Class: Retest::MatchingOptions::Path

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/retest/matching_options/path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Path

Returns a new instance of Path.



11
12
13
# File 'lib/retest/matching_options/path.rb', line 11

def initialize(path)
  @pathname = Pathname(path)
end

Instance Attribute Details

#pathnameObject (readonly)

Returns the value of attribute pathname.



10
11
12
# File 'lib/retest/matching_options/path.rb', line 10

def pathname
  @pathname
end

Instance Method Details

#dirnamesObject



19
20
21
# File 'lib/retest/matching_options/path.rb', line 19

def dirnames
  @dirnames ||= dirname.each_filename.to_a
end

#possible_test?(file) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/retest/matching_options/path.rb', line 31

def possible_test?(file)
  possible_test_regexs.any? { |regex| regex =~ file }
end

#reversed_dirnamesObject



15
16
17
# File 'lib/retest/matching_options/path.rb', line 15

def reversed_dirnames
  @reversed_dirnames ||= dirnames.reverse
end

#similarity_score(file) ⇒ Object



35
36
37
# File 'lib/retest/matching_options/path.rb', line 35

def similarity_score(file)
  String::Similarity.levenshtein(to_s, file)
end

#test?(test_directories: nil) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/retest/matching_options/path.rb', line 23

def test?(test_directories: nil)
  if test_directories && (test_directories & dirnames).empty?
    return false
  end

  test_regexs.any? { |regex| regex =~ to_s }
end