better_errors 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of better_errors might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 27b27931ec5b8e074bac10e095d6c842dbeab9fc
4
- data.tar.gz: b7631911ff716069a371bf30b060241c08d4916d
2
+ SHA256:
3
+ metadata.gz: 832f46e8977908b469e6b527edbaf770541b66dfafcc3f8c1b292c0c6c25838c
4
+ data.tar.gz: 4584adc6e2870f40a5bd3eb0d7f18b693380e6a1c04716217f00c9190766f3e7
5
5
  SHA512:
6
- metadata.gz: cb6451b31dd661e6c966411814522e2c06bc9e19070468b91cdb2f3b46f0160e2ccdd8d38aac0c4ce1e5d83b894aa01478a8b6ddecbb2ff3123cc3b901f29aaf
7
- data.tar.gz: ea83fb1c88433f2f3df9cd7794996896d05956893bde09772b9bc85d4c12e63640162d860660b7ede93c7fbe393ed89611e20c77a1d99e1bf18f41a5c6f00a9f
6
+ metadata.gz: 844ecf262fdeee48a8165e201a189fcd7812db7bf437bf8e5e11ba80f63edeaa841015fcbc21a11b291e9705c8751fa382eba94e86b90d350828c662fffdbf0b
7
+ data.tar.gz: 82ff2fbb24fcbd5dafefe1776125da521cf5813461bca58700060d9be41aa7c138fe95d98b3056289aab5976adc48b83b7dc204521500fc85fe6ee8eb141d09b
@@ -1,6 +1,9 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
+ before_install:
5
+ - gem update --system
6
+ - gem update bundler
4
7
  notifications:
5
8
  webhooks:
6
9
  # With COVERALLS_PARALLEL, coverage information sent to coveralls will not be processed until
@@ -8,22 +11,24 @@ notifications:
8
11
  # https://coveralls.zendesk.com/hc/en-us/articles/203484329-Parallel-Build-Webhook
9
12
  - secure: "YnHYbTq51ySistjvOxsuNhyg4GLuUffEJstTYeGYXiBF7HG5h43IVYo8KNuLzwkgsOYBcNo+YMdQX7qCqJffSbhsr1FZRSzBmjFFxcyD4hu+ukM2theZ4mePVAZiePscYvQPRNY4hIb4d3egStJEytkalDhB3sOebF57tIaCssg="
10
13
  rvm:
11
- - 2.0.0
12
- - 2.1.10
13
- - 2.2.7
14
- - 2.3.4
15
- - 2.4.1
14
+ - 2.2.10
15
+ - 2.3.7
16
+ - 2.4.4
17
+ - 2.5.1
16
18
  - ruby-head
17
19
  gemfile:
18
20
  - gemfiles/rails42.gemfile
19
21
  - gemfiles/rails50.gemfile
20
22
  - gemfiles/rails51.gemfile
23
+ - gemfiles/rails52.gemfile
21
24
  - gemfiles/rails42_haml.gemfile
22
25
  - gemfiles/rails50_haml.gemfile
23
26
  - gemfiles/rails51_haml.gemfile
27
+ - gemfiles/rails52_haml.gemfile
24
28
  - gemfiles/rails42_boc.gemfile
25
29
  - gemfiles/rails50_boc.gemfile
26
30
  - gemfiles/rails51_boc.gemfile
31
+ - gemfiles/rails52_boc.gemfile
27
32
  - gemfiles/rack.gemfile
28
33
  - gemfiles/rack_boc.gemfile
29
34
  - gemfiles/pry09.gemfile
@@ -36,33 +41,15 @@ matrix:
36
41
  - gemfile: gemfiles/pry010.gemfile
37
42
  - gemfile: gemfiles/pry011.gemfile
38
43
  exclude:
39
- - rvm: 2.0.0
40
- gemfile: gemfiles/rails50.gemfile
41
- - rvm: 2.0.0
42
- gemfile: gemfiles/rails50_boc.gemfile
43
- - rvm: 2.0.0
44
- gemfile: gemfiles/rails50_haml.gemfile
45
- - rvm: 2.0.0
46
- gemfile: gemfiles/rails51.gemfile
47
- - rvm: 2.0.0
48
- gemfile: gemfiles/rails51_boc.gemfile
49
- - rvm: 2.0.0
50
- gemfile: gemfiles/rails51_haml.gemfile
51
- - rvm: 2.1.10
52
- gemfile: gemfiles/rails50.gemfile
53
- - rvm: 2.1.10
54
- gemfile: gemfiles/rails50_boc.gemfile
55
- - rvm: 2.1.10
56
- gemfile: gemfiles/rails50_haml.gemfile
57
- - rvm: 2.1.10
58
- gemfile: gemfiles/rails51.gemfile
59
- - rvm: 2.1.10
60
- gemfile: gemfiles/rails51_boc.gemfile
61
- - rvm: 2.1.10
62
- gemfile: gemfiles/rails51_haml.gemfile
63
- - rvm: 2.4.1
44
+ - rvm: 2.4.4
64
45
  gemfile: gemfiles/rails42.gemfile
65
- - rvm: 2.4.1
46
+ - rvm: 2.4.4
66
47
  gemfile: gemfiles/rails42_boc.gemfile
67
- - rvm: 2.4.1
48
+ - rvm: 2.4.4
49
+ gemfile: gemfiles/rails42_haml.gemfile
50
+ - rvm: 2.5.1
51
+ gemfile: gemfiles/rails42.gemfile
52
+ - rvm: 2.5.1
53
+ gemfile: gemfiles/rails42_boc.gemfile
54
+ - rvm: 2.5.1
68
55
  gemfile: gemfiles/rails42_haml.gemfile
@@ -1,3 +1,3 @@
1
1
  # Changelog
2
2
 
3
- See https://github.com/charliesome/better_errors/releases
3
+ See https://github.com/BetterErrors/better_errors/releases
data/README.md CHANGED
@@ -1,17 +1,17 @@
1
- [![Build Status](https://travis-ci.org/charliesome/better_errors.svg)](https://travis-ci.org/charliesome/better_errors)
2
- [![Code Climate](https://img.shields.io/codeclimate/github/charliesome/better_errors.svg)](https://codeclimate.com/github/charliesome/better_errors)
3
- [![Coverage](https://coveralls.io/repos/github/charliesome/better_errors/badge.svg?branch=master)](https://coveralls.io/github/charliesome/better_errors?branch=master)
1
+ [![Build Status](https://travis-ci.org/BetterErrors/better_errors.svg)](https://travis-ci.org/BetterErrors/better_errors)
2
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/6bc3e7d6118d47e6959b16690b815909)](https://www.codacy.com/app/BetterErrors/better_errors?utm_source=github.com&utm_medium=referral&utm_content=BetterErrors/better_errors&utm_campaign=Badge_Grade)
3
+ [![Coverage](https://coveralls.io/repos/github/BetterErrors/better_errors/badge.svg?branch=master)](https://coveralls.io/github/BetterErrors/better_errors?branch=master)
4
4
  [![Gem Version](https://img.shields.io/gem/v/better_errors.svg)](https://rubygems.org/gems/better_errors)
5
5
 
6
6
  # Better Errors
7
7
 
8
8
  Better Errors replaces the standard Rails error page with a much better and more useful error page. It is also usable outside of Rails in any Rack app as Rack middleware.
9
9
 
10
- ![image](https://i.imgur.com/6zBGAAb.png)
10
+ ![screenshot of Better Errors in action](https://i.imgur.com/6zBGAAb.png)
11
11
 
12
12
  ## Features
13
13
 
14
- For screenshots of these features, [see the wiki](https://github.com/charliesome/better_errors/wiki).
14
+ For screenshots of these features, [see the wiki](https://github.com/BetterErrors/better_errors/wiki).
15
15
 
16
16
  * Full stack trace
17
17
  * Source code inspection for all stack frames (with highlighting)
@@ -43,7 +43,7 @@ _Note: If you discover that Better Errors isn't working - particularly after upg
43
43
  You will notice that the only machine that gets the Better Errors page is localhost, which means you get the default error page if you are developing on a remote host (or a virtually remote host, such as a Vagrant box).
44
44
  Obviously, the REPL is not something you want to expose to the public, and there may be sensitive information available in the backtrace.
45
45
 
46
- For more information on how to configure access, see [the wiki](https://github.com/charliesome/better_errors/wiki/Allowing-access-to-the-console).
46
+ For more information on how to configure access, see [the wiki](https://github.com/BetterErrors/better_errors/wiki/Allowing-access-to-the-console).
47
47
 
48
48
  ## Usage
49
49
 
@@ -53,7 +53,7 @@ If you're using Rails, there's nothing else you need to do.
53
53
 
54
54
  If you're not using Rails, you need to insert `BetterErrors::Middleware` into your middleware stack, and optionally set `BetterErrors.application_root` if you'd like Better Errors to abbreviate filenames within your application.
55
55
 
56
- For instructions for your specific middleware, [see the wiki](https://github.com/charliesome/better_errors/wiki/Non-Rails-frameworks).
56
+ For instructions for your specific middleware, [see the wiki](https://github.com/BetterErrors/better_errors/wiki/Non-Rails-frameworks).
57
57
 
58
58
  ### Plain text requests
59
59
 
@@ -78,7 +78,7 @@ to troubleshoot an issue in development.
78
78
 
79
79
  Better Errors includes a link to your editor for the file and line of code that is being shown.
80
80
  By default, it uses your environment to determine which editor should be opened.
81
- See [the wiki for instructions on configuring the editor](https://github.com/charliesome/better_errors/wiki/Link-to-your-editor).
81
+ See [the wiki for instructions on configuring the editor](https://github.com/BetterErrors/better_errors/wiki/Link-to-your-editor).
82
82
 
83
83
 
84
84
  ## Set maximum variable size for inspector.
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = ["charlie@charliesomerville.com"]
10
10
  s.description = %q{Provides a better error page for Rails and other Rack apps. Includes source code inspection, a live REPL and local/instance variable inspection for all stack frames.}
11
11
  s.summary = %q{Better error page for Rails and other Rack apps}
12
- s.homepage = "https://github.com/charliesome/better_errors"
12
+ s.homepage = "https://github.com/BetterErrors/better_errors"
13
13
  s.license = "MIT"
14
14
 
15
15
  s.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 5.2.0"
4
+
5
+ gem 'coveralls', require: false
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 5.2.0"
4
+ gem "binding_of_caller"
5
+
6
+ gem 'coveralls', require: false
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 5.2.0"
4
+ gem "haml"
5
+
6
+ gem 'coveralls', require: false
7
+
8
+ gemspec path: "../"
@@ -4,6 +4,7 @@ require "coderay"
4
4
  require "uri"
5
5
 
6
6
  require "better_errors/code_formatter"
7
+ require "better_errors/inspectable_value"
7
8
  require "better_errors/error_page"
8
9
  require "better_errors/middleware"
9
10
  require "better_errors/raised_exception"
@@ -19,6 +20,8 @@ module BetterErrors
19
20
  { symbols: [:textmate, :txmt, :tm], sniff: /mate/i, url: "txmt://open?url=file://%{file}&line=%{line}" },
20
21
  { symbols: [:idea], sniff: /idea/i, url: "idea://open?file=%{file}&line=%{line}" },
21
22
  { symbols: [:rubymine], sniff: /mine/i, url: "x-mine://open?file=%{file}&line=%{line}" },
23
+ { symbols: [:vscode, :code], sniff: /code/i, url: "vscode://file/%{file}:%{line}" },
24
+ { symbols: [:atom], sniff: /atom/i, url: "atom://core/open/file?filename=%{file}&line=%{line}" },
22
25
  ]
23
26
 
24
27
  class << self
@@ -76,6 +79,7 @@ module BetterErrors
76
79
  # * `:textmate`, `:txmt`, `:tm`
77
80
  # * `:sublime`, `:subl`, `:st`
78
81
  # * `:macvim`
82
+ # * `:atom`
79
83
  #
80
84
  # @param [Symbol] sym
81
85
  #
@@ -125,7 +129,7 @@ module BetterErrors
125
129
  # Enables experimental Pry support in the inline REPL
126
130
  #
127
131
  # If you encounter problems while using Pry, *please* file a bug report at
128
- # https://github.com/charliesome/better_errors/issues
132
+ # https://github.com/BetterErrors/better_errors/issues
129
133
  def self.use_pry!
130
134
  REPL::PROVIDERS.unshift const: :Pry, impl: "better_errors/repl/pry"
131
135
  end
@@ -70,7 +70,8 @@ module BetterErrors
70
70
  application_frames.first || backtrace_frames.first
71
71
  end
72
72
 
73
- private
73
+ private
74
+
74
75
  def editor_url(frame)
75
76
  BetterErrors.editor[frame.filename, frame.line]
76
77
  end
@@ -104,30 +105,15 @@ module BetterErrors
104
105
  end
105
106
 
106
107
  def inspect_value(obj)
107
- inspect_raw_value(obj)
108
- rescue NoMethodError
109
- "<span class='unsupported'>(object doesn't support inspect)</span>"
108
+ InspectableValue.new(obj).to_html
109
+ rescue BetterErrors::ValueLargerThanConfiguredMaximum
110
+ "<span class='unsupported'>(object too large. "\
111
+ "Modify #{CGI.escapeHTML(obj.class.name)}#inspect "\
112
+ "or adjust BetterErrors.maximum_variable_inspect_size)</span>"
110
113
  rescue Exception => e
111
114
  "<span class='unsupported'>(exception #{CGI.escapeHTML(e.class.to_s)} was raised in inspect)</span>"
112
115
  end
113
116
 
114
- def inspect_raw_value(obj)
115
- value = CGI.escapeHTML(obj.inspect)
116
-
117
- if value_small_enough_to_inspect?(value)
118
- value
119
- else
120
- "<span class='unsupported'>(object too large. "\
121
- "Modify #{CGI.escapeHTML(obj.class.to_s)}#inspect "\
122
- "or increase BetterErrors.maximum_variable_inspect_size)</span>"
123
- end
124
- end
125
-
126
- def value_small_enough_to_inspect?(value)
127
- return true if BetterErrors.maximum_variable_inspect_size.nil?
128
- value.length <= BetterErrors.maximum_variable_inspect_size
129
- end
130
-
131
117
  def eval_and_respond(index, code)
132
118
  result, prompt, prefilled_input = @repls[index].send_input(code)
133
119
 
@@ -0,0 +1,45 @@
1
+ require "cgi"
2
+ require "objspace" rescue nil
3
+
4
+ module BetterErrors
5
+ class ValueLargerThanConfiguredMaximum < StandardError; end
6
+
7
+ class InspectableValue
8
+ def initialize(value)
9
+ @original_value = value
10
+ end
11
+
12
+ def to_html
13
+ raise ValueLargerThanConfiguredMaximum unless value_small_enough_to_inspect?
14
+ value_as_html
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :original_value
20
+
21
+ def value_as_html
22
+ @value_as_html ||= CGI.escapeHTML(value)
23
+ end
24
+
25
+ def value
26
+ @value ||= begin
27
+ if original_value.respond_to? :inspect
28
+ original_value.inspect
29
+ else
30
+ original_value
31
+ end
32
+ end
33
+ end
34
+
35
+ def value_small_enough_to_inspect?
36
+ return true if BetterErrors.maximum_variable_inspect_size.nil?
37
+
38
+ if defined?(ObjectSpace) && defined?(ObjectSpace.memsize_of) && ObjectSpace.memsize_of(value)
39
+ ObjectSpace.memsize_of(value) <= BetterErrors.maximum_variable_inspect_size
40
+ else
41
+ value_as_html.length <= BetterErrors.maximum_variable_inspect_size
42
+ end
43
+ end
44
+ end
45
+ end
@@ -76,14 +76,16 @@ module BetterErrors
76
76
  # considered a bug in Ruby itself, but we need to work around it.
77
77
  next if name == :"\#$!"
78
78
 
79
- if defined?(frame_binding.local_variable_get)
80
- hash[name] = frame_binding.local_variable_get(name)
81
- else
82
- hash[name] = frame_binding.eval(name.to_s)
83
- end
79
+ hash[name] = local_variable(name)
84
80
  end
85
81
  end
86
82
 
83
+ def local_variable(name)
84
+ get_local_variable(name) || eval_local_variable(name)
85
+ rescue NameError => ex
86
+ "#{ex.class}: #{ex.message}"
87
+ end
88
+
87
89
  def instance_variables
88
90
  return {} unless frame_binding
89
91
  Hash[visible_instance_variables.map { |x|
@@ -114,5 +116,15 @@ module BetterErrors
114
116
  @method_name = "##{method_name}"
115
117
  end
116
118
  end
119
+
120
+ def get_local_variable(name)
121
+ if defined?(frame_binding.local_variable_get)
122
+ frame_binding.local_variable_get(name)
123
+ end
124
+ end
125
+
126
+ def eval_local_variable(name)
127
+ frame_binding.eval(name.to_s)
128
+ end
117
129
  end
118
130
  end
@@ -721,12 +721,22 @@
721
721
  if(document.styleSheets[i].href)
722
722
  document.styleSheets[i].disabled = true;
723
723
  }
724
- document.addEventListener("page:restore", function restoreCSS(e) {
725
- for(var i=0; i < document.styleSheets.length; i++) {
726
- document.styleSheets[i].disabled = false;
727
- }
728
- document.removeEventListener("page:restore", restoreCSS, false);
729
- });
724
+ if (window.Turbolinks.controller) {
725
+ // Turbolinks > 5 (see https://github.com/turbolinks/turbolinks/issues/6)
726
+ document.addEventListener("turbolinks:load", function restoreCSS(e) {
727
+ for(var i=0; i < document.styleSheets.length; i++) {
728
+ document.styleSheets[i].disabled = false;
729
+ }
730
+ document.removeEventListener("turbolinks:load", restoreCSS, false);
731
+ });
732
+ } else {
733
+ document.addEventListener("page:restore", function restoreCSS(e) {
734
+ for(var i=0; i < document.styleSheets.length; i++) {
735
+ document.styleSheets[i].disabled = false;
736
+ }
737
+ document.removeEventListener("page:restore", restoreCSS, false);
738
+ });
739
+ }
730
740
  }
731
741
  </script>
732
742
 
@@ -943,7 +953,7 @@
943
953
  if(response.explanation) {
944
954
  el.innerHTML += "<p class='explanation'>" + escapeHTML(response.explanation) + "</p>";
945
955
  }
946
- el.innerHTML += "<p><a target='_new' href='https://github.com/charliesome/better_errors'>More about Better Errors</a></p>";
956
+ el.innerHTML += "<p><a target='_new' href='https://github.com/BetterErrors/better_errors'>More about Better Errors</a></p>";
947
957
  } else {
948
958
  el.innerHTML = response.html;
949
959
 
@@ -1,3 +1,3 @@
1
1
  module BetterErrors
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Somerville
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-13 00:00:00.000000000 Z
11
+ date: 2018-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -154,12 +154,16 @@ files:
154
154
  - gemfiles/rails51.gemfile
155
155
  - gemfiles/rails51_boc.gemfile
156
156
  - gemfiles/rails51_haml.gemfile
157
+ - gemfiles/rails52.gemfile
158
+ - gemfiles/rails52_boc.gemfile
159
+ - gemfiles/rails52_haml.gemfile
157
160
  - lib/better_errors.rb
158
161
  - lib/better_errors/code_formatter.rb
159
162
  - lib/better_errors/code_formatter/html.rb
160
163
  - lib/better_errors/code_formatter/text.rb
161
164
  - lib/better_errors/error_page.rb
162
165
  - lib/better_errors/exception_extension.rb
166
+ - lib/better_errors/inspectable_value.rb
163
167
  - lib/better_errors/middleware.rb
164
168
  - lib/better_errors/rails.rb
165
169
  - lib/better_errors/raised_exception.rb
@@ -171,7 +175,7 @@ files:
171
175
  - lib/better_errors/templates/text.erb
172
176
  - lib/better_errors/templates/variable_info.erb
173
177
  - lib/better_errors/version.rb
174
- homepage: https://github.com/charliesome/better_errors
178
+ homepage: https://github.com/BetterErrors/better_errors
175
179
  licenses:
176
180
  - MIT
177
181
  metadata: {}
@@ -191,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
195
  version: '0'
192
196
  requirements: []
193
197
  rubyforge_project:
194
- rubygems_version: 2.6.13
198
+ rubygems_version: 2.7.6
195
199
  signing_key:
196
200
  specification_version: 4
197
201
  summary: Better error page for Rails and other Rack apps