Class: FluentPluginConfigFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/command/plugin_config_formatter.rb

Constant Summary collapse

AVAILABLE_FORMATS =
[:markdown, :txt, :json]
SUPPORTED_TYPES =
[
  "input", "output", "filter",
  "buffer", "parser", "formatter", "storage"
]

Instance Method Summary collapse

Constructor Details

#initialize(argv = ARGV) ⇒ FluentPluginConfigFormatter

Returns a new instance of FluentPluginConfigFormatter.



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fluent/command/plugin_config_formatter.rb', line 34

def initialize(argv = ARGV)
  @argv = argv

  @compact = false
  @format = :markdown
  @verbose = false
  @libs = []
  @plugin_dirs = []
  @options = {}

  prepare_option_parser
end

Instance Method Details

#callObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fluent/command/plugin_config_formatter.rb', line 47

def call
  parse_options!
  init_libraries
  @plugin = Fluent::Plugin.__send__("new_#{@plugin_type}", @plugin_name)
  dumped_config = {}
  if @plugin.class.respond_to?(:plugin_helpers)
    dumped_config[:plugin_helpers] = @plugin.class.plugin_helpers
  end
  @plugin.class.ancestors.reverse_each do |plugin_class|
    next unless plugin_class.respond_to?(:dump_config_definition)
    unless @verbose
      next if plugin_class.name =~ /::PluginHelper::/
    end
    dumped_config_definition = plugin_class.dump_config_definition
    dumped_config[plugin_class.name] = dumped_config_definition unless dumped_config_definition.empty?
  end
  case @format
  when :txt
    puts dump_txt(dumped_config)
  when :markdown
    puts dump_markdown(dumped_config)
  when :json
    puts dump_json(dumped_config)
  end
end