class DeployPin::Collector

Attributes

identifiers[R]

Public Class Methods

new(identifiers:) click to toggle source
# File lib/deploy_pin/collector.rb, line 8
def initialize(identifiers:)
  @identifiers = identifiers
end

Public Instance Methods

exacutable() click to toggle source
# File lib/deploy_pin/collector.rb, line 36
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
list() { |index, count, task| ... } click to toggle source
# File lib/deploy_pin/collector.rb, line 29
def list
  _tasks = tasks
  _tasks.each_with_index do |task, index|
    yield(index, _tasks.count, task)
  end
end
run() { |index, count, task, executable| ... } click to toggle source
# 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
    task.run if executable

    # mark each task as done
    task.mark unless task.done?
  end
end
tasks_count() click to toggle source
# File lib/deploy_pin/collector.rb, line 44
def tasks_count
  tasks.count
end

Private Instance Methods

files() click to toggle source
# File lib/deploy_pin/collector.rb, line 50
def files
  Dir["#{DeployPin.tasks_path}/*.rb"]
end
task_criteria() click to toggle source
# File lib/deploy_pin/collector.rb, line 64
def task_criteria
  @task_criteria ||= DeployPin::TaskCriteria.new(identifiers: identifiers)
end
tasks() click to toggle source
# File lib/deploy_pin/collector.rb, line 54
def tasks
  files.map do |file|
    task = DeployPin::Task.new(file)
    task.parse_file

    # check if task is suitable
    task if task_criteria.suitable?(task)
  end.compact.sort # sort by group position in config
end