render_me_pretty 0.8.0 → 0.8.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c5f4662509ff4efce8bde738342f9f97fc5fd8083cb9639006c515e6eb47bdd
4
- data.tar.gz: 38b4fdad0e9b9b0c311c10f58e530bf5ef145582fa5982afc7e58f86ab196181
3
+ metadata.gz: 568385d41ee6116a69769e93aef3da2540dd504313956a521938d5e8c85114dc
4
+ data.tar.gz: 6728276075074f49d08860f254d09a71e5a4adc24346c218cb5f9961a85c81da
5
5
  SHA512:
6
- metadata.gz: 0df66e4fd938fd5c8477bd24603f0566838897b798756eda7a4769388d0bc5104d6ed4347c2998b3d3b7918a8c3ef886d35d83e78e04bc78769a20afbd3bcee4
7
- data.tar.gz: cac5e1a0a9026838e8ae6d5123f19d7c2388794319d56ebd180d222fc5028c6409a602d8e84ecfb8b77f88b50d2bca27161215bc285b1a02c65a4fbb8e869af2
6
+ metadata.gz: 06c70b6311b152a7725c200da4760678c2ba5bc12a3dc4a127a3e91a32be762df5e9717678973c9aeddfe054afdec4345911400d2aa7b221302af6437c9e7ce7
7
+ data.tar.gz: 40c6951774cc3de8106a5e96a9a75823fb0d9aebcd990b1db32d156474d85a1fb844ed6fc1f8ce85f3385a1d4768a4d5642fcc3a11bb16abfa2cbf8433fc2b2d
@@ -0,0 +1,58 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.5.3
11
+
12
+ working_directory: ~/repo
13
+
14
+ steps:
15
+ - checkout
16
+
17
+ - run:
18
+ name: submodule sync
19
+ command: |
20
+ git submodule sync
21
+ git submodule update --init
22
+
23
+ # Download and cache dependencies
24
+ - restore_cache:
25
+ keys:
26
+ - v2-dependencies-{{ checksum "Gemfile.lock" }}
27
+ # fallback to using the latest cache if no exact match is found
28
+ - v2-dependencies-
29
+
30
+ - run:
31
+ name: install dependencies
32
+ command: |
33
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
34
+
35
+ - save_cache:
36
+ paths:
37
+ - ./vendor/bundle
38
+ key: v2-dependencies-{{ checksum "Gemfile.lock" }}
39
+
40
+ # run tests!
41
+ - run:
42
+ name: run tests
43
+ command: |
44
+ mkdir /tmp/test-results
45
+
46
+ cat >.rspec <<EOL
47
+ --format documentation
48
+ --require spec_helper
49
+ EOL
50
+
51
+ bundle exec rspec
52
+
53
+ # collect reports
54
+ - store_test_results:
55
+ path: /tmp/test-results
56
+ - store_artifacts:
57
+ path: /tmp/test-results
58
+ destination: test-results
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /Gemfile.lock
data/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
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.8.4] - 2021-12-28
7
+ - fix activesupport require
8
+
9
+ ## [0.8.3]
10
+ - add .circleci/config.yml
11
+ - show full backtrace when error not found within users layout or project path
12
+
13
+ ## [0.8.2]
14
+ - use rainbow gem for terminal color
15
+
16
+ ## [0.8.1]
17
+ - tilt default_encoding utf-8
18
+ - update readme with layout support
19
+
6
20
  ## [0.8.0]
7
21
  - pull request #1 from tongueroo/layout-support
8
22
 
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  [![CircleCI](https://circleci.com/gh/tongueroo/render_me_pretty.svg?style=svg)](https://circleci.com/gh/tongueroo/render_me_pretty)
4
4
 
5
+ [![BoltOps Badge](https://img.boltops.com/boltops/badges/boltops-badge.png)](https://www.boltops.com)
6
+
5
7
  Let's say you have an error in your ERB template:
6
8
 
7
9
  ```
@@ -47,6 +49,12 @@ There's also a convenience class method:
47
49
  RenderMePretty.result("/path/to/tempate.erb", a: 5)
48
50
  ```
49
51
 
52
+ ### Layout Support
53
+
54
+ ```ruby
55
+ RenderMePretty.result("/path/to/tempate.erb", layout: "/path/to/layout.erb")
56
+ ```
57
+
50
58
  ### Custom Context
51
59
 
52
60
  ```ruby
@@ -15,10 +15,10 @@ class RenderMePretty::Erb
15
15
  io = StringIO.new
16
16
 
17
17
  message = full_message ? ": #{@exception.message}" : ""
18
- io.puts "#{@exception.class}#{message}".colorize(:red)
18
+ io.puts "#{@exception.class}#{message}".color(:red)
19
19
 
20
20
  pretty_path = template_path_with_error.sub(/^\.\//, '')
21
- io.puts "Error evaluating ERB template around line #{error_line_number.to_s.colorize(:red)} of: #{pretty_path}:"
21
+ io.puts "Error evaluating ERB template around line #{error_line_number.to_s.color(:red)} of: #{pretty_path}:"
22
22
 
23
23
  context = 5 # lines of context
24
24
  top, bottom = [error_line_number-context-1, 0].max, error_line_number+context-1
@@ -28,7 +28,7 @@ class RenderMePretty::Erb
28
28
  lines[top..bottom].each_with_index do |line_content, index|
29
29
  current_line_number = top+index+1
30
30
  if current_line_number == error_line_number
31
- io.printf("%#{spacing}d %s\n".colorize(:red), current_line_number, line_content)
31
+ io.printf("%#{spacing}d %s\n".color(:red), current_line_number, line_content)
32
32
  else
33
33
  io.printf("%#{spacing}d %s\n", current_line_number, line_content)
34
34
  end
@@ -73,7 +73,7 @@ class RenderMePretty::Erb
73
73
  # render_me_pretty lines
74
74
  lines = lines[0..7] # keep 8 lines
75
75
  end
76
- lines[0] = lines[0].colorize(:red)
76
+ lines[0] = lines[0].color(:red)
77
77
 
78
78
  # header
79
79
  lines.unshift "\nOriginal backtrace#{full ? '' : ' (last 8 lines)'}:"
@@ -10,7 +10,13 @@ class RenderMePretty::Erb
10
10
  error_line = lines.select do |line|
11
11
  line.include?(template_path_with_error)
12
12
  end.first
13
- error_line.split(':')[1].to_i
13
+
14
+ if error_line.nil?
15
+ puts "WARN: Unable to find line number. Fallback and print out full backtrace."
16
+ puts @exception.backtrace
17
+ else
18
+ error_line.split(':')[1].to_i
19
+ end
14
20
  end
15
21
 
16
22
  def error_in_layout?
@@ -73,17 +73,19 @@ module RenderMePretty
73
73
  context.instance_variable_set('@' + key.to_s, value)
74
74
  end
75
75
 
76
+ # https://github.com/gotar/dry-view/commit/39e3f96625bf90da2e51fb1fd437f18cedb9ae8c
77
+ tilt_options = {trim: '-', default_encoding: "utf-8"}
76
78
  if @layout_path
77
- layout = Tilt::ERBTemplate.new(@layout_path, trim: '-')
79
+ layout = Tilt::ERBTemplate.new(@layout_path, tilt_options)
78
80
  else
79
81
  # trim mode: https://searchcode.com/codesearch/view/77362792/
80
- template = Tilt::ERBTemplate.new(@path, trim: '-')
82
+ template = Tilt::ERBTemplate.new(@path, tilt_options)
81
83
  end
82
84
 
83
85
  begin
84
86
  if @layout_path
85
87
  layout.render(context) do
86
- Tilt::ERBTemplate.new(@path, trim: '-').render(context)
88
+ Tilt::ERBTemplate.new(@path, tilt_options).render(context)
87
89
  end
88
90
  else
89
91
  template.render(context)
@@ -107,8 +109,8 @@ module RenderMePretty
107
109
  # Refer to specs and uncomment puts out to see the different types of errors.
108
110
  def handle_exception(e)
109
111
  # puts "*" * 30
110
- # puts e.class.to_s.colorize(:cyan)
111
- # puts e.message.colorize(:cyan)
112
+ # puts e.class.to_s.color(:cyan)
113
+ # puts e.message.color(:cyan)
112
114
  # puts e.backtrace
113
115
  # puts "*" * 30
114
116
  handler = e.is_a?(SyntaxError) ?
@@ -158,7 +160,7 @@ module RenderMePretty
158
160
  # render_me_pretty lines
159
161
  lines = lines[0..7] # keep 8 lines
160
162
  end
161
- lines[0] = lines[0].colorize(:red)
163
+ lines[0] = lines[0].color(:red)
162
164
 
163
165
  # header
164
166
  lines.unshift "\nOriginal backtrace#{full ? '' : ' (last 8 lines)'}:"
@@ -1,3 +1,3 @@
1
1
  module RenderMePretty
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.4"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "render_me_pretty/version"
2
+ require "active_support"
2
3
  require "active_support/core_ext/string"
3
- require "colorize"
4
+ require "rainbow/ext/string"
4
5
 
5
6
  module RenderMePretty
6
7
  autoload :Erb, 'render_me_pretty/erb'
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "activesupport"
22
- spec.add_dependency "colorize"
22
+ spec.add_dependency "rainbow"
23
23
  spec.add_dependency "tilt"
24
24
 
25
25
  spec.add_development_dependency "bundler"
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.8.0
4
+ version: 0.8.4
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-27 00:00:00.000000000 Z
11
+ date: 2021-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: colorize
28
+ name: rainbow
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -101,11 +101,11 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".circleci/config.yml"
104
105
  - ".gitignore"
105
106
  - ".rspec"
106
107
  - CHANGELOG.md
107
108
  - Gemfile
108
- - Gemfile.lock
109
109
  - README.md
110
110
  - Rakefile
111
111
  - bin/console
@@ -136,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubyforge_project:
140
- rubygems_version: 2.7.3
139
+ rubygems_version: 3.2.32
141
140
  signing_key:
142
141
  specification_version: 4
143
142
  summary: Render ERB template and provide more useful message pointing out the line
data/Gemfile.lock DELETED
@@ -1,52 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- render_me_pretty (0.6.0)
5
- activesupport
6
- colorize
7
- tilt
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- activesupport (5.1.5)
13
- concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (~> 0.7)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- colorize (0.8.1)
18
- concurrent-ruby (1.0.5)
19
- diff-lcs (1.3)
20
- i18n (0.9.5)
21
- concurrent-ruby (~> 1.0)
22
- minitest (5.11.3)
23
- rake (12.3.0)
24
- rspec (3.7.0)
25
- rspec-core (~> 3.7.0)
26
- rspec-expectations (~> 3.7.0)
27
- rspec-mocks (~> 3.7.0)
28
- rspec-core (3.7.1)
29
- rspec-support (~> 3.7.0)
30
- rspec-expectations (3.7.0)
31
- diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.7.0)
33
- rspec-mocks (3.7.0)
34
- diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.7.0)
36
- rspec-support (3.7.1)
37
- thread_safe (0.3.6)
38
- tilt (2.0.8)
39
- tzinfo (1.2.5)
40
- thread_safe (~> 0.1)
41
-
42
- PLATFORMS
43
- ruby
44
-
45
- DEPENDENCIES
46
- bundler
47
- rake
48
- render_me_pretty!
49
- rspec
50
-
51
- BUNDLED WITH
52
- 1.16.1