Commit 36aa7be34e159e376a384de40d6e5f663a618f3c
1 parent
524524c9
Exists in
master
and in
1 other branch
- use BacktraceLine methods instead of hask keys
- add BacktraceLine#file_relative
Showing
9 changed files
with
24 additions
and
19 deletions
Show diff stats
app/helpers/notices_helper.rb
... | ... | @@ -18,24 +18,24 @@ module NoticesHelper |
18 | 18 | end |
19 | 19 | |
20 | 20 | def filepath_parts(file) |
21 | - [file.split('/').last, file.gsub('[PROJECT_ROOT]', '')] | |
21 | + [file.split('/').last, file] | |
22 | 22 | end |
23 | 23 | |
24 | 24 | def link_to_github(app, line, text = nil) |
25 | - file_name, file_path = filepath_parts(line['file']) | |
26 | - href = "%s#L%s" % [app.github_url_to_file(file_path), line['number']] | |
25 | + file_name, file_path = filepath_parts(line.file) | |
26 | + href = "%s#L%s" % [app.github_url_to_file(file_path), line.number] | |
27 | 27 | link_to(text || file_name, href, :target => '_blank') |
28 | 28 | end |
29 | 29 | |
30 | 30 | def link_to_bitbucket(app, line, text = nil) |
31 | - file_name, file_path = filepath_parts(line['file']) | |
32 | - href = "%s#cl-%s" % [app.bitbucket_url_to_file(file_path), line['number']] | |
31 | + file_name, file_path = filepath_parts(line.file) | |
32 | + href = "%s#cl-%s" % [app.bitbucket_url_to_file(file_path), line.number] | |
33 | 33 | link_to(text || file_name, href, :target => '_blank') |
34 | 34 | end |
35 | 35 | |
36 | 36 | def link_to_issue_tracker_file(app, line, text = nil) |
37 | - file_name, file_path = filepath_parts(line['file']) | |
38 | - href = app.issue_tracker.url_to_file(file_path, line['number']) | |
37 | + file_name, file_path = filepath_parts(line.file_relative) | |
38 | + href = app.issue_tracker.url_to_file(file_path, line.number) | |
39 | 39 | link_to(text || file_name, href, :target => '_blank') |
40 | 40 | end |
41 | 41 | |
... | ... | @@ -55,7 +55,7 @@ module NoticesHelper |
55 | 55 | end |
56 | 56 | |
57 | 57 | def path_for_backtrace_line(line) |
58 | - path = File.dirname(line['file']) | |
58 | + path = File.dirname(line.file) | |
59 | 59 | return '' if path == '.' |
60 | 60 | # Remove [PROJECT_ROOT] |
61 | 61 | path.gsub!('[PROJECT_ROOT]/', '') |
... | ... | @@ -65,7 +65,7 @@ module NoticesHelper |
65 | 65 | end |
66 | 66 | |
67 | 67 | def file_for_backtrace_line(line) |
68 | - file = File.basename(line['file']) | |
68 | + file = File.basename(line.file) | |
69 | 69 | end |
70 | 70 | end |
71 | 71 | ... | ... |
app/models/backtrace_line.rb
app/views/issue_trackers/fogbugz_body.txt.erb
app/views/issue_trackers/github_issues_body.txt.erb
... | ... | @@ -27,7 +27,7 @@ |
27 | 27 | |
28 | 28 | ## Backtrace ## |
29 | 29 | ``` |
30 | -<% for line in notice.backtrace_lines %><%= line['number'] %>: <%= line['file'].to_s.sub(/^\[PROJECT_ROOT\]/, '') %> -> **<%= line['method'] %>** | |
30 | +<% for line in notice.backtrace_lines %><%= line.number %>: <%= line.file_relative %> -> **<%= line.method %>** | |
31 | 31 | <% end %> |
32 | 32 | ``` |
33 | 33 | ... | ... |
app/views/issue_trackers/lighthouseapp_body.txt.erb
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 | |
24 | 24 | ## Backtrace ## |
25 | 25 | <code> |
26 | - <% for line in notice.backtrace_lines %><%= line['number'] %>: <%= line['file'].to_s.sub(/^\[PROJECT_ROOT\]/, '') %> -> **<%= line['method'] %>** | |
26 | + <% for line in notice.backtrace_lines %><%= line.number %>: <%= line.file_relative %> -> **<%= line.method %>** | |
27 | 27 | <% end %> |
28 | 28 | </code> |
29 | 29 | ... | ... |
app/views/issue_trackers/pivotal_body.txt.erb
... | ... | @@ -12,6 +12,6 @@ See this exception on Errbit: <%= app_problem_url problem.app, problem %> |
12 | 12 | <%= pretty_hash notice.session %> |
13 | 13 | |
14 | 14 | Backtrace: |
15 | - <%= notice.backtrace_lines[0..4].map { |line| "#{line['number']}: #{line['file'].to_s.sub(/^\[PROJECT_ROOT\]/, '')} -> *#{line['method']}*" }.join "\n" %> | |
15 | + <%= notice.backtrace_lines[0..4].map { |line| "#{line.number}: #{line.file_relative} -> *#{line.method}*" }.join "\n" %> | |
16 | 16 | <% end %> |
17 | 17 | ... | ... |
app/views/issue_trackers/textile_body.txt.erb
... | ... | @@ -32,7 +32,7 @@ h2. Session |
32 | 32 | h2. Backtrace |
33 | 33 | |
34 | 34 | | Line | File | Method | |
35 | -<% for line in notice.backtrace_lines %>| <%= line['number'] %> | <%= line['file'].to_s.sub(/^\[PROJECT_ROOT\]/, '') %> | *<%= line['method'] %>* | | |
35 | +<% for line in notice.backtrace_lines %>| <%= line.number %> | <%= line.file_relative %> | *<%= line.method %>* | | |
36 | 36 | <% end %> |
37 | 37 | |
38 | 38 | h2. Environment | ... | ... |
app/views/notices/_atom_entry.html.haml
... | ... | @@ -25,10 +25,10 @@ |
25 | 25 | - for line in notice.backtrace_lines |
26 | 26 | %tr |
27 | 27 | %td |
28 | - = "#{line['number']}:" | |
28 | + = "#{line.number}:" | |
29 | 29 | |
30 | 30 | %td |
31 | - = raw "#{h line['file'].sub(/^\[PROJECT_ROOT\]/, '')} -> #{content_tag :strong, h(line['method'])}" | |
31 | + = raw "#{h line.file_relative} -> #{content_tag :strong, h(line.method)}" | |
32 | 32 | |
33 | 33 | %h3 Environment |
34 | 34 | %table | ... | ... |
app/views/notices/_backtrace_line.html.haml
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | = link_to_source_file(@app, line) do |
4 | 4 | %span.path>= path_for_backtrace_line(line) |
5 | 5 | %span.file>= file_for_backtrace_line(line) |
6 | - - if line['number'].present? | |
7 | - %span.number>= ":#{line['number']}" | |
6 | + - if line.number.present? | |
7 | + %span.number>= ":#{line.number}" | |
8 | 8 | → |
9 | - %span.method= line['method'] | |
9 | + %span.method= line.method | ... | ... |