Class: DeployPin::Task
- Inherits:
-
Object
- Object
- DeployPin::Task
- Defined in:
- lib/deploy_pin/task.rb
Overview
Task wrapper
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
-
#<=>(task_b) ⇒ Object
for sorting.
- #details ⇒ Object
- #group_index ⇒ Object
-
#initialize(file) ⇒ Task
constructor
A new instance of Task.
- #parse_file ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(file) ⇒ Task
Returns a new instance of Task.
10 11 12 13 14 15 |
# File 'lib/deploy_pin/task.rb', line 10 def initialize(file) @file = file @uuid = nil @group = nil @script = "" end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
5 6 7 |
# File 'lib/deploy_pin/task.rb', line 5 def file @file end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
5 6 7 |
# File 'lib/deploy_pin/task.rb', line 5 def group @group end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
5 6 7 |
# File 'lib/deploy_pin/task.rb', line 5 def script @script end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
5 6 7 |
# File 'lib/deploy_pin/task.rb', line 5 def uuid @uuid end |
Instance Method Details
#<=>(task_b) ⇒ Object
for sorting
33 34 35 |
# File 'lib/deploy_pin/task.rb', line 33 def <=>(task_b) group_index <=> task_b.group_index end |
#details ⇒ Object
28 29 30 |
# File 'lib/deploy_pin/task.rb', line 28 def details puts @uuid, @group, @script end |
#group_index ⇒ Object
37 38 39 |
# File 'lib/deploy_pin/task.rb', line 37 def group_index DeployPin.groups.index(group) end |
#parse_file ⇒ Object
21 22 23 24 25 26 |
# File 'lib/deploy_pin/task.rb', line 21 def parse_file @script = File.read(file) @script.lines[0] =~ /\A# (\d+):(\w+)/ @uuid = $1 @group = $2 end |
#run ⇒ Object
17 18 19 |
# File 'lib/deploy_pin/task.rb', line 17 def run eval(@script) end |