Class: BacktraceLine

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
app/models/backtrace_line.rb

Constant Summary collapse

IN_APP_PATH =
%r{^\[PROJECT_ROOT\](?!(\/vendor))/?}
GEMS_PATH =
%r{\[GEM_ROOT\]\/gems\/([^\/]+)}

Instance Method Summary collapse

Instance Method Details

#decorated_pathObject


37
38
39
40
# File 'app/models/backtrace_line.rb', line 37

def decorated_path
  path.sub(BacktraceLine::IN_APP_PATH, '').
    sub(BacktraceLine::GEMS_PATH, "<strong>\\1</strong>")
end

#file_nameObject


33
34
35
# File 'app/models/backtrace_line.rb', line 33

def file_name
  File.basename file
end

#file_relativeObject


29
30
31
# File 'app/models/backtrace_line.rb', line 29

def file_relative
  file.to_s.sub(IN_APP_PATH, '')
end

#in_app?Boolean

Returns:

  • (Boolean)

21
22
23
# File 'app/models/backtrace_line.rb', line 21

def in_app?
  !!(file =~ IN_APP_PATH)
end

#pathObject


25
26
27
# File 'app/models/backtrace_line.rb', line 25

def path
  File.dirname(file).gsub(/^\.$/, '') + "/"
end

#to_sObject


17
18
19
# File 'app/models/backtrace_line.rb', line 17

def to_s
  "#{file_relative}:#{number}" << (column.present? ? ":#{column}" : "")
end