Method: RSpec::Core::Metadata.relative_path

Defined in:
lib/rspec/core/metadata.rb

.relative_path(line) ⇒ String

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.

Returns relative path to line.

Parameters:

  • line (String)

    current code line

Returns:

  • (String)

    relative path to line

[View source]

44
45
46
47
48
49
50
51
52
53
# File 'lib/rspec/core/metadata.rb', line 44

def self.relative_path(line)
  line = line.sub(relative_path_regex, "\\1.\\2".freeze)
  line = line.sub(/\A([^:]+:\d+)$/, '\\1'.freeze)
  return nil if line == '-e:1'.freeze
  line
rescue SecurityError
  # :nocov: - SecurityError is no longer produced starting in ruby 2.7
  nil
  # :nocov:
end