Sha256: 76dfe3b1c067f43ac09eca4d77bf854eed5890dfab3260e1692363de936b7f5c

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

module KnapsackPro
  class TestFileFinder
    def self.call(test_file_pattern)
      new(test_file_pattern).call
    end

    def initialize(test_file_pattern)
      @test_file_pattern = test_file_pattern
    end

    def call
      test_file_hashes = []
      test_files.each do |test_file_path|
        test_file_hashes << test_file_hash_for(test_file_path)
      end
      test_file_hashes
    end

    private

    attr_reader :test_file_pattern

    def test_files
      if KnapsackPro::Config::Env.test_file_list
        return KnapsackPro::Config::Env.test_file_list.split(',').map(&:strip)
      end

      test_file_paths = Dir.glob(test_file_pattern).uniq

      excluded_test_file_paths =
        if KnapsackPro::Config::Env.test_file_exclude_pattern
          Dir.glob(KnapsackPro::Config::Env.test_file_exclude_pattern).uniq
        else
          []
        end

      (test_file_paths - excluded_test_file_paths).sort
    end

    def test_file_hash_for(test_file_path)
      {
        'path' => TestFileCleaner.clean(test_file_path)
      }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
knapsack_pro-1.20.2 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.20.1 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.20.0 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.19.0 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.18.2 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.18.1 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.18.0 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.17.0 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.16.1 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.16.0 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.15.0 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.14.0 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.13.0 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.12.1 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.12.0 lib/knapsack_pro/test_file_finder.rb
knapsack_pro-1.11.0 lib/knapsack_pro/test_file_finder.rb