Sha256: 401452a57ad95fc0cbba662dfd8cccd9a5203981202d2926fe54195b2dc97621

Contents?: true

Size: 963 Bytes

Versions: 3

Compression:

Stored size: 963 Bytes

Contents

module Pronto
  class Runners
    def initialize(runners = Runner.runners, config = Config.new)
      @runners = runners
      @config = config
    end

    def run(patches)
      patches = reject_excluded(patches)
      return [] unless patches.any?

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

    private

    def reject_excluded(patches)
      return patches unless @config.excluded_files.any?
      patches.reject! { |patch| excluded?(patch) }
      patches
    end

    def excluded?(patch)
      @config.excluded_files.include?(patch.new_file_full_path.to_s)
    end

    def exceeds_max?(warnings)
      @config.max_warnings && warnings.count >= @config.max_warnings
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pronto-0.7.1 lib/pronto/runners.rb
pronto-0.7.0 lib/pronto/runners.rb
pronto-0.6.0 lib/pronto/runners.rb