Class: Proc

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

Overview

Proc extension to get more location info out of a proc

Constant Summary collapse

PROC_PATTERN =

:nodoc:

/[\d\w]+@(.*):(.*)>/

Instance Method Summary collapse

Instance Method Details

#backtrace_line(name) ⇒ Object



9
10
11
# File 'lib/cucumber/core_ext/proc.rb', line 9

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

#file_colon_lineObject



14
15
16
17
18
19
20
# File 'lib/cucumber/core_ext/proc.rb', line 14

def file_colon_line
  path, line = *to_s.match(PROC_PATTERN)[1..2]
  path = File.expand_path(path)
  pwd = Dir.pwd
  path = path[pwd.length+1..-1]
  "#{path}:#{line}"
end

#to_comment_lineObject



5
6
7
# File 'lib/cucumber/core_ext/proc.rb', line 5

def to_comment_line
  "# #{file_colon_line}"
end