Class: LogStash::Plugins::Registry::PluginRawContext
- Inherits:
-
Object
- Object
- LogStash::Plugins::Registry::PluginRawContext
- Defined in:
- lib/logstash/plugins/registry.rb
Constant Summary collapse
- HOOK_FILE =
"logstash_registry.rb"
- NAME_DELIMITER =
"-"
Instance Attribute Summary collapse
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
- #execute_hooks! ⇒ Object
- #has_hooks? ⇒ Boolean
-
#hooks_file ⇒ Object
In the context of the plugin, the hook file available need to exist in any top level required paths.
-
#initialize(spec) ⇒ PluginRawContext
constructor
A new instance of PluginRawContext.
- #name ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(spec) ⇒ PluginRawContext
Returns a new instance of PluginRawContext.
40 41 42 43 |
# File 'lib/logstash/plugins/registry.rb', line 40 def initialize(spec) @spec = spec @destructured_name = spec.name.split(NAME_DELIMITER) end |
Instance Attribute Details
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
38 39 40 |
# File 'lib/logstash/plugins/registry.rb', line 38 def spec @spec end |
Instance Method Details
#execute_hooks! ⇒ Object
71 72 73 |
# File 'lib/logstash/plugins/registry.rb', line 71 def execute_hooks! require hooks_file end |
#has_hooks? ⇒ Boolean
67 68 69 |
# File 'lib/logstash/plugins/registry.rb', line 67 def has_hooks? !hooks_file.nil? end |
#hooks_file ⇒ Object
In the context of the plugin, the hook file available need to exist in any top level required paths.
Example for the logstash-output-elasticsearch we have this line in the gemspec.
s.require_paths = [“lib”], so the we will expect to have a ‘logstash_registry.rb` file in the `lib` directory.
60 61 62 63 64 65 |
# File 'lib/logstash/plugins/registry.rb', line 60 def hooks_file @hook_file ||= spec.full_require_paths.collect do |path| f = ::File.join(path, HOOK_FILE) ::File.exist?(f) ? f : nil end.compact.first end |
#name ⇒ Object
45 46 47 |
# File 'lib/logstash/plugins/registry.rb', line 45 def name @destructured_name[2..-1].join(NAME_DELIMITER) end |
#type ⇒ Object
49 50 51 |
# File 'lib/logstash/plugins/registry.rb', line 49 def type @destructured_name[1] end |