Module: SolargraphTestCoverage::FileHelpers
- Extended by:
- FileHelpers
- Included in:
- FileHelpers
- Defined in:
- lib/solargraph_test_coverage/file_helpers.rb
Instance Method Summary collapse
- #relative_path(path) ⇒ Object
- #relative_test_file(filename) ⇒ Object
- #test_file(filename) ⇒ Object
- #test_file?(filename) ⇒ Boolean
Instance Method Details
#relative_path(path) ⇒ Object
17 18 19 |
# File 'lib/solargraph_test_coverage/file_helpers.rb', line 17 def relative_path(path) path.sub("#{Dir.pwd}/", '') end |
#relative_test_file(filename) ⇒ Object
21 22 23 |
# File 'lib/solargraph_test_coverage/file_helpers.rb', line 21 def relative_test_file(filename) relative_path test_file(filename) end |
#test_file(filename) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/solargraph_test_coverage/file_helpers.rb', line 7 def test_file(filename) return filename if test_file?(filename) path = relative_path(filename).split('/') path[0] = Config.test_dir path[-1] = path.last.sub(/\.rb$/, Config.test_file_suffix) File.join(Dir.pwd, path.join('/')) end |
#test_file?(filename) ⇒ Boolean
25 26 27 28 |
# File 'lib/solargraph_test_coverage/file_helpers.rb', line 25 def test_file?(filename) filename.start_with?(Config.full_test_dir) && filename.end_with?(Config.test_file_suffix) end |