Class: Yapra::Pipeline
- Inherits:
-
PipelineBase
- Object
- PipelineBase
- Yapra::Pipeline
- Defined in:
- lib/yapra/pipeline.rb
Constant Summary collapse
- UPPER_CASE =
/[A-Z]/
Instance Attribute Summary collapse
-
#legacy_plugin_registry ⇒ Object
Returns the value of attribute legacy_plugin_registry.
Attributes inherited from PipelineBase
Instance Method Summary collapse
- #execute_plugin(command, data) ⇒ Object
-
#run(pipeline_command, data = []) ⇒ Object
start pipeline from commands.
Methods inherited from PipelineBase
Constructor Details
This class inherits a constructor from Yapra::PipelineBase
Instance Attribute Details
#legacy_plugin_registry ⇒ Object
Returns the value of attribute legacy_plugin_registry.
8 9 10 |
# File 'lib/yapra/pipeline.rb', line 8 def legacy_plugin_registry @legacy_plugin_registry end |
Instance Method Details
#execute_plugin(command, data) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/yapra/pipeline.rb', line 51 def execute_plugin command, data self.logger.info("exec plugin #{command["module"]}") if class_based_plugin?(command['module']) run_class_based_plugin command, data else run_legacy_plugin command, data end end |
#run(pipeline_command, data = []) ⇒ Object
start pipeline from commands.
example:
pipeline.run([
{
'module' => 'Config::agent',
'config' => {
'user_agent_alias' => 'Windows IE 6'
}
},
{
'module' => 'RSS::load',
'config' => {
'uri' => 'http://www.example.com/hoge.rdf'
}
},
{
'module' => 'print'
}
])
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/yapra/pipeline.rb', line 33 def run pipeline_command, data=[] @plugins = [] begin pipeline_command.inject(data) do |data, command| execute_plugin(command, data.clone) end rescue => ex @plugins.each do |plugin| begin plugin.on_error(ex) if plugin.respond_to?('on_error') rescue => exx self.logger.error("error is occured when error handling: #{exx.}") end end raise ex end end |