Class: Yapra::PipelineBase

Inherits:
Object
  • Object
show all
Defined in:
lib/yapra/pipeline_base.rb

Direct Known Subclasses

Pipeline, RbPipeline

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pipeline_name, yapra = Yapra::Runtime.new) ⇒ PipelineBase

Returns a new instance of PipelineBase.



9
10
11
12
13
14
15
# File 'lib/yapra/pipeline_base.rb', line 9

def initialize pipeline_name, yapra=Yapra::Runtime.new
  @logger             = nil
  @yapra              = yapra
  @context            = { 'pipeline_name' => pipeline_name }
  
  @module_name_prefix = construct_module_name_prefix yapra.env
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/yapra/pipeline_base.rb', line 6

def context
  @context
end

#loggerObject



21
22
23
# File 'lib/yapra/pipeline_base.rb', line 21

def logger
  return @logger || Yapra::Runtime.logger
end

#yapraObject (readonly)

Returns the value of attribute yapra.



6
7
8
# File 'lib/yapra/pipeline_base.rb', line 6

def yapra
  @yapra
end

Instance Method Details

#load(command) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/yapra/pipeline_base.rb', line 25

def load command
  plugin_name = command['module']
  load_error_stack = []
  plugin_class = nil
  @module_name_prefix.each do |prefix|
    yapra_module_name = "#{prefix}#{plugin_name}"
    begin
      plugin_class      = Yapra.load_class_constant(yapra_module_name)
      break if plugin_class
    rescue LoadError, NameError => ex
      load_error_stack << ex
    end
  end
  raise_load_error(load_error_stack, command) unless plugin_class
  
  plugin = initialize_plugin( plugin_class )
  
  plugin
end

#nameObject



17
18
19
# File 'lib/yapra/pipeline_base.rb', line 17

def name
  self.context[ 'pipeline_name' ]
end