Sha256: daf5dc9fac9d6677025d2c4fcdd2182b230791c586c880e5045db3e6825f3336

Contents?: true

Size: 718 Bytes

Versions: 19

Compression:

Stored size: 718 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 = 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

19 entries across 19 versions & 1 rubygems

Version Path
cucumber-0.8.4 lib/cucumber/core_ext/proc.rb
cucumber-0.8.3 lib/cucumber/core_ext/proc.rb
cucumber-0.8.2 lib/cucumber/core_ext/proc.rb
cucumber-0.8.1 lib/cucumber/core_ext/proc.rb
cucumber-0.8.0 lib/cucumber/core_ext/proc.rb
cucumber-0.7.3 lib/cucumber/core_ext/proc.rb
cucumber-0.7.2 lib/cucumber/core_ext/proc.rb
cucumber-0.7.1 lib/cucumber/core_ext/proc.rb
cucumber-0.7.0 lib/cucumber/core_ext/proc.rb
cucumber-0.7.0.beta.8 lib/cucumber/core_ext/proc.rb
cucumber-0.7.0.beta.7 lib/cucumber/core_ext/proc.rb
cucumber-0.7.0.beta.6 lib/cucumber/core_ext/proc.rb
cucumber-0.7.0.beta.5 lib/cucumber/core_ext/proc.rb
cucumber-0.7.0.beta.4 lib/cucumber/core_ext/proc.rb
cucumber-0.7.0.beta.3 lib/cucumber/core_ext/proc.rb
cucumber-0.7.0.beta.2 lib/cucumber/core_ext/proc.rb
cucumber-0.7.0.beta.1 lib/cucumber/core_ext/proc.rb
cucumber-0.6.4 lib/cucumber/core_ext/proc.rb
cucumber-0.6.3 lib/cucumber/core_ext/proc.rb