class Runnerbean::Runner
Attributes
name[R]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/runnerbean/runner.rb, line 7 def initialize(opts = {}) @name = opts[:name] || 'runner' end
Public Instance Methods
add_process(opts)
click to toggle source
# File lib/runnerbean/runner.rb, line 11 def add_process(opts) opts.each do |key, value| process_index[key] = value end end
group(*process_names)
click to toggle source
# File lib/runnerbean/runner.rb, line 31 def group(*process_names) process_group(*process_names) end
kill!(*process_names)
click to toggle source
# File lib/runnerbean/runner.rb, line 17 def kill!(*process_names) pg = process_group(*process_names) pg.name = name pg.kill! pg # allows chaining end
start!(*process_names)
click to toggle source
# File lib/runnerbean/runner.rb, line 24 def start!(*process_names) pg = process_group(*process_names) pg.name = name pg.start! pg # allows chaining end
Private Instance Methods
process_from_name(name)
click to toggle source
# File lib/runnerbean/runner.rb, line 46 def process_from_name(name) process_index.fetch(name) rescue KeyError => e raise ProcessNotDefined, e.message end
process_group(*process_names)
click to toggle source
# File lib/runnerbean/runner.rb, line 37 def process_group(*process_names) processes = processes_from_names(*process_names) ProcessGroup.new(*processes) end
process_index()
click to toggle source
# File lib/runnerbean/runner.rb, line 52 def process_index @process_index ||= {} end
processes_from_names(*process_names)
click to toggle source
# File lib/runnerbean/runner.rb, line 42 def processes_from_names(*process_names) process_names.map { |pn| process_from_name(pn) } end