Sha256: e3d041107dadb31992fd75a3c7b36440ef8185c052836eb5cffab323ee2a9612

Contents?: true

Size: 934 Bytes

Versions: 24

Compression:

Stored size: 934 Bytes

Contents

# Proc extension to get more location info out of a proc
require 'cucumber/platform'
class Proc #:nodoc:
  PROC_PATTERN = /[\d\w]+@(.+):(\d+).*>/
  PWD = Dir.pwd

  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(PWD)
      pwd.force_encoding(path.encoding) unless Cucumber::RUBY_1_8_7
      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

24 entries across 22 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/cucumber-1.3.18/lib/cucumber/core_ext/proc.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/cucumber-1.3.16/lib/cucumber/core_ext/proc.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/cucumber-1.3.18/lib/cucumber/core_ext/proc.rb
cucumber-1.3.20 lib/cucumber/core_ext/proc.rb
cucumber-1.3.19 lib/cucumber/core_ext/proc.rb
cucumber-1.3.18 lib/cucumber/core_ext/proc.rb
cucumber-1.3.17 lib/cucumber/core_ext/proc.rb
cucumber-1.3.16 lib/cucumber/core_ext/proc.rb
cucumber-1.3.15 lib/cucumber/core_ext/proc.rb
cucumber-1.3.14 lib/cucumber/core_ext/proc.rb
cucumber-1.3.13 lib/cucumber/core_ext/proc.rb
cucumber-1.3.12 lib/cucumber/core_ext/proc.rb
cucumber-1.3.11 lib/cucumber/core_ext/proc.rb
cucumber-1.3.10 lib/cucumber/core_ext/proc.rb
cucumber-1.3.9 lib/cucumber/core_ext/proc.rb
cucumber-1.3.8 lib/cucumber/core_ext/proc.rb
cucumber-1.3.7 lib/cucumber/core_ext/proc.rb
cucumber-1.3.6 lib/cucumber/core_ext/proc.rb
cucumber-1.3.5 lib/cucumber/core_ext/proc.rb
cucumber-1.3.4 lib/cucumber/core_ext/proc.rb