Class: Quarry::Break
Overview
Exception Break and Edit
Instance Attribute Summary collapse
-
#exception ⇒ Object
(also: #error)
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
- #edit ⇒ Object
-
#initialize(exception) ⇒ Break
constructor
A new instance of Break.
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
#exception ⇒ Object (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
#edit ⇒ Object
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 |