Sha256: e7c52081c1b38fbfc8537543a6063587881e61e4634cc491947c690a00e4e6ac

Contents?: true

Size: 866 Bytes

Versions: 33

Compression:

Stored size: 866 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

33 entries across 33 versions & 1 rubygems

Version Path
ree-1.0.32 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.31 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.30 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.29 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.28 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.27 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.26 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.25 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.24 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.23 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.22 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.21 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.20 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.19 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.18 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.17 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.16 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.15 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.14 lib/ree/spec_runner/spec_filename_matcher.rb
ree-1.0.13 lib/ree/spec_runner/spec_filename_matcher.rb