Class: Nutella::RunCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/core/run_command.rb

Overview

This class describes a run command which can be either start or stop. It is mostly a commodity class for code reuse.

Direct Known Subclasses

Start, Stop

Instance Method Summary collapse

Instance Method Details

#extract_names(args) ⇒ String

Extracts run name and run_id

Parameters:

  • command line arguments passed to the command

Returns:

  • the run name (cleaned of nils) and the 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

Parameters:

  • directory where we are iterating

Yields:

  • (actor_dir)

    Gives the actor directory to the block



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 output_success_message(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