Class: Wukong::Local::LocalRunner
- Includes:
- Wukong::Logging
- Defined in:
- lib/wukong/local/runner.rb
Overview
Implements the Runner for wu-local.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Runner
Instance Method Summary collapse
-
#driver ⇒ Wukong::Local::TCPDriver, Wukong::Local::StdioDriver
The driver this Runner will use.
-
#processor ⇒ String
Returns the name of the processor we're going to run.
-
#run ⇒ Object
Runs either the StdioDriver or the TCPDriver, depending on what settings were passed.
-
#setup ⇒ Object
Adds a customized help message built from the Processor # itself.
-
#validate ⇒ true
Validates the chosen processor.
Methods included from Wukong::Logging
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
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
Constructor Details
This class inherits a constructor from Wukong::Runner
Instance Method Details
#driver ⇒ Wukong::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 |
#processor ⇒ String
Returns the name of the processor we're going to run.
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 |
#run ⇒ Object
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 |
#setup ⇒ Object
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 |
#validate ⇒ true
Validates the chosen processor.
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 |