Sha256: eef09981820a47852b0cf4a756c772f5e242a30d09f10ee45111dc7f9e5cbe72

Contents?: true

Size: 833 Bytes

Versions: 6

Compression:

Stored size: 833 Bytes

Contents

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

6 entries across 6 versions & 1 rubygems

Version Path
cucumber-0.8.7 lib/cucumber/core_ext/proc.rb
cucumber-0.9.3 lib/cucumber/core_ext/proc.rb
cucumber-0.9.2 lib/cucumber/core_ext/proc.rb
cucumber-0.9.1 lib/cucumber/core_ext/proc.rb
cucumber-0.9.0 lib/cucumber/core_ext/proc.rb
cucumber-0.8.5 lib/cucumber/core_ext/proc.rb