Class: Yapra::Runtime

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

Overview

How to use

require 'yapra/runtime'
require 'yapra/config'

config = YAML.load(config_file)
config = Yapra::Config.new(config)

Yapra::Runtime.logger = Logger.new(STDOUT)

yapra = Yapra::Runtime.new(config.env)
yapra.execute(config.pipeline_commands)

config_file format written in Yapra::Config document.

Constant Summary collapse

@@logger =
Logger.new(STDOUT)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env = {}, legacy_plugin_registry_factory = nil) ⇒ Runtime

Returns a new instance of Runtime.



28
29
30
31
32
# File 'lib/yapra/runtime.rb', line 28

def initialize env={}, legacy_plugin_registry_factory=nil
  @env    = env
  
  @legacy_plugin_registry_factory        = legacy_plugin_registry_factory
end

Instance Attribute Details

#current_pipelineObject (readonly)

Returns the value of attribute current_pipeline.



24
25
26
# File 'lib/yapra/runtime.rb', line 24

def current_pipeline
  @current_pipeline
end

#envObject (readonly)

Returns the value of attribute env.



22
23
24
# File 'lib/yapra/runtime.rb', line 22

def env
  @env
end

#legacy_plugin_registry_factoryObject (readonly)

Returns the value of attribute legacy_plugin_registry_factory.



23
24
25
# File 'lib/yapra/runtime.rb', line 23

def legacy_plugin_registry_factory
  @legacy_plugin_registry_factory
end

Class Method Details

.loggerObject



51
52
53
# File 'lib/yapra/runtime.rb', line 51

def self.logger
  @@logger
end

.logger=(logger) ⇒ Object



55
56
57
# File 'lib/yapra/runtime.rb', line 55

def self.logger=logger
  @@logger = logger
end

Instance Method Details

#execute(pipeline_commands) ⇒ Object

execute pipelines from commands.



35
36
37
38
39
# File 'lib/yapra/runtime.rb', line 35

def execute pipeline_commands
  pipeline_commands.each do |k, v|
    execute_pipeline k, v, []
  end
end

#execute_pipeline(pipeline_name, command_array, data = []) ⇒ Object

execute one pipeline.



42
43
44
45
46
47
48
49
# File 'lib/yapra/runtime.rb', line 42

def execute_pipeline pipeline_name, command_array, data=[]
  self.class.logger.info("# pipeline '#{pipeline_name}' is started...")
  pipeline = Yapra::Pipeline.new(pipeline_name, self)
  @current_pipeline = pipeline
  legacy_plugin_registory = legacy_plugin_registry_factory.create(pipeline) if legacy_plugin_registry_factory
  pipeline.run(command_array, data)
  @current_pipeline = nil
end