Class: Proc

Inherits:
Object show all
Defined in:
lib/cucumber/core_ext/proc.rb

Overview

:nodoc:

Constant Summary collapse

PROC_PATTERN =
/[\d\w]+@(.+):(\d+).*>/
PWD =
Dir.pwd

Instance Method Summary collapse

Instance Method Details

#backtrace_line(name) ⇒ Object



11
12
13
# File 'lib/cucumber/core_ext/proc.rb', line 11

def backtrace_line(name)
  "#{file_colon_line}:in `#{name}'"
end

#file_colon_lineObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cucumber/core_ext/proc.rb', line 16

def file_colon_line
  path, line = *to_s.match(PROC_PATTERN)[1..2]
  path = File.expand_path(path)
  pwd = File.expand_path(PWD)
  pwd.force_encoding(path.encoding) unless Cucumber::RUBY_1_8_7
  if path.index(pwd)
    path = path[pwd.length+1..-1]
  elsif path =~ /.*\/gems\/(.*\.rb)$/
    path = $1
  end
  "#{path}:#{line}"
end

#to_comment_lineObject



7
8
9
# File 'lib/cucumber/core_ext/proc.rb', line 7

def to_comment_line
  "# #{file_colon_line}"
end