Sha256: 31e7d6ef0c349197718b7092a7c8025aa32139f59da52c75423ab41281cf4909
Contents?: true
Size: 845 Bytes
Versions: 52
Compression:
Stored size: 845 Bytes
Contents
# Proc extension to get more location info out of a proc class Proc #:nodoc: PROC_PATTERN = /[\d\w]+@(.+):(\d+).*>/ PWD = Dir.pwd def to_comment_line "# #{file_colon_line}" end def backtrace_line(name) "#{file_colon_line}:in `#{name}'" end if Proc.new{}.to_s =~ PROC_PATTERN def file_colon_line path, line = *to_s.match(PROC_PATTERN)[1..2] path = File.expand_path(path) pwd = File.expand_path(PWD) if path.index(pwd) path = path[pwd.length+1..-1] elsif path =~ /.*\/gems\/(.*\.rb)$/ path = $1 end "#{path}:#{line}" end else # This Ruby implementation doesn't implement Proc#to_s correctly STDERR.puts "*** THIS RUBY IMPLEMENTATION DOESN'T REPORT FILE AND LINE FOR PROCS ***" def file_colon_line "UNKNOWN:-1" end end end
Version data entries
52 entries across 50 versions & 11 rubygems