Sha256: ccb968a1197b7b913d4bdfc72c2da74e630e8bff19c7d5914820fbdb860b3d08

Contents?: true

Size: 764 Bytes

Versions: 20

Compression:

Stored size: 764 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]
      line = line.to_i - 1 if Cucumber::RUBY_1_9
      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

20 entries across 20 versions & 5 rubygems

Version Path
davidtrogers-cucumber-0.6.2 lib/cucumber/core_ext/proc.rb
cucumber-0.6.2 lib/cucumber/core_ext/proc.rb
cucumber-0.6.1 lib/cucumber/core_ext/proc.rb
cucumber-0.6.0 lib/cucumber/core_ext/proc.rb
cucumber-0.5.3 lib/cucumber/core_ext/proc.rb
cucumber-0.5.2 lib/cucumber/core_ext/proc.rb
cucumber-0.5.1 lib/cucumber/core_ext/proc.rb
cucumber-0.5.0 lib/cucumber/core_ext/proc.rb
cucumber-0.4.5.rc2 lib/cucumber/core_ext/proc.rb
kbaum-cucumber-0.4.5.pre lib/cucumber/core_ext/proc.rb
cucumber-0.4.5.rc1 lib/cucumber/core_ext/proc.rb
middleman-0.10.17 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/core_ext/proc.rb
middleman-0.10.16 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/core_ext/proc.rb
middleman-0.10.15 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/core_ext/proc.rb
rackjour-0.1.8 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/core_ext/proc.rb
middleman-0.10.14 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/core_ext/proc.rb
cucumber-0.4.4 lib/cucumber/core_ext/proc.rb
cucumber-0.4.3 lib/cucumber/core_ext/proc.rb
cucumber-0.4.2 lib/cucumber/core_ext/proc.rb
cucumber-0.4.1 lib/cucumber/core_ext/proc.rb