Class: RSpec::Core::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_clickable_output.rb

Class Method Summary collapse

Class Method Details

.relative_path(line) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rspec_clickable_output.rb', line 8

def self.relative_path(line)
  prefix = "subl://open?url=file://"
  cwd = Dir.pwd
  case line
    when %r{(^[a-z_]+\([A-Za-z]+\)) \[\.?(/?.*):(\d+)\]:}
      line = "#{$1}\n#{prefix}#{File.join(cwd, $2)}&line=#{$3}"
    when %r{^\s*(\[?)(/.+):(\d+):(.*)$}               # regular stacktrace
      line = "#{$1}#{prefix}#{$2}&line=#{$3} #{$4}"
    when %r{^\s*(\[?)\.?(/?.+):(\d+):(in .*)$}        # stacktrace with relative path
      line = "#{$1}#{prefix}#{File.join(cwd, $2)}&line=#{$3} #{$4}"
  end
  line.gsub(%r|/[^/]+/\.\./|, '/')
end