Sha256: caf1889e011c4741fb5710e8acd6f56a3d246fe63376fa9016fb02eae5aa2e11

Contents?: true

Size: 750 Bytes

Versions: 47

Compression:

Stored size: 750 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 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 backtrace_line
      nil
    end

    def to_comment_line
      ""
    end
  end
end 

Version data entries

47 entries across 47 versions & 5 rubygems

Version Path
aslakhellesoy-cucumber-0.1.100.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.100.2 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.100.3 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.100.4 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.1.100.5 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.0.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.0.2 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.0.3 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.0.4 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.0 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.2.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.2.2 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.2 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.3.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.3.2 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.3.3 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.3.4 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.2.3 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.0.1 lib/cucumber/core_ext/proc.rb