Sha256: da7f40a65e4190d213e2df91b5c9c6f08a5c13867244c6696f5c43aafb0b5172

Contents?: true

Size: 715 Bytes

Versions: 29

Compression:

Stored size: 715 Bytes

Contents

# Proc extension to get more location info out of a proc
class Proc #:nodoc:
  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

29 entries across 29 versions & 5 rubygems

Version Path
aslakhellesoy-cucumber-0.3.100 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.101.2 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.101 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.102.1 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.102.2 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.102 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.103 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.104 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.97 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.98 lib/cucumber/core_ext/proc.rb
aslakhellesoy-cucumber-0.3.99 lib/cucumber/core_ext/proc.rb
dwaite-cucumber-0.3.101 lib/cucumber/core_ext/proc.rb
engineyard-cucumber-0.3.101 lib/cucumber/core_ext/proc.rb
kosmas58-cucumber-0.3.100 lib/cucumber/core_ext/proc.rb
kosmas58-cucumber-0.3.102 lib/cucumber/core_ext/proc.rb
kosmas58-cucumber-0.3.103 lib/cucumber/core_ext/proc.rb
kosmas58-cucumber-0.3.97 lib/cucumber/core_ext/proc.rb
kosmas58-cucumber-0.3.98 lib/cucumber/core_ext/proc.rb
kosmas58-cucumber-0.3.99 lib/cucumber/core_ext/proc.rb
cucumber-0.4.0 lib/cucumber/core_ext/proc.rb