Class: Rnotifier::ExceptionCode
- Inherits:
-
Object
- Object
- Rnotifier::ExceptionCode
- Defined in:
- lib/rnotifier/exception_code.rb
Class Method Summary collapse
Class Method Details
.find(filename, line_no, wrap_size = 1) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rnotifier/exception_code.rb', line 14 def find(filename, line_no, wrap_size = 1) s_range = [line_no - wrap_size, 1].max - 1 e_range = line_no + wrap_size - 1 code = [s_range] begin File.open(filename) do |f| f.each_with_index do |line, i| code << line if i >= s_range && i <= e_range break if i > e_range end end rescue Exception => e end code end |
.get(backtrace) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/rnotifier/exception_code.rb', line 5 def get(backtrace) return unless backtrace bline = backtrace.find do |l| l.index(Config.app_env[:app_root]) == 0 && !Gem.path.any?{|path| l.index(path) == 0} end filename, line, method = (bline|| backtrace[0]).split(':') self.find(filename, line.to_i, 3) end |