Class: DeployPin::Collector
- Inherits:
-
Object
- Object
- DeployPin::Collector
- Includes:
- ActionView::Helpers::DateHelper
- Defined in:
- lib/deploy_pin/collector.rb
Instance Attribute Summary collapse
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
Instance Method Summary collapse
- #executable ⇒ Object
-
#initialize(identifiers:) ⇒ Collector
constructor
A new instance of Collector.
- #list ⇒ Object
- #run ⇒ Object
- #tasks_count ⇒ Object
Constructor Details
#initialize(identifiers:) ⇒ Collector
Returns a new instance of Collector.
10 11 12 |
# File 'lib/deploy_pin/collector.rb', line 10 def initialize(identifiers:) @identifiers = identifiers end |
Instance Attribute Details
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
8 9 10 |
# File 'lib/deploy_pin/collector.rb', line 8 def formatter @formatter end |
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
8 9 10 |
# File 'lib/deploy_pin/collector.rb', line 8 def identifiers @identifiers end |
Instance Method Details
#executable ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/deploy_pin/collector.rb', line 44 def executable # cache tasks _tasks = tasks _tasks.map.with_index do |task, index| task if _tasks[0..index].none? { |_task| task.eql?(_task) } end.compact end |
#list ⇒ Object
37 38 39 40 41 42 |
# File 'lib/deploy_pin/collector.rb', line 37 def list _tasks = tasks _tasks.each_with_index do |task, index| DeployPin.list_formatter.call(index, task) end end |
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/deploy_pin/collector.rb', line 14 def run # cache tasks _tasks = tasks _tasks.each_with_index do |task, index| # run only uniq tasks executable = _tasks[0..index].none? { |_task| task.eql?(_task) } DeployPin.run_formatter.call(index, _tasks.count, task, executable, true) # run if executable if executable time = execution_time do run_with_timeout(task) { task.run } end DeployPin.run_formatter.call(index, _tasks.count, task, executable, false, time) end # mark each task as done task.mark unless task.done? end end |
#tasks_count ⇒ Object
52 53 54 |
# File 'lib/deploy_pin/collector.rb', line 52 def tasks_count tasks.count end |