Class: Quarry::Break

Inherits:
Object show all
Defined in:
lib/quarry/break.rb

Overview

Exception Break and Edit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ Break

Returns a new instance of Break.



12
13
14
# File 'lib/quarry/break.rb', line 12

def initialize(exception)
  @exception = exception
end

Instance Attribute Details

#exceptionObject (readonly) Also known as: error

Returns the value of attribute exception.



7
8
9
# File 'lib/quarry/break.rb', line 7

def exception
  @exception
end

Instance Method Details

#editObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/quarry/break.rb', line 17

def edit
  file, line = *exception.backtrace[0].split(':')
  line = line.to_i

  puts exception

  e = "# DEBUG " + exception.to_s
  e.gsub!("`","'")

  e = Regexp.escape(e)

  case ed = ENV['EDITOR']
  when 'vi', 'vim', 'gvim'
    cmd = []
    cmd << "#{ed} -e -s #{file} <<-EOS"
    cmd << ":#{line}"
    cmd << "a"
    cmd << "#{e}"
    cmd << "."
    cmd << ":.,+#{e.size}"
    cmd << "EOS"
    cmd = cmd.join("\n")
  when nil
    puts "EDITOR environment variable not set"
  else
    puts "EDITOR environment variable not supported"
  end

  system cmd
end