Class: Wukong::Local::LocalRunner

Inherits:
Runner
  • Object
show all
Includes:
Wukong::Logging
Defined in:
lib/wukong/local/runner.rb

Overview

Implements the Runner for wu-local.

Instance Attribute Summary

Attributes inherited from Runner

#settings

Instance Method Summary collapse

Methods included from Wukong::Logging

included

Methods inherited from Runner

#args, #dataflow?, #dataflow_class_for, description, #description, die, #initialize, #processor?, #program_name, #program_name=, #registered?, #root, run, #usage, usage

Methods included from Runner::BootSequence

#boot!

Methods included from Runner::HelpMessage

#dump_help, #dump_help_and_exit!, #help_given?, #strip_help_param!

Methods included from Runner::DeployPackLoader

#deploy_pack_dir, #environment_file, #in_deploy_pack?, #load_deploy_pack, #loaded_deploy_pack?

Methods included from Runner::CodeLoader

#load_args

Constructor Details

This class inherits a constructor from Wukong::Runner

Instance Method Details

#dataflowString Also known as: processor

Returns the name of the dataflow we're going to run.

Returns:



49
50
51
52
53
54
55
56
57
58
# File 'lib/wukong/local/runner.rb', line 49

def dataflow
  arg      = args.first
  basename = File.basename(arg.to_s, '.rb')

  case
  when settings[:run]          then settings[:run]
  when arg && File.exist?(arg) then basename
  else arg
  end
end

#driverClass, #start

The class used

Returns:

  • (Class, #start)


90
91
92
# File 'lib/wukong/local/runner.rb', line 90

def driver
  StdioDriver
end

#runObject

Starts up the driver with the right dataflow and settings.

Starts the EventMachine reactor before starting the driver.



81
82
83
84
85
# File 'lib/wukong/local/runner.rb', line 81

def run
  EM.run do
    driver.start(dataflow, settings)
  end
end

#setupObject

Adds a customized help message built from the Processor

itself.



73
74
75
76
# File 'lib/wukong/local/runner.rb', line 73

def setup
  super()
  dataflow_class_for(dataflow).configure(settings) if registered?(dataflow)
end

#validatetrue

Validates the chosen processor.

Returns:

  • (true)

Raises:



65
66
67
68
69
# File 'lib/wukong/local/runner.rb', line 65

def validate
  raise Error.new("Must provide a processor or dataflow to run, via either the --run option or as the first argument") if dataflow.nil? || dataflow.empty?
  raise Error.new("No such processor or dataflow <#{dataflow}>") unless registered?(dataflow)
  true
end