class LogStash::Config::AST::Plugin
Public Instance Methods
compile()
click to toggle source
# File lib/logstash/config/config_ast.rb, line 152 def compile case plugin_type when "input" return "start_input(#{variable_name})" when "filter" # This is some pretty stupid code, honestly. # I'd prefer much if it were put into the Pipeline itself # and this should simply compile to # #{variable_name}.filter(event) return [ "newevents = []", "extra_events.each do |event|", " #{variable_name}.filter(event) do |newevent|", " newevents << newevent", " end", "end", "extra_events += newevents", "#{variable_name}.filter(event) do |newevent|", " extra_events << newevent", "end", "if event.cancelled?", " extra_events.each(&block)", " return", "end", ].map { |l| "#{l}\n" }.join("") when "output" return "#{variable_name}.handle(event)\n" when "codec" settings = attributes.recursive_select(Attribute).collect(&:compile).reject(&:empty?) attributes_code = "LogStash::Util.hash_merge_many(#{settings.map { |c| "{ #{c} }" }.join(", ")})" return "plugin(#{plugin_type.inspect}, #{plugin_name.inspect}, #{attributes_code})" end end
compile_initializer()
click to toggle source
# File lib/logstash/config/config_ast.rb, line 139 def compile_initializer # If any parent is a Plugin, this must be a codec. if attributes.elements.nil? return "plugin(#{plugin_type.inspect}, #{plugin_name.inspect})" << (plugin_type == "codec" ? "" : "\n") else settings = attributes.recursive_select(Attribute).collect(&:compile).reject(&:empty?) attributes_code = "LogStash::Util.hash_merge_many(#{settings.map { |c| "{ #{c} }" }.join(", ")})" return "plugin(#{plugin_type.inspect}, #{plugin_name.inspect}, #{attributes_code})" << (plugin_type == "codec" ? "" : "\n") end end
plugin_name()
click to toggle source
# File lib/logstash/config/config_ast.rb, line 131 def plugin_name return name.text_value end
plugin_type()
click to toggle source
# File lib/logstash/config/config_ast.rb, line 123 def plugin_type if recursive_select_parent(Plugin).any? return "codec" else return recursive_select_parent(PluginSection).first.plugin_type.text_value end end
variable_name()
click to toggle source
# File lib/logstash/config/config_ast.rb, line 135 def variable_name return recursive_select_parent(PluginSection).first.variable(self) end