Sha256: a266661e2dc185641afde087b1cdea395313460ba61df7a7b88c9018701d48c8

Contents?: true

Size: 906 Bytes

Versions: 13

Compression:

Stored size: 906 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)
      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

13 entries across 13 versions & 1 rubygems

Version Path
cucumber-2.0.2 lib/cucumber/core_ext/proc.rb
cucumber-2.0.1 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0.rc.5 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0.rc.4 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0.rc.3 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0.rc.2 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0.rc.1 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0.beta.5 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0.beta.4 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0.beta.3 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0.beta.2 lib/cucumber/core_ext/proc.rb
cucumber-2.0.0.beta.1 lib/cucumber/core_ext/proc.rb