Sha256: 425d26c9527f85358dad3bb187f2ff0cb0621b11d7cf4387975dfa59a1ae323c

Contents?: true

Size: 706 Bytes

Versions: 63

Compression:

Stored size: 706 Bytes

Contents

# Proc extension to get more location info out of a proc
class Proc
  PROC_PATTERN = /[\d\w]+@(.*):(.*)>/
  
  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 = Dir.pwd
      path = path[pwd.length+1..-1]
      "#{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

63 entries across 63 versions & 7 rubygems

Version Path
aslakhellesoy-cucumber-0.3.10 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.11.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.11.200907091518 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.11.3 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.11.5 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.11.6 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.11 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.4 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.5 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.6.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.7.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.7.2 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.7.3 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.7.4 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.7.5 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.7 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.8 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.9.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.9.2 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.9.3 lib/cucumber/core_ext/proc.rb