Module: Tracee::Stack::BaseDecorator
- Defined in:
- lib/tracee/stack/base_decorator.rb
Class Method Summary collapse
-
.call(source, paint_code_line: nil) ⇒ Object
Make sure that Dir.pwd is the application root directory.
Class Method Details
.call(source, paint_code_line: nil) ⇒ Object
Make sure that Dir.pwd is the application root directory
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tracee/stack/base_decorator.rb', line 6 def self.call(source, paint_code_line: nil) return source if source.empty? or source[0]["\n"] # already decorated result, current_line_steps = [], [] # path, file, line, is_block, block_level, method step_details = source[0].match(CALLER_RE) source.each_with_index do |step, i| next_step_details = source[i+1] && source[i+1].match(CALLER_RE) if step_details and step_details[:path] !~ Tracee::IGNORE_RE #if level = step_details[:block_level] # step = step.sub(/block (\(\d+ levels\) )?in/, "{#{level}}") #end if method = step_details[:method] and next_step_details and [step_details[:path], step_details[:line]] == [next_step_details[:path], next_step_details[:line]] current_line_steps.unshift "`#{method}#{" {#{step_details[:block_level]}}" if step_details[:block_level]}'" elsif step_details[:line].to_i > 0 and code_line = Tracee::Stack.readline(step_details[:path], step_details[:line].to_i) current_line_steps.unshift step code_line = code_line.send paint_code_line if paint_code_line result << "#{current_line_steps * ' -> '}\n >> #{code_line}" current_line_steps = [] else result << step end end step_details = next_step_details end if defined? IRB and IRB.conf[:BACK_TRACE_LIMIT] and result.size > IRB.conf[:BACK_TRACE_LIMIT] and result.last[-1] != "\n" result.last << "\n" end result end |