Class: Avocado::Task
- Inherits:
-
Object
- Object
- Avocado::Task
- Defined in:
- lib/avocado/task/task.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#name ⇒ Object
Returns the value of attribute name.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
Class Method Summary collapse
-
.from_task_block(name, options, &block) ⇒ Task
Creates a new task from a task block in the deployment configuration process.
Instance Method Summary collapse
-
#invoke(env) ⇒ mixed
Runs the code of a task.
-
#pretty_print ⇒ Object
Prettyprints a command using a table.
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
25 26 27 |
# File 'lib/avocado/task/task.rb', line 25 def block @block end |
#desc ⇒ Object
Returns the value of attribute desc.
26 27 28 |
# File 'lib/avocado/task/task.rb', line 26 def desc @desc end |
#name ⇒ Object
Returns the value of attribute name.
22 23 24 |
# File 'lib/avocado/task/task.rb', line 22 def name @name end |
#scope ⇒ Object
Returns the value of attribute scope.
23 24 25 |
# File 'lib/avocado/task/task.rb', line 23 def scope @scope end |
#visibility ⇒ Object
Returns the value of attribute visibility.
24 25 26 |
# File 'lib/avocado/task/task.rb', line 24 def visibility @visibility end |
Class Method Details
.from_task_block(name, options, &block) ⇒ Task
Creates a new task from a task block in the deployment configuration process
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/avocado/task/task.rb', line 34 def self.from_task_block(name, , &block) instance = self.new instance.name = name instance.block = block instance.scope = :local if .has_key?(:scope) && [:scope] == :remote instance.scope = :remote end instance.visibility = :public if .has_key?(:visibility) && [:visibility] == :private instance.visibility = :private end if .has_key?(:desc) instance.desc = [:desc] end instance end |
Instance Method Details
#invoke(env) ⇒ mixed
Runs the code of a task
63 64 65 66 67 68 69 70 71 |
# File 'lib/avocado/task/task.rb', line 63 def invoke(env) raise ArgumentError 'env must be a valid TaskExecutionEnvironment' unless env.kind_of?(Avocado::TaskExecutionEnvironment) avo = Avocado::Deployment.instance avo.log.debug "Running task #{@name}" env.instance_eval(&@block) end |
#pretty_print ⇒ Object
Prettyprints a command using a table
74 75 76 77 78 79 80 81 |
# File 'lib/avocado/task/task.rb', line 74 def pretty_print puts Terminal::Table.new :title => 'Task overview', :rows => [ ['Name', @name.to_s], ['Description', @desc.to_s], ['Scope', @scope.to_s], ['Visibility', @visibility.to_s], ] end |