render_me_pretty 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/render_me_pretty/erb.rb +24 -10
- data/lib/render_me_pretty/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5e982d58b2b59ca91a4713eeb1720ba73fcc0fe6c23ad0052ec54fa8c80adde
|
4
|
+
data.tar.gz: 2b791ee128231df293c58fa55c064d1cae60df140baf6460c38f68446325f04a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/render_me_pretty/erb.rb
CHANGED
@@ -78,13 +78,23 @@ module RenderMePretty
|
|
78
78
|
|
79
79
|
# handles Tilt error
|
80
80
|
def handle_exception(e)
|
81
|
-
|
82
|
-
|
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
|
162
|
+
lines.unshift "\nOriginal backtrace#{full ? '' : ' (last 8 lines)'}:"
|
149
163
|
# footer
|
150
|
-
lines << "\nRe-run with
|
164
|
+
lines << "\nRe-run with FULL_BACKTRACE=1 to see all lines"
|
151
165
|
lines.join("\n")
|
152
166
|
end
|
153
167
|
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
|
+
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-
|
11
|
+
date: 2018-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|