Class: DeployPin::Task
- Inherits:
-
Object
- Object
- DeployPin::Task
- Extended by:
- ParallelWrapper
- Includes:
- ParallelWrapper
- Defined in:
- lib/deploy_pin/task.rb
Constant Summary
Constants included from ParallelWrapper
ParallelWrapper::PARALLEL_PREFIX
Instance Attribute Summary collapse
-
#explicit_timeout ⇒ Object
readonly
Returns the value of attribute explicit_timeout.
-
#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
- #explicit_timeout? ⇒ Boolean
-
#initialize(file) ⇒ Task
constructor
A new instance of Task.
- #mark ⇒ Object
- #parallel? ⇒ Boolean
- #parse_file ⇒ Object
- #run ⇒ Object
Methods included from ParallelWrapper
method_missing, respond_to_missing?
Constructor Details
#initialize(file) ⇒ Task
Returns a new instance of Task.
16 17 18 19 20 21 22 23 24 |
# File 'lib/deploy_pin/task.rb', line 16 def initialize(file) @file = file @uuid = nil @group = nil @title = '' @script = '' @explicit_timeout = false @parallel = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DeployPin::ParallelWrapper
Instance Attribute Details
#explicit_timeout ⇒ Object (readonly)
Returns the value of attribute explicit_timeout.
9 10 11 |
# File 'lib/deploy_pin/task.rb', line 9 def explicit_timeout @explicit_timeout end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
9 10 11 |
# File 'lib/deploy_pin/task.rb', line 9 def file @file end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
9 10 11 |
# File 'lib/deploy_pin/task.rb', line 9 def group @group end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
9 10 11 |
# File 'lib/deploy_pin/task.rb', line 9 def script @script end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/deploy_pin/task.rb', line 9 def title @title end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
9 10 11 |
# File 'lib/deploy_pin/task.rb', line 9 def uuid @uuid end |
Instance Method Details
#details ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/deploy_pin/task.rb', line 65 def details { uuid: uuid, group: group, title: title } end |
#done? ⇒ Boolean
36 37 38 |
# File 'lib/deploy_pin/task.rb', line 36 def done? DeployPin::Record.where(uuid: uuid).exists? end |
#eql?(other) ⇒ Boolean
73 74 75 76 |
# File 'lib/deploy_pin/task.rb', line 73 def eql?(other) # same script & different uuid script == other.script && uuid != other.uuid end |
#explicit_timeout? ⇒ Boolean
40 41 42 |
# File 'lib/deploy_pin/task.rb', line 40 def explicit_timeout? @explicit_timeout end |
#mark ⇒ Object
31 32 33 34 |
# File 'lib/deploy_pin/task.rb', line 31 def mark # store record in the DB DeployPin::Record.create(uuid: uuid) end |
#parallel? ⇒ Boolean
44 45 46 |
# File 'lib/deploy_pin/task.rb', line 44 def parallel? @parallel end |
#parse_file ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/deploy_pin/task.rb', line 48 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 @explicit_timeout = true if line =~ /Database.execute_with_timeout.*/ @parallel = true if line =~ /[Pp]arallel.*/ end end end |
#run ⇒ Object
26 27 28 29 |
# File 'lib/deploy_pin/task.rb', line 26 def run # eval script eval(script) end |