class Pronto::Runners

Attributes

config[R]
runners[R]

Public Class Methods

new(runners = Runner.runners, config = Config.new) click to toggle source
# File lib/pronto/runners.rb, line 3
def initialize(runners = Runner.runners, config = Config.new)
  @runners = runners
  @config = config
end

Public Instance Methods

run(patches) click to toggle source
# File lib/pronto/runners.rb, line 8
def run(patches)
  patches = reject_excluded(config.excluded_files('all'), patches)
  return [] if patches.none?

  result = []
  active_runners.each do |runner|
    next if exceeds_max?(result)
    config.logger.log("Running #{runner}")
    runner_patches = reject_excluded(
      config.excluded_files(runner.title), patches
    )
    next if runner_patches.none?
    result += runner.new(runner_patches, patches.commit).run.flatten.compact
  end
  result = result.take(config.max_warnings) if config.max_warnings
  result
end

Private Instance Methods

active_runner?(runner) click to toggle source
# File lib/pronto/runners.rb, line 34
def active_runner?(runner)
  return true if config.runners.empty? && config.skip_runners.empty?

  if config.runners.empty?
    !config.skip_runners.include?(runner.title)
  else
    active_runner_names = config.runners - config.skip_runners
    active_runner_names.include?(runner.title)
  end
end
active_runners() click to toggle source
# File lib/pronto/runners.rb, line 30
def active_runners
  runners.select { |runner| active_runner?(runner) }
end
exceeds_max?(warnings) click to toggle source
# File lib/pronto/runners.rb, line 53
def exceeds_max?(warnings)
  config.max_warnings && warnings.count >= config.max_warnings
end
reject_excluded(excluded_files, patches) click to toggle source
# File lib/pronto/runners.rb, line 45
def reject_excluded(excluded_files, patches)
  return patches unless excluded_files.any?

  patches.reject do |patch|
    excluded_files.include?(patch.new_file_full_path.to_s)
  end
end