render_me_pretty 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fca5bd4ed5c7502ec8b72669e5fced039e90b8e4f1cdb6f47fdaab6f289e247
4
- data.tar.gz: 26ecbd9090b108e5baf921cec068a06a2ac4057232d984792304e49d0d038304
3
+ metadata.gz: a5e982d58b2b59ca91a4713eeb1720ba73fcc0fe6c23ad0052ec54fa8c80adde
4
+ data.tar.gz: 2b791ee128231df293c58fa55c064d1cae60df140baf6460c38f68446325f04a
5
5
  SHA512:
6
- metadata.gz: bb38911b2da29bc35e67d648d7de31b17b74cdfd0b7a3b97bfbb6419a641d884c77d063d84ba9f4abd195f2fc6ebf7915e598b3b9b2b6ff18297e2cd6a6f601b
7
- data.tar.gz: 74a63b170fcab819827e3f808f0b14c25925b162c123b9b7f519c39b2b77e07a858fe38c351fa3e08cfbc4ce6a52c5c70dc3a687f069993bc6348e8179ca253c
6
+ metadata.gz: '085a42766665d911e15928aa5026d3bc95aa595030a92d20340222b0661750dd5b24ae95884310828b67952cd3b0b697c545d2ef470d5b6ee9a6d811621fb1ba'
7
+ data.tar.gz: '0943c0fb992da2d40e00b2d4242c70694bca5195672eea6e4164a19fd32cf505f6918cf9b7e84ed9e0b594c6a47defc8ce9b6e06753c767181ba7c6869b6267d'
data/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.5.0]
7
+ - fix find_template_error_line
8
+ - remove some of the filtering for backtrace lines
9
+
6
10
  ## [0.4.0]
7
11
  - fix erb and context definitions, fix bug with empty variables={}
8
12
  - improve original backtrace info, colorize exact line
@@ -78,13 +78,23 @@ module RenderMePretty
78
78
 
79
79
  # handles Tilt error
80
80
  def handle_exception(e)
81
- # first line of the baacktrace for Tilt has the line number
82
- # spec/fixtures/invalid.erb:2:in `block in singleton class'
83
- error_info = e.backtrace[0]
84
- error_line_number = error_info.split(':')[1].to_i
81
+ error_line = find_template_error_line(e.backtrace)
82
+ error_line_number = error_line.split(':')[1].to_i
85
83
  pretty_error(e, error_line_number)
86
84
  end
87
85
 
86
+ # For Tilt, first line of the baacktrace that contains the path of the file
87
+ # we're rendeirng has the line number. Example:
88
+ #
89
+ # spec/fixtures/invalid.erb:2:in `block in singleton class'
90
+ # error_info = e.backtrace[0]
91
+ def find_template_error_line(lines)
92
+ lines.select do |line|
93
+ line.include?(@path)
94
+ end.first
95
+ end
96
+
97
+
88
98
  def pretty_error(e, line)
89
99
  pretty_path = @path.sub(/^\.\//, '')
90
100
  io = StringIO.new
@@ -134,20 +144,24 @@ module RenderMePretty
134
144
  lines = e.backtrace
135
145
  else
136
146
  lines = e.backtrace
147
+ # This filtering business makes is hiding useful info.
148
+ # Think it was needed for ERB but Tilt provides a better stack trace.
149
+ # Commenting out for now.
150
+
137
151
  # filter out internal lines
138
- removal_index = lines.find_index { |l| l =~ %r[lib/render_me_pretty] }
139
- lines = lines[removal_index..-1] # remove leading lines above the lib/
152
+ # removal_index = lines.find_index { |l| l =~ %r[lib/render_me_pretty] }
153
+ # lines = lines[removal_index..-1] # remove leading lines above the lib/
140
154
  # render_me_pretty lines by keeping lines past the removal index
141
- lines.reject! { |l| l =~ %r[lib/render_me_pretty] } # now filter out
155
+ # lines.reject! { |l| l =~ %r[lib/render_me_pretty] } # now filter out
142
156
  # render_me_pretty lines
143
157
  lines = lines[0..7] # keep 8 lines
144
- lines[0] = lines[0].colorize(:red)
145
158
  end
159
+ lines[0] = lines[0].colorize(:red)
146
160
 
147
161
  # header
148
- lines.unshift "\nOriginal filtered backtrace#{full ? '' : ' (last 8 lines)'}:"
162
+ lines.unshift "\nOriginal backtrace#{full ? '' : ' (last 8 lines)'}:"
149
163
  # footer
150
- lines << "\nRe-run with FULL_STACK_TRACE=1 to see all lines"
164
+ lines << "\nRe-run with FULL_BACKTRACE=1 to see all lines"
151
165
  lines.join("\n")
152
166
  end
153
167
  end
@@ -1,3 +1,3 @@
1
1
  module RenderMePretty
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_me_pretty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-15 00:00:00.000000000 Z
11
+ date: 2018-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport