Class: Nutella::RunCommand
Overview
This class describes a run command which can be either start or stop. It is mostly a commodity class for code reuse.
Instance Method Summary collapse
-
#extract_names(args) ⇒ String
Extracts run name and run_id.
-
#for_each_actor_in_dir(actors_dir) {|actor_dir| ... } ⇒ Object
Executes a code block for each actor in a certain directory.
- #output_success_message(run_id, run, action) ⇒ Object
- #run(args = nil) ⇒ Object
Instance Method Details
#extract_names(args) ⇒ String
Extracts run name and run_id
15 16 17 18 19 20 21 |
# File 'lib/core/run_command.rb', line 15 def extract_names( args ) # Check that the run name passed as parameter is not nil run = args.nil? ? nil : args[0] # Extract run_id run_id = args.nil? ? Nutella.runlist.extract_run_id( '' ) : Nutella.runlist.extract_run_id( args[0] ) return run, run_id end |
#for_each_actor_in_dir(actors_dir) {|actor_dir| ... } ⇒ Object
Executes a code block for each actor in a certain directory
26 27 28 29 30 |
# File 'lib/core/run_command.rb', line 26 def for_each_actor_in_dir( actors_dir, &block ) Dir.entries(actors_dir).select {|entry| File.directory?(File.join(actors_dir, entry)) && !(entry =='.' || entry == '..') }.each do |actor_dir| block.call actor_dir end end |
#output_success_message(run_id, run, action) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/core/run_command.rb', line 33 def (run_id, run, action) if run_id == Nutella.current_project.config['name'] console.success "Project #{Nutella.current_project.config['name']} #{action}!" else console.success "Project #{Nutella.current_project.config['name']}, run #{run} #{action}!" end end |
#run(args = nil) ⇒ Object
8 9 10 |
# File 'lib/core/run_command.rb', line 8 def run (args=nil) console.error 'Running generic RunCommand!!! WAT?' end |