Module: RSpecTracer::SourceFile
- Defined in:
- lib/rspec_tracer/source_file.rb
Overview
Path manipulation helpers used by Example.location_file_name. Post-coverage-stack retirement, the only caller is example.rb (the legacy CoverageReporter that previously used these is gone).
All methods declared ‘def self.x` per feedback_mutation_friendly_modules so mutant observes mutations through the singleton call path.
Constant Summary collapse
- PROJECT_ROOT_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Internal constant.
Regexp.new("^#{Regexp.escape(RSpecTracer.root)}").freeze
Class Method Summary collapse
-
.absolute_external_file?(file_name) ⇒ Boolean
private
Internal helper for the tracer pipeline.
-
.file_name(file_path) ⇒ Object
private
Internal helper for the tracer pipeline.
-
.file_path(file_name) ⇒ Object
private
Internal helper for the tracer pipeline.
-
.from_name(file_name) ⇒ Object
private
Internal helper for the tracer pipeline.
-
.from_path(file_path) ⇒ Object
private
Internal helper for the tracer pipeline.
Class Method Details
.absolute_external_file?(file_name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal helper for the tracer pipeline.
50 51 52 53 54 |
# File 'lib/rspec_tracer/source_file.rb', line 50 def self.absolute_external_file?(file_name) file_name.start_with?('/') && !file_name.start_with?(RSpecTracer.root) && File.file?(file_name) end |
.file_name(file_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal helper for the tracer pipeline.
36 37 38 |
# File 'lib/rspec_tracer/source_file.rb', line 36 def self.file_name(file_path) file_path.sub(PROJECT_ROOT_REGEX, '') end |
.file_path(file_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal helper for the tracer pipeline.
42 43 44 45 46 |
# File 'lib/rspec_tracer/source_file.rb', line 42 def self.file_path(file_name) return file_name if absolute_external_file?(file_name) File.(file_name.sub(%r{^/}, ''), RSpecTracer.root) end |
.from_name(file_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal helper for the tracer pipeline.
30 31 32 |
# File 'lib/rspec_tracer/source_file.rb', line 30 def self.from_name(file_name) from_path(file_path(file_name)) end |
.from_path(file_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal helper for the tracer pipeline.
18 19 20 21 22 23 24 25 26 |
# File 'lib/rspec_tracer/source_file.rb', line 18 def self.from_path(file_path) return unless File.file?(file_path) { file_path: file_path, file_name: file_name(file_path), digest: Digest::MD5.hexdigest(File.binread(file_path)) } end |