web-console 3.0.0 → 3.1.1
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.markdown +12 -0
- data/MIT-LICENSE +1 -1
- data/README.markdown +6 -3
- data/lib/web_console.rb +20 -14
- data/lib/web_console/extensions.rb +44 -20
- data/lib/web_console/integration.rb +1 -1
- data/lib/web_console/middleware.rb +35 -23
- data/lib/web_console/railtie.rb +3 -6
- data/lib/web_console/session.rb +16 -11
- data/lib/web_console/version.rb +1 -1
- metadata +3 -5
- data/lib/web_console/helper.rb +0 -22
- data/lib/web_console/tracer.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35b84addef5e3e76f47e06e3c18582721dd344f1
|
4
|
+
data.tar.gz: 2089aca773c3f118ef93ecea2084838da6c69951
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d9e288ce24ad68f578d87bc9a5de25678defe0e82b1af6e3d22adc0d4aee394df5f369f0eb8c036bf437b24103db2086c97abe8aaf2b98a5690c416daf2abe4
|
7
|
+
data.tar.gz: deb6c9fb3bce25afbc4e446b660a8b6dc7d47698fd8dae4933be7b96080d00115940a3b614e9eec822563da4fef800037fc9db7768bfad34b856eabbe04776f7
|
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 3.1.1
|
6
|
+
|
7
|
+
* [#185](https://github.com/rails/web-console/pull/185) Fix `rails console` startup ([@gsamokovarov])
|
8
|
+
|
9
|
+
## 3.1.0
|
10
|
+
|
11
|
+
* [#182](https://github.com/rails/web-console/pull/182) Let `#console` live in `Kernel` ([@schneems])
|
12
|
+
* [#181](https://github.com/rails/web-console/pull/181) Log internal Web Console errors ([@gsamokovarov])
|
13
|
+
* [#180](https://github.com/rails/web-console/pull/180) Autoload Web Console constants for faster Rails boot time ([@herminiotorres])
|
14
|
+
|
5
15
|
## 3.0.0
|
6
16
|
|
7
17
|
* [#173](https://github.com/rails/web-console/pull/173) Revert "Change config.development_only default until 4.2.4 is released" ([@gsamokovarov])
|
@@ -55,3 +65,5 @@
|
|
55
65
|
[@parterburn]: https://github.com/parterburn
|
56
66
|
[@sh19910711]: https://github.com/sh19910711
|
57
67
|
[@frenesim]: https://github.com/frenesim
|
68
|
+
[@herminiotorres]: https://github.com/herminiotorres
|
69
|
+
[@schneems]: https://github.com/schneems
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright 2014 Charlie Somerville, Genadi Samokovarov, Guillermo Iguaran and Ryan Dao
|
1
|
+
Copyright 2014-2016 Charlie Somerville, Genadi Samokovarov, Guillermo Iguaran and Ryan Dao
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
data/README.markdown
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
<p align=right>
|
2
2
|
Documentation for:
|
3
3
|
<a href=https://github.com/rails/web-console/tree/v1.0.4>v1.0.4</a>
|
4
|
-
<a href=https://github.com/rails/web-console/tree/v2.1
|
4
|
+
<a href=https://github.com/rails/web-console/tree/v2.2.1>v2.2.1</a>
|
5
|
+
<a href=https://github.com/rails/web-console/tree/v3.0.0>v3.0.0</a>
|
5
6
|
</p>
|
6
7
|
|
7
8
|
# Web Console [](https://travis-ci.org/rails/web-console)
|
@@ -67,8 +68,10 @@ class PostsController < ApplicationController
|
|
67
68
|
end
|
68
69
|
```
|
69
70
|
|
70
|
-
|
71
|
-
|
71
|
+
The method is defined in `Kernel` and you can invoke it any application code.
|
72
|
+
|
73
|
+
Only one `console` invocation is allowed once per request. If you happen to
|
74
|
+
have multiple ones, a `WebConsole::DoubleRenderError` will be raised.
|
72
75
|
|
73
76
|
## Configuration
|
74
77
|
|
data/lib/web_console.rb
CHANGED
@@ -1,23 +1,29 @@
|
|
1
|
+
require 'active_support/dependencies/autoload'
|
1
2
|
require 'active_support/lazy_load_hooks'
|
2
3
|
require 'active_support/logger'
|
3
4
|
|
4
|
-
require 'web_console/integration'
|
5
|
-
require 'web_console/railtie'
|
6
|
-
require 'web_console/errors'
|
7
|
-
require 'web_console/helper'
|
8
|
-
require 'web_console/evaluator'
|
9
|
-
require 'web_console/session'
|
10
|
-
require 'web_console/template'
|
11
|
-
require 'web_console/middleware'
|
12
|
-
require 'web_console/whitelist'
|
13
|
-
require 'web_console/request'
|
14
|
-
require 'web_console/response'
|
15
|
-
require 'web_console/view'
|
16
|
-
require 'web_console/whiny_request'
|
17
|
-
|
18
5
|
module WebConsole
|
6
|
+
extend ActiveSupport::Autoload
|
7
|
+
|
8
|
+
autoload :View
|
9
|
+
autoload :Evaluator
|
10
|
+
autoload :Session
|
11
|
+
autoload :Response
|
12
|
+
autoload :Request
|
13
|
+
autoload :WhinyRequest
|
14
|
+
autoload :Whitelist
|
15
|
+
autoload :Template
|
16
|
+
autoload :Middleware
|
17
|
+
|
18
|
+
autoload_at 'web_console/errors' do
|
19
|
+
autoload :Error
|
20
|
+
autoload :DoubleRenderError
|
21
|
+
end
|
22
|
+
|
19
23
|
mattr_accessor :logger
|
20
24
|
@@logger = ActiveSupport::Logger.new($stderr)
|
21
25
|
|
22
26
|
ActiveSupport.run_load_hooks(:web_console, self)
|
23
27
|
end
|
28
|
+
|
29
|
+
require 'web_console/railtie'
|
@@ -1,24 +1,48 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
module Kernel
|
2
|
+
module_function
|
3
|
+
|
4
|
+
# Instructs Web Console to render a console in the specified binding.
|
5
|
+
#
|
6
|
+
# If +bidning+ isn't explicitly given it will default to the binding of the
|
7
|
+
# previous frame. E.g. the one that invoked +console+.
|
8
|
+
#
|
9
|
+
# Raises DoubleRenderError if a double +console+ invocation per request is
|
10
|
+
# detected.
|
11
|
+
def console(binding = WebConsole.caller_bindings.first)
|
12
|
+
raise WebConsole::DoubleRenderError if Thread.current[:__web_console_binding]
|
13
|
+
|
14
|
+
Thread.current[:__web_console_binding] = binding
|
15
|
+
|
16
|
+
# Make sure nothing is rendered from the view helper. Otherwise
|
17
|
+
# you're gonna see unexpected #<Binding:0x007fee4302b078> in the
|
18
|
+
# templates.
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
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
|
27
|
+
# Retain superficial Rails 4.2 compatibility.
|
28
|
+
env = Hash === request ? request : request.env
|
29
|
+
|
30
|
+
backtrace_cleaner = env['action_dispatch.backtrace_cleaner']
|
31
|
+
error = ExceptionWrapper.new(backtrace_cleaner, exception).exception
|
32
|
+
|
33
|
+
# Get the original exception if ExceptionWrapper decides to follow it.
|
34
|
+
Thread.current[:__web_console_exception] = error
|
35
|
+
|
36
|
+
# ActionView::Template::Error bypass ExceptionWrapper original
|
37
|
+
# exception following. The backtrace in the view is generated from
|
38
|
+
# reaching out to original_exception in the view.
|
39
|
+
if error.is_a?(ActionView::Template::Error)
|
40
|
+
Thread.current[:__web_console_exception] = error.cause
|
41
|
+
end
|
18
42
|
end
|
19
43
|
end
|
20
|
-
end
|
21
44
|
|
22
|
-
|
23
|
-
|
45
|
+
alias_method :render_exception_without_web_console, :render_exception
|
46
|
+
alias_method :render_exception, :render_exception_with_web_console
|
47
|
+
end
|
24
48
|
end
|
@@ -15,34 +15,40 @@ module WebConsole
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(env)
|
18
|
-
|
19
|
-
|
18
|
+
app_exception = catch :app_exception do
|
19
|
+
request = create_regular_or_whiny_request(env)
|
20
|
+
return call_app(env) unless request.from_whitelisted_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
|
20
27
|
|
21
|
-
|
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
|
28
|
+
status, headers, body = call_app(env)
|
26
29
|
|
27
|
-
|
30
|
+
if session = Session.from(Thread.current) and acceptable_content_type?(headers)
|
31
|
+
response = Response.new(body, status, headers)
|
32
|
+
template = Template.new(env, session)
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
34
|
+
response.headers["X-Web-Console-Session-Id"] = session.id
|
35
|
+
response.headers["X-Web-Console-Mount-Point"] = mount_point
|
36
|
+
response.write(template.render('index'))
|
37
|
+
response.finish
|
38
|
+
else
|
39
|
+
[ status, headers, body ]
|
40
|
+
end
|
33
41
|
end
|
42
|
+
rescue => e
|
43
|
+
WebConsole.logger.error("\n#{e.class}: #{e}\n\tfrom #{e.backtrace.join("\n\tfrom ")}")
|
44
|
+
raise e
|
45
|
+
ensure
|
46
|
+
# Clean up the fiber locals after the session creation. Object#console
|
47
|
+
# uses those to communicate the current binding or exception to the middleware.
|
48
|
+
Thread.current[:__web_console_exception] = nil
|
49
|
+
Thread.current[:__web_console_binding] = nil
|
34
50
|
|
35
|
-
if
|
36
|
-
response = Response.new(body, status, headers)
|
37
|
-
template = Template.new(env, session)
|
38
|
-
|
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 ]
|
45
|
-
end
|
51
|
+
raise app_exception if Exception === app_exception
|
46
52
|
end
|
47
53
|
|
48
54
|
private
|
@@ -120,5 +126,11 @@ module WebConsole
|
|
120
126
|
{ output: I18n.t('errors.unacceptable_request') }
|
121
127
|
end
|
122
128
|
end
|
129
|
+
|
130
|
+
def call_app(env)
|
131
|
+
@app.call(env)
|
132
|
+
rescue => e
|
133
|
+
throw :app_exception, e
|
134
|
+
end
|
123
135
|
end
|
124
136
|
end
|
data/lib/web_console/railtie.rb
CHANGED
@@ -6,14 +6,11 @@ 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
10
|
require 'web_console/extensions'
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
ActiveSupport.on_load(:action_controller) do
|
16
|
-
ActionController::Base.send(:include, Helper)
|
12
|
+
if logger = ::Rails.logger
|
13
|
+
WebConsole.logger = logger
|
17
14
|
end
|
18
15
|
end
|
19
16
|
|
data/lib/web_console/session.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module WebConsole
|
2
|
-
# A session lets you persist
|
3
|
-
#
|
2
|
+
# A session lets you persist an +Evaluator+ instance in memory associated
|
3
|
+
# with multiple bindings.
|
4
4
|
#
|
5
5
|
# Each newly created session is persisted into memory and you can find it
|
6
|
-
# later its +id+.
|
6
|
+
# later by its +id+.
|
7
7
|
#
|
8
8
|
# A session may be associated with multiple bindings. This is used by the
|
9
9
|
# error pages only, as currently, this is the only client that needs to do
|
@@ -21,14 +21,19 @@ module WebConsole
|
|
21
21
|
inmemory_storage[id]
|
22
22
|
end
|
23
23
|
|
24
|
-
# Create a Session from an exception.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
|
31
|
-
|
24
|
+
# Create a Session from an binding or exception in a storage.
|
25
|
+
#
|
26
|
+
# The storage is expected to respond to #[]. The binding is expected in
|
27
|
+
# :__web_console_binding and the exception in :__web_console_exception.
|
28
|
+
#
|
29
|
+
# Can return nil, if no binding or exception have been preserved in the
|
30
|
+
# storage.
|
31
|
+
def from(storage)
|
32
|
+
if exc = storage[:__web_console_exception]
|
33
|
+
new(exc.bindings)
|
34
|
+
elsif binding = storage[:__web_console_binding]
|
35
|
+
new(binding)
|
36
|
+
end
|
32
37
|
end
|
33
38
|
end
|
34
39
|
|
data/lib/web_console/version.rb
CHANGED
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
|
+
version: 3.1.1
|
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:
|
14
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: railties
|
@@ -74,7 +74,6 @@ files:
|
|
74
74
|
- lib/web_console/errors.rb
|
75
75
|
- lib/web_console/evaluator.rb
|
76
76
|
- lib/web_console/extensions.rb
|
77
|
-
- lib/web_console/helper.rb
|
78
77
|
- lib/web_console/integration.rb
|
79
78
|
- lib/web_console/integration/cruby.rb
|
80
79
|
- lib/web_console/integration/rubinius.rb
|
@@ -100,7 +99,6 @@ files:
|
|
100
99
|
- lib/web_console/testing/erb_precompiler.rb
|
101
100
|
- lib/web_console/testing/fake_middleware.rb
|
102
101
|
- lib/web_console/testing/helper.rb
|
103
|
-
- lib/web_console/tracer.rb
|
104
102
|
- lib/web_console/version.rb
|
105
103
|
- lib/web_console/view.rb
|
106
104
|
- lib/web_console/whiny_request.rb
|
@@ -125,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
123
|
version: '0'
|
126
124
|
requirements: []
|
127
125
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.5.1
|
129
127
|
signing_key:
|
130
128
|
specification_version: 4
|
131
129
|
summary: A debugging tool for your Ruby on Rails applications.
|
data/lib/web_console/helper.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module WebConsole
|
2
|
-
module Helper
|
3
|
-
# Communicates with the middleware to render a console in a +binding+.
|
4
|
-
#
|
5
|
-
# If +bidning+ isn't explicitly given, Binding#of_caller will be used to
|
6
|
-
# get the binding of the previous frame. E.g. the one that invoked
|
7
|
-
# +console+.
|
8
|
-
#
|
9
|
-
# Raises DoubleRenderError if a double +console+ invocation per request is
|
10
|
-
# detected.
|
11
|
-
def console(binding = nil)
|
12
|
-
raise DoubleRenderError if request.env['web_console.binding']
|
13
|
-
|
14
|
-
request.env['web_console.binding'] = binding || ::WebConsole.caller_bindings.first
|
15
|
-
|
16
|
-
# Make sure nothing is rendered from the view helper. Otherwise
|
17
|
-
# you're gonna see unexpected #<Binding:0x007fee4302b078> in the
|
18
|
-
# templates.
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|