module RSpecTracer::SourceFile

Constants

PROJECT_ROOT_REGEX

Public Instance Methods

file_name(file_path) click to toggle source
# File lib/rspec_tracer/source_file.rb, line 23
def file_name(file_path)
  file_path.sub(PROJECT_ROOT_REGEX, '')
end
file_path(file_name) click to toggle source
# File lib/rspec_tracer/source_file.rb, line 27
def file_path(file_name)
  File.expand_path(file_name.sub(%r{^/}, ''), RSpecTracer.root)
end
from_name(file_name) click to toggle source
# File lib/rspec_tracer/source_file.rb, line 19
def from_name(file_name)
  from_path(file_path(file_name))
end
from_path(file_path) click to toggle source
# File lib/rspec_tracer/source_file.rb, line 9
def 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.read(file_path))
  }
end