Class: DeployPin::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/deploy_pin/collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifiers:) ⇒ Collector

Returns a new instance of Collector.



8
9
10
# File 'lib/deploy_pin/collector.rb', line 8

def initialize(identifiers:)
  @identifiers = identifiers
end

Instance Attribute Details

#identifiersObject (readonly)

Returns the value of attribute identifiers.



6
7
8
# File 'lib/deploy_pin/collector.rb', line 6

def identifiers
  @identifiers
end

Instance Method Details

#exacutableObject



40
41
42
43
44
45
46
# File 'lib/deploy_pin/collector.rb', line 40

def exacutable
  # cache tasks
  _tasks = tasks
  _tasks.map.with_index do |task, index|
    task if _tasks[0..index].none? { |_task| task.eql?(_task) }
  end.compact
end

#listObject



33
34
35
36
37
38
# File 'lib/deploy_pin/collector.rb', line 33

def list
  _tasks = tasks
  _tasks.each_with_index do |task, index|
    yield(index, _tasks.count, task)
  end
end

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/deploy_pin/collector.rb', line 12

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) }

    yield(index, _tasks.count, task, executable)

    # run if executable
    if executable
      run_with_timeout(!task.explicit_timeout? && !task.parallel?) do
        task.run
      end
    end

    # mark each task as done
    task.mark unless task.done?
  end
end

#tasks_countObject



48
49
50
# File 'lib/deploy_pin/collector.rb', line 48

def tasks_count
  tasks.count
end