Class: Retest::MatchingOptions::Path
- Inherits:
-
Object
- Object
- Retest::MatchingOptions::Path
- Extended by:
- Forwardable
- Defined in:
- lib/retest/matching_options/path.rb
Instance Attribute Summary collapse
-
#pathname ⇒ Object
readonly
Returns the value of attribute pathname.
Instance Method Summary collapse
- #dirnames ⇒ Object
-
#initialize(path) ⇒ Path
constructor
A new instance of Path.
- #possible_test?(file) ⇒ Boolean
- #reversed_dirnames ⇒ Object
- #similarity_score(file) ⇒ Object
- #test?(test_directories: nil) ⇒ Boolean
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
#pathname ⇒ Object (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
#dirnames ⇒ Object
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
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_dirnames ⇒ Object
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
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 |