Sha256: a1b6c41fc412b2eefc0e69666eaf80fd9c2c7b71f481452d9a3bf1220a4363e8

Contents?: true

Size: 1.06 KB

Versions: 10

Compression:

Stored size: 1.06 KB

Contents

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

    def run(patches)
      patches = reject_excluded(@config.excluded_files('all'), patches)
      return [] if patches.none?

      result = []
      @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

    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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pronto-0.11.0 lib/pronto/runners.rb
pronto-0.10.0 lib/pronto/runners.rb
pronto-0.9.5 lib/pronto/runners.rb
pronto-0.9.4 lib/pronto/runners.rb
pronto-0.9.3 lib/pronto/runners.rb
pronto-0.9.2 lib/pronto/runners.rb
pronto-0.9.1 lib/pronto/runners.rb
pronto-0.9.0 lib/pronto/runners.rb
pronto-0.8.1 lib/pronto/runners.rb
pronto-0.8.0 lib/pronto/runners.rb