Class: DeployPin::Task
- Inherits:
-
Object
- Object
- DeployPin::Task
- Defined in:
- lib/deploy_pin/task.rb
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.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
- #details ⇒ Object
- #done? ⇒ Boolean
- #eql?(other) ⇒ Boolean
-
#initialize(file) ⇒ Task
constructor
A new instance of Task.
- #mark ⇒ Object
- #parse_file ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(file) ⇒ Task
Returns a new instance of Task.
12 13 14 15 16 17 18 |
# File 'lib/deploy_pin/task.rb', line 12 def initialize(file) @file = file @uuid = nil @group = nil @title = '' @script = '' end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/deploy_pin/task.rb', line 6 def file @file end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
6 7 8 |
# File 'lib/deploy_pin/task.rb', line 6 def group @group end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
6 7 8 |
# File 'lib/deploy_pin/task.rb', line 6 def script @script end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/deploy_pin/task.rb', line 6 def title @title end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
6 7 8 |
# File 'lib/deploy_pin/task.rb', line 6 def uuid @uuid end |
Instance Method Details
#details ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/deploy_pin/task.rb', line 48 def details { uuid: uuid, group: group, title: title } end |
#done? ⇒ Boolean
30 31 32 |
# File 'lib/deploy_pin/task.rb', line 30 def done? DeployPin::Record.where(uuid: uuid).exists? end |
#eql?(other) ⇒ Boolean
56 57 58 59 |
# File 'lib/deploy_pin/task.rb', line 56 def eql?(other) # same script & different uuid script == other.script && uuid != other.uuid end |
#mark ⇒ Object
25 26 27 28 |
# File 'lib/deploy_pin/task.rb', line 25 def mark # store record in the DB DeployPin::Record.create(uuid: uuid) end |
#parse_file ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/deploy_pin/task.rb', line 34 def parse_file File.foreach(file) do |line| case line.strip when /\A# (\d+):(\w+)/ @uuid = Regexp.last_match(1) @group = Regexp.last_match(2) when /\A# task_title:(.+)/ @title = Regexp.last_match(1).strip when /\A[^#].*/ @script += line end end end |
#run ⇒ Object
20 21 22 23 |
# File 'lib/deploy_pin/task.rb', line 20 def run # eval script eval(script) end |