web-console 2.3.0 → 3.0.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
  SHA1:
3
- metadata.gz: 02d40821ae813ac4e5893b4c853725833017cb46
4
- data.tar.gz: 56b2826919677b8a93e6ecedce69a176949d15ee
3
+ metadata.gz: 3ed4f368321b193eeb169e5c5fc82db4b704cbaa
4
+ data.tar.gz: db55b7d89f828ec70974bd9ed46d19e8509f001c
5
5
  SHA512:
6
- metadata.gz: 6c6a07f241b5bfad39c7a588ac92bccc8f0786db1b807d3ab94b4ec13464d7d8514493634c88247a868e78e43169094d216da6f01c3559be45af39854a76a0a0
7
- data.tar.gz: 4b656f08efb441715996f541f94806d9f6249171502fded529041c5fc5cead0a73ce4f155fe246f0c4a36c4a0b54f9bdd65fb3091ed5e9b9bfa86b9d95f3a552
6
+ metadata.gz: 196f9a54b30873b3838c8798f02803fc850af578812c84cc32bf5faccc7e8decc33cb878048e899d9bf4cf0c13415b52edbd042f19ba9c4654e1a784b1961e59
7
+ data.tar.gz: 9927a7e855ceeccfca83ca490bacf8392f8c55fedf2291ecc87f17d51437b7eea35cfe04e050ec6f52eee5d14e793248383c4e670904e4253a43ac96c6284541
@@ -2,14 +2,16 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
- ## 2.3.0
5
+ ## 3.0.0
6
6
 
7
- * [#181](https://github.com/rails/web-console/pull/181) Log internal Web Console errors ([@schneems])
8
- * [#150](https://github.com/rails/web-console/pull/150) Revert #150. ([@gsamokovarov])
7
+ * [#173](https://github.com/rails/web-console/pull/173) Revert "Change config.development_only default until 4.2.4 is released" ([@gsamokovarov])
8
+ * [#171](https://github.com/rails/web-console/pull/171) Fixed blocked IP logging ([@gsamokovarov])
9
+ * [#162](https://github.com/rails/web-console/pull/162) Render the console inside the body tag ([@gsamokovarov])
10
+ * [#165](https://github.com/rails/web-console/pull/165) Revamped integrations for CRuby and Rubinius ([@gsamokovarov])
9
11
 
10
12
  ## 2.2.1
11
13
 
12
- * [#150](https://github.com/rails/web-console/pull/150) Change config.development_only default until 4.2.4 is released. ([@gsamokovarov])
14
+ * [#150](https://github.com/rails/web-console/pull/150) Change config.development_only default until 4.2.4 is released ([@gsamokovarov])
13
15
 
14
16
  ## 2.2.0
15
17
 
@@ -53,4 +55,3 @@
53
55
  [@parterburn]: https://github.com/parterburn
54
56
  [@sh19910711]: https://github.com/sh19910711
55
57
  [@frenesim]: https://github.com/frenesim
56
- [@schneems]: https://github.com/schneems
@@ -1,9 +1,6 @@
1
1
  <p align=right>
2
2
  Documentation for:
3
- <a href=https://github.com/rails/web-console/tree/v2.0.0>v2.0.0</a>
4
- <a href=https://github.com/rails/web-console/tree/v2.1.0>v2.1.0</a>
5
- <a href=https://github.com/rails/web-console/tree/v2.1.1>v2.1.1</a>
6
- <a href=https://github.com/rails/web-console/tree/v2.1.2>v2.1.2</a>
3
+ <a href=https://github.com/rails/web-console/tree/v1.0.4>v1.0.4</a>
7
4
  <a href=https://github.com/rails/web-console/tree/v2.1.3>v2.1.3</a>
8
5
  </p>
9
6
 
@@ -28,7 +25,7 @@ application, add the following to your `Gemfile`.
28
25
 
29
26
  ```ruby
30
27
  group :development do
31
- gem 'web-console', '~> 2.0'
28
+ gem 'web-console', '~> 3.0'
32
29
  end
33
30
  ```
34
31
 
@@ -37,35 +34,9 @@ restart your server for the _Web Console_ to kick in.
37
34
 
38
35
  ## Runtime
39
36
 
40
- _Web Console_ uses [John Mair]'s [binding_of_caller] to spawn a console in a
41
- specific binding. This comes at the price of limited Ruby runtime support.
42
-
43
37
  ### CRuby
44
38
 
45
- CRuby 1.9.2 and below is **not** supported.
46
-
47
- ### JRuby
48
-
49
- JRuby needs to run in interpreted mode. You can enable it by:
50
-
51
- ```bash
52
- export JRUBY_OPTS=-J-Djruby.compile.mode=OFF
53
-
54
- # If you run JRuby 1.7.12 and above, you can use:
55
- export JRUBY_OPTS=--dev
56
- ```
57
-
58
- An unstable version of [binding_of_caller] is needed as the latest stable one
59
- won't compile on _JRuby_. To install it, put the following in your application
60
- `Gemfile`:
61
-
62
- ```ruby
63
- group :development do
64
- gem 'binding_of_caller', '0.7.3.pre1'
65
- end
66
- ```
67
-
68
- Only _JRuby_ 1.7, is supported (no JRuby 9K support at the moment).
39
+ CRuby 2.2 and below is **not** supported.
69
40
 
70
41
  ### Rubinius
71
42
 
@@ -75,7 +46,7 @@ Internal errors like `ZeroDevisionError` aren't caught.
75
46
 
76
47
  The web console allows you to create an interactive Ruby session in your
77
48
  browser. Those sessions are launched automatically in case on an error, but
78
- they can also be launched manually in in any page.
49
+ they can also be launched manually in any page.
79
50
 
80
51
  For example, calling `console` in a view will display a console in the current
81
52
  page in the context of the view binding.
@@ -215,17 +186,16 @@ Make sure you configuration lives in `config/environments/development.rb`.
215
186
 
216
187
  ## Credits
217
188
 
218
- * Shoutout to [Charlie Somerville] for [better_errors] and [this] code.
219
- * Kudos to [John Mair] for [binding_of_caller].
189
+ * Shoutout to [Charlie Somerville] for [better_errors].
190
+ * Kudos to [John Mair] for [debug_inspector].
220
191
  * Thanks to [Charles Oliver Nutter] for all the _JRuby_ feedback.
221
- * Hugs and kisses to all of our [contributors].
192
+ * Hugs and kisses to all of our [contributors]!
222
193
 
223
194
  [better_errors]: https://github.com/charliesome/better_errors
224
- [binding_of_caller]: https://github.com/banister/binding_of_caller
195
+ [debug_inspector]: https://github.com/banister/debug_inspector
225
196
  [Charlie Somerville]: https://github.com/charliesome
226
197
  [John Mair]: https://github.com/banister
227
198
  [Charles Oliver Nutter]: https://github.com/headius
228
199
  [templates]: https://github.com/rails/web-console/tree/master/lib/web_console/templates
229
- [this]: https://github.com/rails/web-console/blob/master/lib/web_console/integration/cruby.rb#L20-L32
230
200
  [rvt]: https://github.com/gsamokovarov/rvt
231
201
  [contributors]: https://github.com/rails/web-console/graphs/contributors
@@ -1,5 +1,3 @@
1
- require 'binding_of_caller'
2
-
3
1
  require 'active_support/lazy_load_hooks'
4
2
  require 'active_support/logger'
5
3
 
@@ -1,10 +1,11 @@
1
1
  ActionDispatch::DebugExceptions.class_eval do
2
2
  def render_exception_with_web_console(request, exception)
3
3
  render_exception_without_web_console(request, exception).tap do
4
- # Retain superficial Rails 5 compatibility.
4
+ # Retain superficial Rails 4.2 compatibility.
5
5
  env = Hash === request ? request : request.env
6
6
 
7
- error = ActionDispatch::ExceptionWrapper.new(env, exception).exception
7
+ backtrace_cleaner = env['action_dispatch.backtrace_cleaner']
8
+ error = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception).exception
8
9
 
9
10
  # Get the original exception if ExceptionWrapper decides to follow it.
10
11
  env['web_console.exception'] = error
@@ -11,7 +11,7 @@ module WebConsole
11
11
  def console(binding = nil)
12
12
  raise DoubleRenderError if request.env['web_console.binding']
13
13
 
14
- request.env['web_console.binding'] = binding || ::Kernel.binding.of_caller(1)
14
+ request.env['web_console.binding'] = binding || ::WebConsole.caller_bindings.first
15
15
 
16
16
  # Make sure nothing is rendered from the view helper. Otherwise
17
17
  # you're gonna see unexpected #<Binding:0x007fee4302b078> in the
@@ -1,8 +1,31 @@
1
+ module WebConsole
2
+ # Returns the Ruby bindings of Kernel#callers locations.
3
+ #
4
+ # The list of bindings here doesn't map 1 to 1 with Kernel#callers, as we
5
+ # can't build Ruby bindings for C functions or the equivalent native
6
+ # implementations in JRuby and Rubinius.
7
+ #
8
+ # This method needs to be overridden by every integration.
9
+ def self.caller_bindings
10
+ raise NotImplementedError
11
+ end
12
+ end
13
+
14
+ class Exception
15
+ # Returns an array of the exception backtrace locations bindings.
16
+ #
17
+ # The list won't map to the traces in #backtrace 1 to 1, because we can't
18
+ # build bindings for every trace (C functions, for example).
19
+ #
20
+ # Every integration should the instance variable.
21
+ def bindings
22
+ @bindings || []
23
+ end
24
+ end
25
+
1
26
  case RUBY_ENGINE
2
27
  when 'rbx'
3
28
  require 'web_console/integration/rubinius'
4
- when 'jruby'
5
- require 'web_console/integration/jruby'
6
29
  when 'ruby'
7
30
  require 'web_console/integration/cruby'
8
31
  end
@@ -1,40 +1,23 @@
1
- class Exception
2
- begin
3
- # We share the same exception binding extraction mechanism as better_errors,
4
- # so try to use it if it is already available. It also solves problems like
5
- # charliesome/better_errors#272, caused by an infinite recursion.
6
- require 'better_errors'
1
+ require 'debug_inspector'
7
2
 
8
- # The bindings in which the exception originated in.
9
- def bindings
10
- @bindings || __better_errors_bindings_stack
11
- end
12
- rescue LoadError
13
- # The bindings in which the exception originated in.
14
- def bindings
15
- @bindings || []
16
- end
17
-
18
- # CRuby calls #set_backtrace every time it raises an exception. Overriding
19
- # it to assign the #bindings.
20
- def set_backtrace_with_binding_of_caller(*args)
21
- # Thanks to @charliesome who wrote this bit for better_errors.
22
- unless Thread.current[:__web_console_exception_lock]
23
- Thread.current[:__web_console_exception_lock] = true
24
- begin
25
- # Raising an exception here will cause all of the rubies to go into a
26
- # stack overflow. Some rubies may even segfault. See
27
- # https://bugs.ruby-lang.org/issues/10164 for details.
28
- @bindings = binding.callers.drop(1)
29
- ensure
30
- Thread.current[:__web_console_exception_lock] = false
31
- end
32
- end
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
33
7
 
34
- set_backtrace_without_binding_of_caller(*args)
35
- end
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
36
17
 
37
- alias_method :set_backtrace_without_binding_of_caller, :set_backtrace
38
- alias_method :set_backtrace, :set_backtrace_with_binding_of_caller
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)
39
22
  end
40
23
  end
@@ -1,62 +1,34 @@
1
- module WebConsole
2
- module Rubinius
3
- # Filters internal Rubinius locations.
4
- #
5
- # There are a couple of reasons why we wanna filter out the locations.
6
- #
7
- # * ::Kernel.raise, is implemented in Ruby for Rubinius. We don't wanna
8
- # have the frame for it to align with the CRuby and JRuby implementations.
9
- #
10
- # * For internal methods location variables can be nil. We can't create a
11
- # bindings for them.
12
- #
13
- # * Bindings from the current file are considered internal and ignored.
14
- #
15
- # We do that all that so we can align the bindings with the backtraces
16
- # entries.
17
- class InternalLocationFilter
18
- def initialize(locations)
19
- @locations = locations
20
- end
1
+ def WebConsole.caller_bindings
2
+ locations = ::Rubinius::VM.backtrace(1, true)
21
3
 
22
- def filter
23
- @locations.reject do |location|
24
- location.file.start_with?('kernel/delta/kernel.rb') ||
25
- location.file == __FILE__ ||
26
- location.variables.nil?
27
- end
28
- end
29
- end
30
-
31
- # Gets the current bindings for all available Ruby frames.
32
- #
33
- # Filters the internal Rubinius and WebConsole frames.
34
- def self.current_bindings
35
- locations = ::Rubinius::VM.backtrace(1, true)
36
-
37
- InternalLocationFilter.new(locations).filter.map do |location|
38
- Binding.setup(
39
- location.variables,
40
- location.variables.method,
41
- location.constant_scope,
42
- location.variables.self,
43
- location
44
- )
45
- end
46
- end
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?
47
11
  end
48
- end
49
12
 
50
- ::Exception.class_eval do
51
- def bindings
52
- @bindings || []
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
+ )
53
21
  end
22
+
23
+ # Drop the binding of the direct caller. That one can be created by
24
+ # Kernel#binding.
25
+ bindings.drop(1)
54
26
  end
55
27
 
56
28
  ::Rubinius.singleton_class.class_eval do
57
29
  def raise_exception_with_current_bindings(exc)
58
30
  if exc.bindings.empty?
59
- exc.instance_variable_set(:@bindings, WebConsole::Rubinius.current_bindings)
31
+ exc.instance_variable_set(:@bindings, WebConsole.caller_bindings)
60
32
  end
61
33
 
62
34
  raise_exception_without_current_bindings(exc)
@@ -15,47 +15,40 @@ module WebConsole
15
15
  end
16
16
 
17
17
  def call(env)
18
- app_exception = catch :app_exception do
19
- request = create_regular_or_whiny_request(env)
20
- return @app.call(env) unless request.from_whitelited_ip?
21
-
22
- if id = id_for_repl_session_update(request)
23
- return update_repl_session(id, request)
24
- elsif id = id_for_repl_session_stack_frame_change(request)
25
- return change_stack_trace(id, request)
26
- end
18
+ request = create_regular_or_whiny_request(env)
19
+ return @app.call(env) unless request.from_whitelisted_ip?
20
+
21
+ if id = id_for_repl_session_update(request)
22
+ return update_repl_session(id, request)
23
+ elsif id = id_for_repl_session_stack_frame_change(request)
24
+ return change_stack_trace(id, request)
25
+ end
27
26
 
28
- status, headers, body = @app.call(env)
27
+ status, headers, body = @app.call(env)
29
28
 
30
- if exception = env['web_console.exception']
31
- session = Session.from_exception(exception)
32
- elsif binding = env['web_console.binding']
33
- session = Session.from_binding(binding)
34
- end
29
+ if exception = env['web_console.exception']
30
+ session = Session.from_exception(exception)
31
+ elsif binding = env['web_console.binding']
32
+ session = Session.from_binding(binding)
33
+ end
35
34
 
36
- if session && acceptable_content_type?(headers)
37
- response = Response.new(body, status, headers)
38
- template = Template.new(env, session)
35
+ if session && acceptable_content_type?(headers)
36
+ response = Response.new(body, status, headers)
37
+ template = Template.new(env, session)
39
38
 
40
- response.headers["X-Web-Console-Session-Id"] = session.id
41
- response.headers["X-Web-Console-Mount-Point"] = mount_point
42
- response.write(template.render('index'))
43
- response.finish
44
- else
45
- [ status, headers, body ]
46
- end
39
+ response.headers["X-Web-Console-Session-Id"] = session.id
40
+ response.headers["X-Web-Console-Mount-Point"] = mount_point
41
+ response.write(template.render('index'))
42
+ response.finish
43
+ else
44
+ [ status, headers, body ]
47
45
  end
48
- rescue => e
49
- WebConsole.logger.error("\n#{e.class}: #{e}\n\tfrom #{e.backtrace.join("\n\tfrom ")}")
50
- raise e
51
- ensure
52
- raise app_exception if Exception === app_exception
53
46
  end
54
47
 
55
48
  private
56
49
 
57
50
  def acceptable_content_type?(headers)
58
- Mime::Type.parse(headers['Content-Type']).first == Mime::HTML
51
+ Mime::Type.parse(headers['Content-Type']).first == Mime[:html]
59
52
  end
60
53
 
61
54
  def json_response(opts = {})
@@ -127,11 +120,5 @@ module WebConsole
127
120
  { output: I18n.t('errors.unacceptable_request') }
128
121
  end
129
122
  end
130
-
131
- def call_app(env)
132
- @app.call(env)
133
- rescue => e
134
- throw :app_exception, e
135
- end
136
123
  end
137
124
  end
@@ -20,7 +20,7 @@ module WebConsole
20
20
  initializer 'web_console.development_only' do
21
21
  unless (config.web_console.development_only == false) || Rails.env.development?
22
22
  abort <<-END.strip_heredoc
23
- Web Console is activated in the #{Rails.env} environment, which is
23
+ Web Console is activated in the #{Rails.env} environment. This is
24
24
  usually a mistake. To ensure it's only activated in development
25
25
  mode, move it to the development group of your Gemfile:
26
26
 
@@ -5,14 +5,14 @@ module WebConsole
5
5
  cattr_accessor :whitelisted_ips
6
6
  @@whitelisted_ips = Whitelist.new
7
7
 
8
- # Define a vendor MIME type. We can call it using Mime::WEB_CONSOLE_V2 constant.
8
+ # Define a vendor MIME type. We can call it using Mime[:web_console_v2].
9
9
  Mime::Type.register 'application/vnd.web-console.v2', :web_console_v2
10
10
 
11
11
  # Returns whether a request came from a whitelisted IP.
12
12
  #
13
13
  # For a request to hit Web Console features, it needs to come from a white
14
14
  # listed IP.
15
- def from_whitelited_ip?
15
+ def from_whitelisted_ip?
16
16
  whitelisted_ips.include?(strict_remote_ip)
17
17
  end
18
18
 
@@ -23,7 +23,7 @@ module WebConsole
23
23
 
24
24
  # Returns whether the request is acceptable.
25
25
  def acceptable?
26
- xhr? && accepts.any? { |mime| Mime::WEB_CONSOLE_V2 == mime }
26
+ xhr? && accepts.any? { |mime| Mime[:web_console_v2] == mime }
27
27
  end
28
28
 
29
29
  private
@@ -488,7 +488,7 @@ REPLConsole.request = function request(method, url, params, callback) {
488
488
  xhr.open(method, url, true);
489
489
  xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
490
490
  xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
491
- xhr.setRequestHeader("Accept", "<%= Mime::WEB_CONSOLE_V2 %>");
491
+ xhr.setRequestHeader("Accept", "<%= Mime[:web_console_v2] %>");
492
492
  xhr.send(params);
493
493
 
494
494
  xhr.onreadystatechange = function() {
@@ -0,0 +1,11 @@
1
+ module WebConsole
2
+ class BindingTracer
3
+ def initialize(exception)
4
+ @bindings = exception.bindings
5
+ @backtrace = exception.backtrace
6
+ end
7
+
8
+ def binding_for_trace(trace)
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module WebConsole
2
- VERSION = '2.3.0'
2
+ VERSION = '3.0.0'
3
3
  end
@@ -4,9 +4,9 @@ module WebConsole
4
4
  # If any calls to +from_whitelisted_ip?+ and +acceptable_content_type?+
5
5
  # return false, an info log message will be displayed in users' logs.
6
6
  class WhinyRequest < SimpleDelegator
7
- def from_whitelited_ip?
8
- whine_unless request.from_whitelited_ip? do
9
- "Cannot render console from #{request.remote_ip}! " \
7
+ def from_whitelisted_ip?
8
+ whine_unless request.from_whitelisted_ip? do
9
+ "Cannot render console from #{request.strict_remote_ip}! " \
10
10
  "Allowed networks: #{request.whitelisted_ips}"
11
11
  end
12
12
  end
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: 2.3.0
4
+ version: 3.0.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-01-27 00:00:00.000000000 Z
14
+ date: 2015-12-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: railties
@@ -19,90 +19,42 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '4.0'
22
+ version: '4.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '4.0'
29
+ version: '4.2'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: activemodel
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: '4.0'
36
+ version: '4.2'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: '4.0'
43
+ version: '4.2'
44
44
  - !ruby/object:Gem::Dependency
45
- name: sprockets-rails
45
+ name: debug_inspector
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: '2.0'
51
- - - "<"
52
- - !ruby/object:Gem::Version
53
- version: '4.0'
50
+ version: '0'
54
51
  type: :runtime
55
52
  prerelease: false
56
53
  version_requirements: !ruby/object:Gem::Requirement
57
54
  requirements:
58
55
  - - ">="
59
56
  - !ruby/object:Gem::Version
60
- version: '2.0'
61
- - - "<"
62
- - !ruby/object:Gem::Version
63
- version: '4.0'
64
- - !ruby/object:Gem::Dependency
65
- name: binding_of_caller
66
- requirement: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 0.7.2
71
- type: :runtime
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: 0.7.2
78
- - !ruby/object:Gem::Dependency
79
- name: actionmailer
80
- requirement: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: '4.0'
85
- type: :development
86
- prerelease: false
87
- version_requirements: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: '4.0'
92
- - !ruby/object:Gem::Dependency
93
- name: activerecord
94
- requirement: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- version: '4.0'
99
- type: :development
100
- prerelease: false
101
- version_requirements: !ruby/object:Gem::Requirement
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- version: '4.0'
57
+ version: '0'
106
58
  description:
107
59
  email:
108
60
  - charlie@charliesomerville.com
@@ -125,7 +77,6 @@ files:
125
77
  - lib/web_console/helper.rb
126
78
  - lib/web_console/integration.rb
127
79
  - lib/web_console/integration/cruby.rb
128
- - lib/web_console/integration/jruby.rb
129
80
  - lib/web_console/integration/rubinius.rb
130
81
  - lib/web_console/locales/en.yml
131
82
  - lib/web_console/middleware.rb
@@ -149,6 +100,7 @@ files:
149
100
  - lib/web_console/testing/erb_precompiler.rb
150
101
  - lib/web_console/testing/fake_middleware.rb
151
102
  - lib/web_console/testing/helper.rb
103
+ - lib/web_console/tracer.rb
152
104
  - lib/web_console/version.rb
153
105
  - lib/web_console/view.rb
154
106
  - lib/web_console/whiny_request.rb
@@ -165,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
117
  requirements:
166
118
  - - ">="
167
119
  - !ruby/object:Gem::Version
168
- version: '0'
120
+ version: 2.2.2
169
121
  required_rubygems_version: !ruby/object:Gem::Requirement
170
122
  requirements:
171
123
  - - ">="
@@ -173,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
125
  version: '0'
174
126
  requirements: []
175
127
  rubyforge_project:
176
- rubygems_version: 2.5.1
128
+ rubygems_version: 2.4.5
177
129
  signing_key:
178
130
  specification_version: 4
179
131
  summary: A debugging tool for your Ruby on Rails applications.
@@ -1,111 +0,0 @@
1
- require 'English'
2
- require 'active_support/core_ext/string/strip'
3
-
4
- java_import org.jruby.RubyInstanceConfig
5
-
6
- module WebConsole
7
- module JRuby
8
- class << self
9
- # Returns whether JRuby is ran in interpreted mode.
10
- def interpreted_mode?
11
- compile_mode = ::JRuby.runtime.instance_config.compile_mode
12
- interpreted_mode = RubyInstanceConfig::CompileMode::OFF
13
-
14
- compile_mode == interpreted_mode
15
- end
16
-
17
- # A proc to be used in Kernel#set_trace_func.
18
- #
19
- # It sets Exception#bindings for an error with all the bindings the
20
- # current ThreadContext contains.
21
- def set_exception_bindings_trace_func
22
- proc do |event, file, line, id, binding, classname|
23
- case event
24
- when 'raise'
25
- if $ERROR_INFO.bindings.empty?
26
- # binding_of_caller will generate an improperly built binding at
27
- # caller[1]. Every call to a non existent method, constant or a
28
- # local variable will result in a Java NullPointerException.
29
- #
30
- # The binding that Kernel#set_trace_func is giving us is properly
31
- # built, so we can use in place of the broken one.
32
- bindings = ::Kernel.binding.callers.drop(2).unshift(binding)
33
- $ERROR_INFO.instance_variable_set(:@bindings, bindings)
34
- end
35
- end
36
- end
37
- end
38
- end
39
-
40
- # A fake binding for JRuby in non interpreted mode.
41
- #
42
- # It won't actually evaluate any code, rather it will tell the user how to
43
- # enable interpreted mode.
44
- class FakeJRubyBinding
45
- TURN_ON_INTERPRETED_MODE_TEXT = <<-END.strip_heredoc
46
- JRuby needs to run in interpreted mode for introspection support.
47
-
48
- To turn on interpreted mode, put -J-Djruby.compile.mode=OFF in the
49
- JRUBY_OPTS environment variable.
50
- END
51
-
52
- def TURN_ON_INTERPRETED_MODE_TEXT.inspect
53
- self
54
- end
55
-
56
- TURN_ON_INTERPRETED_MODE_TEXT.freeze
57
-
58
- def eval(*)
59
- TURN_ON_INTERPRETED_MODE_TEXT
60
- end
61
- end
62
-
63
- # A fake array of FakeJRubyBinding objects.
64
- #
65
- # It is used in Exception#bindings to make sure that when users switch
66
- # bindings on the UI, they get a FakeJRubyBinding notifying them what to do
67
- # if they want introspection.
68
- class FakeJRubyBindingsArray < Array
69
- def [](*)
70
- FakeJRubyBinding.new
71
- end
72
-
73
- # For Kernel#Array and other implicit conversion API. JRuby expects it to
74
- # return an object that is_a? an Array. This is the reasoning of
75
- # FakeJRubyBindingsArray being a subclass of Array.
76
- def to_ary
77
- self
78
- end
79
- end
80
- end
81
- end
82
-
83
- if WebConsole::JRuby.interpreted_mode?
84
- ::Exception.class_eval do
85
- def bindings
86
- @bindings || []
87
- end
88
- end
89
-
90
- # Kernel#set_trace_func will complain about not being able to capture all the
91
- # events without the JRuby --debug flag.
92
- silence_warnings do
93
- set_trace_func WebConsole::JRuby.set_exception_bindings_trace_func
94
- end
95
- else
96
- ::Exception.class_eval do
97
- def bindings
98
- WebConsole::JRuby::FakeJRubyBindingsArray.new
99
- end
100
- end
101
-
102
- ::Binding.class_eval do
103
- def of_caller(*)
104
- WebConsole::JRuby::FakeJRubyBinding.new
105
- end
106
-
107
- def callers
108
- WebConsole::JRuby::FakeJRubyBindingsArray.new
109
- end
110
- end
111
- end