Sha256: 0bb035390113a0f36efbfcef5dc56e81e2644a6f920fa57df99d47c7bf73c2c3

Contents?: true

Size: 756 Bytes

Versions: 25

Compression:

Stored size: 756 Bytes

Contents

# Proc extension to get more location info out of a proc
class Proc
  PROC_PATTERN = /[\d\w]+@(.*):(.*)>/
  
  if Proc.new{}.to_s =~ PROC_PATTERN
    def to_backtrace_line(name)
      "#{file_colon_line}:in `#{name}'"
    end

    def to_comment_line
      "# #{file_colon_line}"
    end

    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 to_backtrace_line
      nil
    end

    def to_comment_line
      ""
    end
  end
end 

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
aslakhellesoy-cucumber-0.1.16.5 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.10 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.11 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.12 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.13 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.14 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.15 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.17 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.18 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.19 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.2 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.20 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.21 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.22 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.23 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.3 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.5 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.6 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.99.7 lib/cucumber/core_ext/proc.rb