Sha256: b7a114909df4e1e309d09fe8c2b4204b52bb536806d17eee2228b12485ecd5fd

Contents?: true

Size: 864 Bytes

Versions: 15

Compression:

Stored size: 864 Bytes

Contents

# frozen_string_literal: true

class Ree::SpecRunner::SpecFilenameMatcher
  class << self
    def find_matches(package_path:, spec_matcher:)
      Ree::SpecRunner::SpecFilenameMatcher.new(package_path, spec_matcher).find_matches
    end
  end

  def initialize(package_path, spec_matcher)
    @package_path = File.expand_path(package_path)
    @spec_matcher = spec_matcher
  end

  def find_matches
    expected_filename = File.join(@package_path, @spec_matcher)

    if File.exist?(expected_filename)
      return Pathname.new(expected_filename).relative_path_from(Pathname.new(@package_path)).to_s.split
    end

    Dir.glob(File.join(@package_path, '**/*_spec.rb'))
      .select { |fn| File.file?(fn) }
      .map {|file| Pathname.new(file).relative_path_from(Pathname.new(@package_path)).to_s }
      .grep(/#{@spec_matcher.split('').join('.*')}/)
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ree-1.0.47 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.46 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.45 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.44 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.43 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.42 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.41 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.40 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.39 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.38 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.37 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.36 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.35 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.34 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.33 lib/ree/spec_runner/spec_filename_matcher.rb