web-console 3.4.0 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 963c13addc1eda302c2fb5e217334b403e0f6a09
4
- data.tar.gz: e8768504bc586024d0061ba82b0b275c65d93442
3
+ metadata.gz: 5b2ea6288a1823356b457a11ad5746b84b4788aa
4
+ data.tar.gz: 4ce3d79517c3aee34c9841d8c9d9d697329a7b44
5
5
  SHA512:
6
- metadata.gz: 00d6e18111d7d37a870015012dd2e590e2e4e392490a9301e883e450a95f7b87b81c767dc3cf90829496d2efecd65ffe07599ac4f09dd50d1014ea35ccb6586a
7
- data.tar.gz: 7be81b47f363fb912e2df95c6f44a493235fed6f72aae1f0ea11006919e593668b11d4473434480d448676ef1cfa5962f7e4cd5ada857636cec518357207254f
6
+ metadata.gz: 51316ba9e0ef5be8be874d5a77a15a54907ea73fd0d4cab8c15ae3b02ea1f5b4cdd42fb71636892f68c74f8c89c3866bd8eb9c69c92fde0ffd9f2944826922e7
7
+ data.tar.gz: d61663a8957c915c8f90efb54893874e5a8c6003241928336f9a54041b241e30c898b109a7994fc852e699b3d150f44753f226792b37a6f1234353df19df697b
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 3.5.0
6
+
7
+ * [237](https://github.com/rails/web-console/pull/237) Bindex integration for JRuby 9k support ([@gsamokovarov])
8
+ * [236](https://github.com/rails/web-console/pull/236) Remove unused Active Support lazy load hook ([@betesh])
9
+ * [230](https://github.com/rails/web-console/pull/230) Handle invalid remote addresses ([@akirakoyasu])
10
+
5
11
  ## 3.4.0
6
12
 
7
13
  * [#205](https://github.com/rails/web-console/pull/205) Introduce autocompletion ([@sh19910711])
@@ -96,3 +102,5 @@ go to 3.1.0 instead.
96
102
  [@frenesim]: https://github.com/frenesim
97
103
  [@herminiotorres]: https://github.com/herminiotorres
98
104
  [@schneems]: https://github.com/schneems
105
+ [@betesh]: https://github.com/betesh
106
+ [@akirakoyasu]: https://github.com/akirakoyasu
@@ -10,10 +10,6 @@
10
10
  _Web Console_ is a debugging tool for your Ruby on Rails applications.
11
11
 
12
12
  - [Installation](#installation)
13
- - [Runtime](#runtime)
14
- - [CRuby](#cruby)
15
- - [JRuby](#jruby)
16
- - [Rubinius](#rubinius)
17
13
  - [Configuration](#configuration)
18
14
  - [Usage](#usage)
19
15
  - [FAQ](#faq)
@@ -33,16 +29,6 @@ end
33
29
  After you save the `Gemfile` changes, make sure to run `bundle install` and
34
30
  restart your server for the _Web Console_ to kick in.
35
31
 
36
- ## Runtime
37
-
38
- ### CRuby
39
-
40
- CRuby 2.2 and above is required.
41
-
42
- ### Rubinius
43
-
44
- Internal errors like `ZeroDevisionError` aren't caught.
45
-
46
32
  ## Usage
47
33
 
48
34
  The web console allows you to create an interactive Ruby session in your
@@ -162,7 +148,6 @@ All of _Web Console_ sessions are stored in memory. If you happen to run on a
162
148
  multi-process server (like Unicorn) you may get unavailable session errors
163
149
  while the server is still running. This is because a request may hit a
164
150
  different worker (process) that doesn't have the desired session in memory.
165
-
166
151
  To avoid that, if you use such servers in development, configure them so they
167
152
  server requests only out of one process.
168
153
 
@@ -190,12 +175,13 @@ Make sure your configuration lives in `config/environments/development.rb`.
190
175
  ## Credits
191
176
 
192
177
  * Shoutout to [Charlie Somerville] for [better_errors].
193
- * Kudos to [John Mair] for [debug_inspector].
178
+ * Kudos to [John Mair] for [binding_of_caller] and [debug_inspector].
194
179
  * Thanks to [Charles Oliver Nutter] for all the _JRuby_ feedback.
195
180
  * Hugs and kisses to all of our [contributors]!
196
181
 
197
182
  [better_errors]: https://github.com/charliesome/better_errors
198
183
  [debug_inspector]: https://github.com/banister/debug_inspector
184
+ [binding_of_caller]: https://github.com/banister/binding_of_caller
199
185
  [Charlie Somerville]: https://github.com/charliesome
200
186
  [John Mair]: https://github.com/banister
201
187
  [Charles Oliver Nutter]: https://github.com/headius
@@ -1,5 +1,4 @@
1
1
  require 'active_support/dependencies/autoload'
2
- require 'active_support/lazy_load_hooks'
3
2
  require 'active_support/logger'
4
3
 
5
4
  module WebConsole
@@ -24,8 +23,6 @@ module WebConsole
24
23
 
25
24
  mattr_accessor :logger
26
25
  @@logger = ActiveSupport::Logger.new($stderr)
27
-
28
- ActiveSupport.run_load_hooks(:web_console, self)
29
26
  end
30
27
 
31
28
  require 'web_console/railtie'
@@ -3,12 +3,12 @@ module Kernel
3
3
 
4
4
  # Instructs Web Console to render a console in the specified binding.
5
5
  #
6
- # If +bidning+ isn't explicitly given it will default to the binding of the
6
+ # If +binding+ isn't explicitly given it will default to the binding of the
7
7
  # previous frame. E.g. the one that invoked +console+.
8
8
  #
9
9
  # Raises DoubleRenderError if a double +console+ invocation per request is
10
10
  # detected.
11
- def console(binding = WebConsole.caller_bindings.first)
11
+ def console(binding = Bindex.current_bindings.second)
12
12
  raise WebConsole::DoubleRenderError if Thread.current[:__web_console_binding]
13
13
 
14
14
  Thread.current[:__web_console_binding] = binding
@@ -20,12 +20,12 @@ module Kernel
20
20
  end
21
21
  end
22
22
 
23
- module ActionDispatch
24
- class DebugExceptions
25
- def render_exception_with_web_console(request, exception)
26
- render_exception_without_web_console(request, exception).tap do
23
+ module WebConsole
24
+ module DebugExceptionsExt
25
+ def render_exception(request, exception)
26
+ super(request, exception).tap do
27
27
  backtrace_cleaner = request.get_header('action_dispatch.backtrace_cleaner')
28
- error = ExceptionWrapper.new(backtrace_cleaner, exception).exception
28
+ error = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception).exception
29
29
 
30
30
  # Get the original exception if ExceptionWrapper decides to follow it.
31
31
  Thread.current[:__web_console_exception] = error
@@ -38,8 +38,7 @@ module ActionDispatch
38
38
  end
39
39
  end
40
40
  end
41
-
42
- alias_method :render_exception_without_web_console, :render_exception
43
- alias_method :render_exception, :render_exception_with_web_console
44
41
  end
45
42
  end
43
+
44
+ ActionDispatch::DebugExceptions.prepend(WebConsole::DebugExceptionsExt)
@@ -54,7 +54,7 @@ module WebConsole
54
54
  private
55
55
 
56
56
  def acceptable_content_type?(headers)
57
- Mime::Type.parse(headers['Content-Type']).first == Mime[:html]
57
+ Mime::Type.parse(headers['Content-Type'].to_s).first == Mime[:html]
58
58
  end
59
59
 
60
60
  def json_response(opts = {})
@@ -6,7 +6,7 @@ module WebConsole
6
6
  config.web_console.whitelisted_ips = %w( 127.0.0.1 ::1 )
7
7
 
8
8
  initializer 'web_console.initialize' do
9
- require 'web_console/integration'
9
+ require 'bindex'
10
10
  require 'web_console/extensions'
11
11
 
12
12
  if logger = ::Rails.logger
@@ -23,7 +23,7 @@ module WebConsole
23
23
 
24
24
  gem 'web-console', group: :development
25
25
 
26
- If you still want to run it the #{Rails.env} environment (and know
26
+ If you still want to run it in the #{Rails.env} environment (and know
27
27
  what you are doing), put this in your Rails application
28
28
  configuration:
29
29
 
@@ -40,6 +40,7 @@ module WebConsole
40
40
  if mount_point = config.web_console.mount_point
41
41
  Middleware.mount_point = mount_point.chomp('/')
42
42
  end
43
+
43
44
  if root = Rails.application.config.relative_url_root
44
45
  Middleware.mount_point = File.join(root, Middleware.mount_point)
45
46
  end
@@ -1,3 +1,3 @@
1
1
  module WebConsole
2
- VERSION = '3.4.0'
2
+ VERSION = '3.5.0'
3
3
  end
@@ -15,6 +15,8 @@ module WebConsole
15
15
 
16
16
  def include?(network)
17
17
  @networks.any? { |whitelist| whitelist.include?(network.to_s) }
18
+ rescue IPAddr::InvalidAddressError
19
+ false
18
20
  end
19
21
 
20
22
  def to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web-console
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Somerville
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-10-29 00:00:00.000000000 Z
14
+ date: 2017-03-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: railties
@@ -56,19 +56,19 @@ dependencies:
56
56
  - !ruby/object:Gem::Version
57
57
  version: '5.0'
58
58
  - !ruby/object:Gem::Dependency
59
- name: debug_inspector
59
+ name: bindex
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: '0'
64
+ version: 0.4.0
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: '0'
71
+ version: 0.4.0
72
72
  description:
73
73
  email:
74
74
  - charlie@charliesomerville.com
@@ -90,9 +90,6 @@ files:
90
90
  - lib/web_console/evaluator.rb
91
91
  - lib/web_console/exception_mapper.rb
92
92
  - lib/web_console/extensions.rb
93
- - lib/web_console/integration.rb
94
- - lib/web_console/integration/cruby.rb
95
- - lib/web_console/integration/rubinius.rb
96
93
  - lib/web_console/locales/en.yml
97
94
  - lib/web_console/middleware.rb
98
95
  - lib/web_console/railtie.rb
@@ -139,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
136
  version: '0'
140
137
  requirements: []
141
138
  rubyforge_project:
142
- rubygems_version: 2.5.1
139
+ rubygems_version: 2.6.11
143
140
  signing_key:
144
141
  specification_version: 4
145
142
  summary: A debugging tool for your Ruby on Rails applications.
@@ -1,33 +0,0 @@
1
- class Exception
2
- # Returns an array of the exception backtrace locations bindings.
3
- #
4
- # The list won't map to the traces in #backtrace 1 to 1, because we can't
5
- # build bindings for every trace (C functions, for example).
6
- #
7
- # Every integration should set the instance variable.
8
- def bindings
9
- defined?(@bindings) ? @bindings : []
10
- end
11
- end
12
-
13
- case RUBY_ENGINE
14
- when 'rbx'
15
- require 'web_console/integration/rubinius'
16
- when 'ruby'
17
- require 'web_console/integration/cruby'
18
- else
19
- # Prevent a `method redefined; discarding old caller_bindings` warning.
20
-
21
- module WebConsole
22
- # Returns the Ruby bindings of Kernel#callers locations.
23
- #
24
- # The list of bindings here doesn't map 1 to 1 with Kernel#callers, as we
25
- # can't build Ruby bindings for C functions or the equivalent native
26
- # implementations in JRuby and Rubinius.
27
- #
28
- # This method needs to be overridden by every integration.
29
- def self.caller_bindings
30
- raise NotImplementedError
31
- end
32
- end
33
- end
@@ -1,23 +0,0 @@
1
- require 'debug_inspector'
2
-
3
- def WebConsole.caller_bindings
4
- bindings = RubyVM::DebugInspector.open do |context|
5
- context.backtrace_locations.each_index.map { |i| context.frame_binding(i) }
6
- end
7
-
8
- # For C functions, we can't extract a binding. In this case,
9
- # DebugInspector#frame_binding would have returned us nil. That's why we need
10
- # to compact the bindings.
11
- #
12
- # Dropping two bindings, removes the current Ruby one in this exact method,
13
- # and the one in the caller method. The caller method binding can be obtained
14
- # by Kernel#binding, if needed.
15
- bindings.compact.drop(2)
16
- end
17
-
18
- TracePoint.trace(:raise) do |context|
19
- exc = context.raised_exception
20
- if exc.bindings.empty?
21
- exc.instance_variable_set(:@bindings, WebConsole.caller_bindings)
22
- end
23
- end
@@ -1,39 +0,0 @@
1
- def WebConsole.caller_bindings
2
- locations = ::Rubinius::VM.backtrace(1, true)
3
-
4
- # Kernel.raise, is implemented in Ruby for Rubinius. We don't wanna have
5
- # the frame for it to align with the CRuby and JRuby implementations.
6
- #
7
- # For internal methods location variables can be nil. We can't create a
8
- # bindings for them.
9
- locations.reject! do |location|
10
- location.file.start_with?('kernel/delta/kernel.rb') || location.variables.nil?
11
- end
12
-
13
- bindings = locations.map do |location|
14
- Binding.setup(
15
- location.variables,
16
- location.variables.method,
17
- location.constant_scope,
18
- location.variables.self,
19
- location
20
- )
21
- end
22
-
23
- # Drop the binding of the direct caller. That one can be created by
24
- # Kernel#binding.
25
- bindings.drop(1)
26
- end
27
-
28
- ::Rubinius.singleton_class.class_eval do
29
- def raise_exception_with_current_bindings(exc)
30
- if exc.bindings.empty?
31
- exc.instance_variable_set(:@bindings, WebConsole.caller_bindings)
32
- end
33
-
34
- raise_exception_without_current_bindings(exc)
35
- end
36
-
37
- alias_method :raise_exception_without_current_bindings, :raise_exception
38
- alias_method :raise_exception, :raise_exception_with_current_bindings
39
- end