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.

Direct Known Subclasses

SpecHelpers::UnitTestRunner

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

#driverWukong::Local::TCPDriver, Wukong::Local::StdioDriver

The driver this Runner will use.

Defaults to the Wukong::Local::StdioDriver, but will use the TcpDriver if it has a :port setting defined.



92
93
94
# File 'lib/wukong/local/runner.rb', line 92

def driver
  (settings[:tcp_port] ? TCPDriver : StdioDriver)
end

#processorString

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

Returns:



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

def processor
  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

#runObject

Runs either the StdioDriver or the TCPDriver, depending on what settings were passed.



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

def run
  EM.run do 
    driver.start(processor, 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(processor).configure(settings) if processor?(processor)
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 processor.nil? || processor.empty?
  raise Error.new("No such processor or dataflow <#{processor}>") unless registered?(processor)
  true
end