class Turbo

Public Class Methods

new(conf) click to toggle source
# File lib/turbo.rb, line 18
    def initialize(conf)
f = File.join(File.dirname(File.expand_path(__FILE__)), conf ? conf : "config/turbo.conf")
            @conf = JSON.parse(File.read(f))
@conf['conf_path'] = File.dirname(File.absolute_path(f))
    end

Public Instance Methods

run_workflow(workflow=nil) click to toggle source
# File lib/turbo.rb, line 24
def run_workflow(workflow=nil)
    wf = JSON.parse(File.read("workflows/#{workflow}/workflow.json"))

    @workflow_path = "workflows/#{workflow}"
    @pre_command = "#{@workflow_path}/#{wf['before']}"
    @post_command = "#{@workflow_path}/#{wf['after']}"
    @debug_file = 'debug.log'

    scenarios = wf['scenarios']
    @run_success = 0
    @run_failed = 0

    execute_before_script
    scenarios.each do |scenario|
        run_scenario("#{@workflow_path}/scenarios/#{scenario}")
    end
    execute_after_script
end

Private Instance Methods

bootstrap(scenario) click to toggle source
# File lib/turbo.rb, line 70
def bootstrap(scenario)
  config = load_common.rmerge(load_scenario(scenario)).to_hashugar

  def config.get_binding
    binding
  end

  config  
end
execute_after_script() click to toggle source
# File lib/turbo.rb, line 48
def execute_after_script
    system "#{@post_command}"
end
execute_before_script() click to toggle source
# File lib/turbo.rb, line 44
def execute_before_script
    system "#{@pre_command}"
end
load_common() click to toggle source
# File lib/turbo.rb, line 62
def load_common
        JSON.parse(File.read(@conf['conf_path'] + '/' + @conf['common_conf']))
end
load_scenario(scenario) click to toggle source
# File lib/turbo.rb, line 66
def load_scenario(scenario)
        JSON.parse(File.read(scenario))
end
run(scenario=nil) click to toggle source
# File lib/turbo.rb, line 52
def run(scenario=nil)
        if scenario
                run_scenario(scenario)
        else
                Dir.glob(@conf['scenarios_path']) do |json_file|
                        run_scenario(json_file)
                end
        end
end
run_scenario(scenario) click to toggle source
# File lib/turbo.rb, line 80
def run_scenario(scenario)
  generate_command(@workflow_path, bootstrap(scenario))
end