Class: Caracara::Group
- Inherits:
-
Object
- Object
- Caracara::Group
- Defined in:
- lib/caracara/group.rb
Overview
Group
Class Attribute Summary collapse
-
.tasks ⇒ Object
readonly
Tasks.
Instance Attribute Summary collapse
-
#tasks ⇒ Object
readonly
Tasks.
Class Method Summary collapse
-
.init(options = {}) ⇒ Object
Init.
-
.task(name, command) ⇒ Object
Set a new task to the group.
Instance Method Summary collapse
-
#command(name, options = {}, ssh_command = true, escape = true) ⇒ Object
Generate the SSH command.
-
#command_all(options = {}, escape = true) ⇒ Object
Generate all tasks commands.
-
#compile(name, options = {}) ⇒ Object
Compile the tasks.
-
#compile_all(options = {}) ⇒ Object
Compile all the tasks.
-
#initialize(tasks = [], options = {}) ⇒ Group
constructor
Initialize.
Constructor Details
#initialize(tasks = [], options = {}) ⇒ Group
Initialize
9 10 11 12 |
# File 'lib/caracara/group.rb', line 9 def initialize(tasks = [], = {}) @tasks = tasks @options = end |
Class Attribute Details
.tasks ⇒ Object (readonly)
Tasks
65 66 67 |
# File 'lib/caracara/group.rb', line 65 def tasks @tasks end |
Instance Attribute Details
#tasks ⇒ Object (readonly)
Tasks
6 7 8 |
# File 'lib/caracara/group.rb', line 6 def tasks @tasks end |
Class Method Details
.init(options = {}) ⇒ Object
Init
86 87 88 |
# File 'lib/caracara/group.rb', line 86 def init( = {}) new @tasks, end |
.task(name, command) ⇒ Object
Set a new task to the group
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/caracara/group.rb', line 70 def task(name, command) # Check the type of the command if command.is_a? String task = Task.new [command] else task = command.init end # Init the tasks @tasks = {} if @tasks.nil? # Set the task @tasks[name] = task end |
Instance Method Details
#command(name, options = {}, ssh_command = true, escape = true) ⇒ Object
Generate the SSH command
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/caracara/group.rb', line 36 def command(name, = {}, ssh_command = true, escape = true) # Set options = Utils.merge @options, # Generate task command task = @tasks[name].command , false # Do not return the SSH command return task unless ssh_command # Generate the full command SSH.command task, escape end |
#command_all(options = {}, escape = true) ⇒ Object
Generate all tasks commands
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/caracara/group.rb', line 51 def command_all( = {}, escape = true) # Each tasks tasks = @tasks.keys.map do |name| # Compile the task command name, , false end # Generate the full command SSH.command tasks, escape end |
#compile(name, options = {}) ⇒ Object
Compile the tasks
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/caracara/group.rb', line 15 def compile(name, = {}) # Set options = Utils.merge @options, # Get the tasks task = @tasks[name] # Compile the task task.compile end |
#compile_all(options = {}) ⇒ Object
Compile all the tasks
27 28 29 30 31 32 33 |
# File 'lib/caracara/group.rb', line 27 def compile_all( = {}) # Each tasks @tasks.keys.map do |name| # Compile the task compile name, end end |