web-console 1.0.4 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of web-console might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.markdown +26 -247
- data/lib/action_dispatch/debug_exceptions.rb +115 -0
- data/lib/action_dispatch/exception_wrapper.rb +15 -0
- data/lib/action_dispatch/templates/rescues/_request_and_response.html.erb +34 -0
- data/lib/action_dispatch/templates/rescues/_request_and_response.text.erb +23 -0
- data/lib/action_dispatch/templates/rescues/_source.erb +27 -0
- data/lib/action_dispatch/templates/rescues/_trace.html.erb +76 -0
- data/lib/action_dispatch/templates/rescues/_trace.text.erb +15 -0
- data/lib/action_dispatch/templates/rescues/_web_console.html.erb +382 -0
- data/lib/action_dispatch/templates/rescues/diagnostics.html.erb +18 -0
- data/lib/action_dispatch/templates/rescues/diagnostics.text.erb +9 -0
- data/lib/action_dispatch/templates/rescues/layout.erb +162 -0
- data/lib/action_dispatch/templates/rescues/missing_template.html.erb +7 -0
- data/lib/action_dispatch/templates/rescues/missing_template.text.erb +3 -0
- data/lib/action_dispatch/templates/rescues/routing_error.html.erb +30 -0
- data/lib/action_dispatch/templates/rescues/routing_error.text.erb +11 -0
- data/lib/action_dispatch/templates/rescues/template_error.html.erb +22 -0
- data/lib/action_dispatch/templates/rescues/template_error.text.erb +8 -0
- data/lib/action_dispatch/templates/rescues/unknown_action.html.erb +6 -0
- data/lib/action_dispatch/templates/rescues/unknown_action.text.erb +3 -0
- data/lib/web_console.rb +17 -7
- data/lib/web_console/exception_extension.rb +22 -0
- data/lib/web_console/railtie.rb +15 -0
- data/lib/web_console/repl.rb +24 -0
- data/lib/web_console/repl_session.rb +90 -0
- data/lib/web_console/version.rb +1 -1
- data/lib/web_console/view_helpers.rb +21 -0
- data/test/action_pack/exception_wrapper_test.rb +26 -0
- data/test/dummy/app/controllers/exception_test_controller.rb +11 -0
- data/test/dummy/app/controllers/helper_test_controller.rb +5 -0
- data/test/dummy/app/views/helper_test/index.html.erb +220 -0
- data/test/dummy/app/views/layouts/application.html.erb +2 -0
- data/test/dummy/config/application.rb +0 -34
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +61270 -0
- data/test/dummy/log/test.log +3917 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/038461854af2e8bccdb29768efd4768f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0ec396634a5f6808b026257fd107c355 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/127a54171eea8d294e4673599861787d +0 -0
- data/{app/assets/stylesheets/web_console/application.css → test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/17c571144b4e44da39bddb2d2c412414 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1cb77d8cf661ccbc9de08f347c89b9f1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/204edd12a29660722d4e0d8de9bd6652 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2b96b037f3dfeccfe27113eb95b06ea1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2c853768baf811357d81d41bdfd05dcf +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/314d48e543146f617c4d3439a4d8d40d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/34f21019a876722b8c24a6da4f0ef50b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/{vendor/assets/javascripts/term.js → test/dummy/tmp/cache/assets/development/sprockets/36341e42f23669574fa1027d0958ff3e} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/44117154e909436e7eeaf10cdb18d2b4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/496864a905d53afd8e176f29500f96a8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/55b7b76605fdffe31d737d4ac1f1ef7b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5ac98782fe3dfd0a766f75ce1801f0a0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6088d6f344b38303cc8028057d69e0f9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/676dcf9b2d01b9dc7bd3183d8da88463 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/680381170dc160e358fc28076ea6886c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6ad7acc9a22fe2a67ec24a1fc866c20e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6bdb0d0c602e0e1bc304dc697e2cc6de +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6dc8d7aa69668fce85683aaad6615432 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6e4d5b32cc444226f6597198994ccd5e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/74db0ca5cb8c8c347c9131a3ff516748 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7999e525c88173c1beb785f002effc1d +0 -0
- data/{lib/assets/javascripts/web_console.js → test/dummy/tmp/cache/assets/development/sprockets/7a50a9e605754e99783de95715b976b0} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/806b0e33a2fe8e1245534345fa27c30a +0 -0
- data/{app/assets/javascripts/web_console/console_sessions.js → test/dummy/tmp/cache/assets/development/sprockets/8aa4c7aabff23c8089d41e9e54193483} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/90396626cba6cbec37e32038e6c54e76 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/976b28910aa72c90a3b30c6e940f51df +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/99e1bd7cbc437505bc8f07bc528c721c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/aaccf2c9ae2add0863c9a49e0042a097 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ae4677d24a79d9411f2fced5011d5807 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b2401118729720034b6f3eda0b4c5025 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c649837df826fc310cb80f1adafd6b8d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cac185d59612fae451a12df3fc21bb51 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cb0065359d3b5b296f71d673f4b276e9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cee8c6b09c33d2b276753e959712724e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d1f6e06bc2f112c4ec3a4c3f68351878 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d20d83fd7ffa378b1b2b901786d640f3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d38c7c3aa1e72b55769ccb3607641ef4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d6b85d8b0b5c569388b89e56e9f6fed7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d982412def520c434e2240eae6d29cf2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/df048a8b0897b9c04acdf59c8f95b18f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/df600f50f002512c95d93bcfbab891ed +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e6d6b8bde546349764be7b44ffcf5807 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/eb25265794d2f7afd1684779d84efdac +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ee8826b12b7d9bfd717df950b58f82ab +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ef9824789c6ed3483590e0564a12e1d1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fc7201c6cbef32453aa4175c520c8eae +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/17c571144b4e44da39bddb2d2c412414 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/36341e42f23669574fa1027d0958ff3e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/55b7b76605fdffe31d737d4ac1f1ef7b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5ac98782fe3dfd0a766f75ce1801f0a0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/680381170dc160e358fc28076ea6886c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6ad7acc9a22fe2a67ec24a1fc866c20e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6e4d5b32cc444226f6597198994ccd5e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7a50a9e605754e99783de95715b976b0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8aa4c7aabff23c8089d41e9e54193483 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b2401118729720034b6f3eda0b4c5025 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cb0065359d3b5b296f71d673f4b276e9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d1f6e06bc2f112c4ec3a4c3f68351878 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d6b85d8b0b5c569388b89e56e9f6fed7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d982412def520c434e2240eae6d29cf2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/df048a8b0897b9c04acdf59c8f95b18f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e6d6b8bde546349764be7b44ffcf5807 +0 -0
- data/test/web_console/exception_extention_test.rb +16 -0
- data/test/web_console/repl_session_test.rb +32 -0
- data/test/web_console/repl_test.rb +26 -0
- metadata +191 -58
- data/app/assets/javascripts/web_console/application.js +0 -1
- data/app/assets/stylesheets/web_console/console_sessions.css.erb +0 -6
- data/app/controllers/web_console/application_controller.rb +0 -13
- data/app/controllers/web_console/console_sessions_controller.rb +0 -43
- data/app/helpers/web_console/application_helper.rb +0 -4
- data/app/helpers/web_console/console_session_helper.rb +0 -4
- data/app/models/web_console/console_session.rb +0 -96
- data/app/views/layouts/web_console/application.html.erb +0 -14
- data/app/views/web_console/console_sessions/index.html.erb +0 -15
- data/config/routes.rb +0 -11
- data/lib/assets/javascripts/web-console.js +0 -1
- data/lib/web_console/colors.rb +0 -87
- data/lib/web_console/colors/light.rb +0 -24
- data/lib/web_console/colors/monokai.rb +0 -24
- data/lib/web_console/colors/solarized.rb +0 -47
- data/lib/web_console/colors/tango.rb +0 -24
- data/lib/web_console/colors/xterm.rb +0 -24
- data/lib/web_console/engine.rb +0 -77
- data/lib/web_console/slave.rb +0 -139
- data/test/controllers/web_console/console_sessions_controller_test.rb +0 -95
- data/test/helpers/web_console/console_session_helper_test.rb +0 -6
- data/test/models/console_session_test.rb +0 -58
- data/test/web_console/colors_test.rb +0 -58
- data/test/web_console/engine_test.rb +0 -136
- data/test/web_console/slave_test.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc7be22774c0ed19fa1cc197bb32a8289078f9d7
|
4
|
+
data.tar.gz: c97418fb52eebab0ed839e4889e4154a0aeb48f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5edfba9b1fd714b835609e9534ba89fcb2cc7bca5c505ac5a4368e6e1218a295b5ddb129c251299a117a2976660ffef69ab2b82be28778ed805459c978a2cc41
|
7
|
+
data.tar.gz: 02cc4186912594113ed78a3eaf88e8f5e9ffa1bd31cbf842087de4c7cd4360d4776d04308432062c2e94c82072eb653ef63c51137ca845642db139fa83b03567
|
data/README.markdown
CHANGED
@@ -4,23 +4,19 @@
|
|
4
4
|
<a href=https://github.com/rails/web-console/tree/v0.2.0>v0.2.0</a>
|
5
5
|
<a href=https://github.com/rails/web-console/tree/v0.3.0>v0.3.0</a>
|
6
6
|
<a href=https://github.com/rails/web-console/tree/v0.4.0>v0.4.0</a>
|
7
|
+
<a href=https://github.com/rails/web-console/tree/v1.0.4>v1.0.4</a>
|
7
8
|
</p>
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
offer. However, sometimes you can't easily access it, or maybe you want to
|
14
|
-
share it with a coworker without configuring remote desktop server.
|
10
|
+
<p align=center>
|
11
|
+
<em>Web Console is going through an overhaul, if you are looking for a stable
|
12
|
+
version documentation, checkout the links above.</em>
|
13
|
+
</p>
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
let's you evaluate Ruby code, there are a lot of those. Its a [VT100]
|
19
|
-
compatible terminal, running `rails console`.
|
15
|
+
Web Console [![Travis](https://travis-ci.org/rails/web-console.png)](https://travis-ci.org/rails/web-console)
|
16
|
+
===========
|
20
17
|
|
21
|
-
|
18
|
+
Web Console is a debugging console for you Rails application. It is launched whenever an error occurs or manually by using the console helper.
|
22
19
|
|
23
|
-
You can see _Web Console_ in action at this [video].
|
24
20
|
|
25
21
|
Requirements
|
26
22
|
------------
|
@@ -29,261 +25,44 @@ _Web Console_ has been tested on the following rubies.
|
|
29
25
|
|
30
26
|
* _MRI Ruby_ 2.0.0
|
31
27
|
* _MRI Ruby_ 1.9.3
|
32
|
-
* _JRuby_ 1.7.4
|
33
28
|
|
34
|
-
|
29
|
+
_Web Console_ is built explicitly for _Rails 4_.
|
35
30
|
|
36
|
-
|
37
|
-
|
31
|
+
Dependencies
|
32
|
+
------------
|
33
|
+
|
34
|
+
Web Console is bundled with `bindings_of_caller`. Because of the dependency, the gem only works on MRI Ruby at the moment.
|
38
35
|
|
39
36
|
Installation
|
40
37
|
------------
|
41
38
|
|
42
|
-
|
43
|
-
|
44
|
-
```ruby
|
45
|
-
group :development do
|
46
|
-
gem 'web-console'
|
47
|
-
end
|
48
|
-
```
|
39
|
+
Add the `web-console` gem to your Gemfile. Be sure to use the master branch version for now:
|
49
40
|
|
50
|
-
|
51
|
-
restart your server for the _Web Console_ to take affect.
|
41
|
+
gem 'web-console', git: 'git://github.com/rails/web-console
|
52
42
|
|
53
|
-
By default, it should be available in your development environment under
|
54
|
-
`/console`. The route is not automatically mounted in a production environment
|
55
|
-
and we strongly encourage you to keep it that way.
|
56
43
|
|
57
|
-
|
44
|
+
Use Cases
|
58
45
|
-------------
|
59
46
|
|
60
|
-
|
61
|
-
> responsibility.
|
62
|
-
>
|
63
|
-
> -- <cite>Franklin D. Roosevelt</cite>
|
64
|
-
|
65
|
-
_Web Console_ is a powerful tool. It allows you to execute arbitrary code on
|
66
|
-
the server, so you should be very careful, who you give access to it.
|
67
|
-
|
68
|
-
### config.web_console.whitelisted_ips
|
69
|
-
|
70
|
-
By default, only requests coming from `127.0.0.1` are allowed.
|
71
|
-
|
72
|
-
`config.web_console.whitelisted_ips` lets you control which IP's have access to
|
73
|
-
the console.
|
74
|
-
|
75
|
-
Let's say you want to share your console with just that one roommate, you like
|
76
|
-
and his/her IP is `192.168.0.100`.
|
77
|
-
|
78
|
-
```ruby
|
79
|
-
class Application < Rails::Application
|
80
|
-
config.web_console.whitelisted_ips = %w( 127.0.0.1 192.168.0.100 )
|
81
|
-
end
|
82
|
-
```
|
83
|
-
|
84
|
-
From the example, you can guess that `config.web_console.whitelisted_ips`
|
85
|
-
accepts an array of ip addresses, provided as strings. An important thing to
|
86
|
-
note here is that, we won't push `127.0.0.1` if you manually set the option!
|
87
|
-
|
88
|
-
Now let's assume you like all of your roommates. Instead of enumerating their
|
89
|
-
IP's, you can whitelist the whole private network. Now every time their IP's
|
90
|
-
change, you'll have them covered.
|
91
|
-
|
92
|
-
```ruby
|
93
|
-
class Application < Rails::Application
|
94
|
-
config.web_console.whitelisted_ips = '192.168.0.0/16'
|
95
|
-
end
|
96
|
-
```
|
97
|
-
|
98
|
-
You can see that `config.web_console.whitelisted_ips` accepts plains strings
|
99
|
-
too. More than that, they can cover whole networks.
|
100
|
-
|
101
|
-
Again, note that this network doesn't allow `127.0.0.1`. If you want to access
|
102
|
-
the console, you have to do so from it's external IP or add `127.0.0.1` to the
|
103
|
-
mix.
|
104
|
-
|
105
|
-
### config.web_console.default_mount_path
|
106
|
-
|
107
|
-
By default, the console will be automatically mounted on `/console`.
|
108
|
-
|
109
|
-
_(This happens only in the development and test environments!)_.
|
110
|
-
|
111
|
-
Say you want to mount the console to `/debug`, so you can more easily remember
|
112
|
-
where to go, when your application needs debugging.
|
113
|
-
|
114
|
-
```ruby
|
115
|
-
class Application < Rails::Application
|
116
|
-
config.web_console.default_mount_path = '/debug'
|
117
|
-
end
|
118
|
-
```
|
119
|
-
|
120
|
-
### config.web_console.automount
|
121
|
-
|
122
|
-
If you want to explicitly mount `WebConsole::Engine`, you can prevent the
|
123
|
-
automatic mount by setting this option to `false`.
|
124
|
-
|
125
|
-
### config.web_console.command
|
126
|
-
|
127
|
-
By default, _Web Console_ will run `Rails.root.join('bin/rails console)` to
|
128
|
-
spawn you a fresh Rails console. If the relative `bin/rails` does not exist, it
|
129
|
-
doesn't exist, `rails console` will be run.
|
130
|
-
|
131
|
-
One of the advantages of being a [VT100] emulator is that _Web Console_ can run
|
132
|
-
most of your terminal applications.
|
47
|
+
### Debug when an error happens
|
133
48
|
|
134
|
-
|
135
|
-
run [`login`][login] instead to let users sign into the host system.
|
49
|
+
Web Console is launched automatically in the default Rails error page. It's easy to inspect the stack trace and execute Ruby code in the stack trace's bindings.
|
136
50
|
|
137
|
-
|
138
|
-
class Application < Rails::Application
|
139
|
-
# You have to run /bin/login as root. That should worry you and you may work
|
140
|
-
# around it by running ssh connecting to the same machine.
|
141
|
-
config.web_console.command = 'sudo /bin/login'
|
142
|
-
end
|
143
|
-
```
|
51
|
+
![image](https://cloud.githubusercontent.com/assets/705116/3825943/a010af92-1d5a-11e4-84c2-4ed0ba367f4e.gif)
|
144
52
|
|
145
|
-
|
53
|
+
### Inspect view and controller binding
|
146
54
|
|
147
|
-
|
148
|
-
traffic, otherwise all the input (including the negotiated username and
|
149
|
-
password) can be easily sniffed!**
|
55
|
+
In your view, drop `<%= console %>` anywhere to launch the console and execute code in the view binding. A helper for running the console in the controller binding is under development.
|
150
56
|
|
151
|
-
|
152
|
-
|
153
|
-
By default, the _Web Console_ terminal will report itself as `xterm-color`. You
|
154
|
-
can override this option to change that.
|
155
|
-
|
156
|
-
### config.web_console.timeout
|
157
|
-
|
158
|
-
You may have noticed that _Web Console_ client sends a lot of requests to the
|
159
|
-
server. And by a lot, we really mean, **a lot** _(every few milliseconds)_.
|
160
|
-
We do this since we can't reliably predict when the output of your command
|
161
|
-
execution will come available, so we poll for it.
|
162
|
-
|
163
|
-
This option control how much will the server wait on the process output pipe
|
164
|
-
for input, before signalling the client to try again.
|
165
|
-
|
166
|
-
Maybe some day Web Sockets or SSE can be used for more efficient communication.
|
167
|
-
Until that day, you can use long-polling. To enable it, use [Puma] as your
|
168
|
-
development server and add the following to your configuration.
|
169
|
-
|
170
|
-
```ruby
|
171
|
-
class Application < Rails::Application
|
172
|
-
# You have to explicitly enable the concurrency, as in development mode,
|
173
|
-
# the falsy config.cache_classes implies no concurrency support.
|
174
|
-
#
|
175
|
-
# The concurrency is enabled by removing the Rack::Lock middleware, which
|
176
|
-
# wraps each request in a mutex, effectively making the request handling
|
177
|
-
# synchronous.
|
178
|
-
config.allow_concurrency = true
|
179
|
-
|
180
|
-
# For long-polling, 45 seconds timeout for the development server seems
|
181
|
-
# reasonable. You may want to experiment with the value.
|
182
|
-
config.web_console.timeout = 45.seconds
|
183
|
-
end
|
184
|
-
```
|
185
|
-
|
186
|
-
Styling
|
187
|
-
-------
|
188
|
-
|
189
|
-
If you would like to style the terminal a bit different than the default
|
190
|
-
appearance, you can do so with the following options.
|
191
|
-
|
192
|
-
### config.web_console.style.colors
|
193
|
-
|
194
|
-
_Web Console_ supports up to 256 color themes, though most of the common
|
195
|
-
terminal themes are usually just 16 colors.
|
196
|
-
|
197
|
-
The default color theme is a white-on-black theme called `light`. For
|
198
|
-
different appearance you may want to experiment with the other included color
|
199
|
-
themes.
|
200
|
-
|
201
|
-
- `monokai` _the default Sublime Text colors_
|
202
|
-
- `solarized_dark` _light version of the common solarized colors_
|
203
|
-
- `solarized_light` _dark version of the common solarized colors_
|
204
|
-
- `tango` _theme based on the tango colors_
|
205
|
-
- `xterm` _the standard xterm theme_
|
206
|
-
|
207
|
-
If you would like to use a custom theme, you may do so with the following
|
208
|
-
syntax.
|
209
|
-
|
210
|
-
```ruby
|
211
|
-
class Application < Rails::Application
|
212
|
-
# First, you have to define and register your custom color theme. Each color
|
213
|
-
# theme is mapped to a name.
|
214
|
-
WebConsole::Colors.register_theme(:custom) do |c|
|
215
|
-
# The most common color themes are the 16 colors one. They are built from 3
|
216
|
-
# parts.
|
217
|
-
|
218
|
-
# 8 darker colors.
|
219
|
-
c.add '#000000'
|
220
|
-
c.add '#cd0000'
|
221
|
-
c.add '#00cd00'
|
222
|
-
c.add '#cdcd00'
|
223
|
-
c.add '#0000ee'
|
224
|
-
c.add '#cd00cd'
|
225
|
-
c.add '#00cdcd'
|
226
|
-
c.add '#e5e5e5'
|
227
|
-
|
228
|
-
# 8 lighter colors.
|
229
|
-
c.add '#7f7f7f'
|
230
|
-
c.add '#ff0000'
|
231
|
-
c.add '#00ff00'
|
232
|
-
c.add '#ffff00'
|
233
|
-
c.add '#5c5cff'
|
234
|
-
c.add '#ff00ff'
|
235
|
-
c.add '#00ffff'
|
236
|
-
c.add '#ffffff'
|
237
|
-
|
238
|
-
# Background and foreground colors.
|
239
|
-
c.background '#ffffff'
|
240
|
-
c.foreground '#000000'
|
241
|
-
end
|
242
|
-
|
243
|
-
# Now you have to tell Web Console to actually use it.
|
244
|
-
config.web_console.style.colors = :custom
|
245
|
-
end
|
246
|
-
```
|
247
|
-
|
248
|
-
### config.web_console.style.font
|
249
|
-
|
250
|
-
You may also change the font, which is following the CSS font property syntax.
|
251
|
-
By default it is `large DejaVu Sans Mono, Liberation Mono, monospace`.
|
252
|
-
|
253
|
-
Trial
|
254
|
-
-----
|
255
|
-
|
256
|
-
If you just want to try the web-console, without having to go through the
|
257
|
-
trouble of installing it, we provide a [Docker] container that does that for
|
258
|
-
you.
|
259
|
-
|
260
|
-
To try it, install [Docker] first and then paste the following snippet in your
|
261
|
-
shell.
|
262
|
-
|
263
|
-
```bash
|
264
|
-
docker build -t rails/web-console github.com/rails/web-console && docker run -i -t rails/web-console
|
265
|
-
```
|
57
|
+
![image](https://cloud.githubusercontent.com/assets/705116/3825939/7e284de0-1d5a-11e4-9896-81465a38da76.gif)
|
266
58
|
|
267
59
|
FAQ
|
268
60
|
---
|
269
61
|
|
270
|
-
###
|
271
|
-
|
272
|
-
**TL;DR** Give it a bit of time, it will load.
|
273
|
-
|
274
|
-
While spawning processes is relatively cheap on _MRI_, this is not the case in
|
275
|
-
_JRuby_. Spawning another process is slow. Spawning another **JRuby** process
|
276
|
-
is even slower. Read more about the problem at the _JRuby_ [wiki].
|
62
|
+
### Is there any plan to support JRuby and Rubinius?
|
277
63
|
|
278
|
-
|
64
|
+
`bindings_of_caller` only works on MRI Ruby at the moment. There's a plan to make Web Console work with JRuby and Rubinius, but most likely without the ability to navigate exception backtrace.
|
279
65
|
|
280
|
-
|
281
|
-
`rake tmp:cache:clear` to clear those up.
|
66
|
+
### How to get local and instance variables of a binding in the console?
|
282
67
|
|
283
|
-
|
284
|
-
[Puma]: http://puma.io/
|
285
|
-
[VT100]: http://en.wikipedia.org/wiki/VT100
|
286
|
-
[login]: http://linux.die.net/man/1/login
|
287
|
-
[video]: http://www.youtube.com/watch?v=zjuJRXCLkHk
|
288
|
-
[web-console-rails3]: https://github.com/gsamokovarov/web-console-rails3
|
289
|
-
[wiki]: https://github.com/jruby/jruby/wiki/Improving-startup-time#avoid-spawning-sub-rubies
|
68
|
+
The console executes Ruby code, and therefore, invoking `instance_variables` and `local_variables` will give you what you want.
|
@@ -0,0 +1,115 @@
|
|
1
|
+
module ActionDispatch
|
2
|
+
class DebugExceptions
|
3
|
+
RESCUES_TEMPLATE_PATH.replace(File.expand_path('../templates', __FILE__))
|
4
|
+
|
5
|
+
def call(env)
|
6
|
+
request = Request.new(env)
|
7
|
+
|
8
|
+
if request.put? && m = env["PATH_INFO"].match(%r{/repl_sessions/(?<id>.+?)\z})
|
9
|
+
update_repl_session(m[:id], request.params[:input])
|
10
|
+
elsif request.post? && m = env["PATH_INFO"].match(%r{/repl_sessions/(?<id>.+?)/trace\z})
|
11
|
+
change_stack_trace(m[:id], request.params[:frame_id])
|
12
|
+
else
|
13
|
+
middleware_call(env)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def middleware_call(env)
|
18
|
+
_, headers, body = response = @app.call(env)
|
19
|
+
|
20
|
+
if headers['X-Cascade'] == 'pass'
|
21
|
+
body.close if body.respond_to?(:close)
|
22
|
+
raise ActionController::RoutingError, "No route matches [#{env['REQUEST_METHOD']}] #{env['PATH_INFO'].inspect}"
|
23
|
+
end
|
24
|
+
|
25
|
+
response
|
26
|
+
rescue Exception => exception
|
27
|
+
raise exception if env['action_dispatch.show_exceptions'] == false
|
28
|
+
render_exception(env, exception)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def update_repl_session(id, input)
|
34
|
+
console_session = WebConsole::REPLSession.find(id)
|
35
|
+
response = console_session.save({ input: input })
|
36
|
+
[200, { "Content-Type" => "text/plain; charset=utf-8" }, [response.to_json]]
|
37
|
+
end
|
38
|
+
|
39
|
+
def change_stack_trace(id, frame_id)
|
40
|
+
console_session = WebConsole::REPLSession.find(id)
|
41
|
+
binding = console_session.binding_stack[frame_id.to_i]
|
42
|
+
console_session.binding = binding
|
43
|
+
[200, { "Content-Type" => "text/plain; charset=utf-8" }, [JSON.dump("success")]]
|
44
|
+
end
|
45
|
+
|
46
|
+
def render_exception(env, exception)
|
47
|
+
if exception.respond_to?(:original_exception) && exception.original_exception
|
48
|
+
exception = exception.original_exception
|
49
|
+
end
|
50
|
+
|
51
|
+
wrapper = ExceptionWrapper.new(env, exception)
|
52
|
+
traces = traces_from_wrapper(wrapper)
|
53
|
+
extract_sources = wrapper.extract_sources
|
54
|
+
console_session = WebConsole::REPLSession.create(
|
55
|
+
binding: binding_from_exception(exception),
|
56
|
+
binding_stack: exception.__web_console_bindings_stack
|
57
|
+
)
|
58
|
+
log_error(env, wrapper)
|
59
|
+
|
60
|
+
if env['action_dispatch.show_detailed_exceptions']
|
61
|
+
request = Request.new(env)
|
62
|
+
template = ActionView::Base.new([RESCUES_TEMPLATE_PATH],
|
63
|
+
request: request,
|
64
|
+
exception: wrapper.exception,
|
65
|
+
application_trace: traces[:application_trace],
|
66
|
+
framework_trace: traces[:framework_trace],
|
67
|
+
full_trace: traces[:full_trace],
|
68
|
+
routes_inspector: routes_inspector(exception),
|
69
|
+
extract_sources: extract_sources,
|
70
|
+
console_session: console_session
|
71
|
+
)
|
72
|
+
file = "rescues/#{wrapper.rescue_template}"
|
73
|
+
|
74
|
+
if request.xhr?
|
75
|
+
body = template.render(template: file, layout: false, formats: [:text])
|
76
|
+
format = "text/plain"
|
77
|
+
else
|
78
|
+
body = template.render(template: file, layout: 'rescues/layout')
|
79
|
+
format = "text/html"
|
80
|
+
end
|
81
|
+
|
82
|
+
[wrapper.status_code, {'Content-Type' => "#{format}; charset=#{Response.default_charset}", 'Content-Length' => body.bytesize.to_s}, [body]]
|
83
|
+
else
|
84
|
+
raise exception
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Augment the exception traces by providing ids for all unique stack frame
|
89
|
+
def traces_from_wrapper(wrapper)
|
90
|
+
id_counter = 0
|
91
|
+
|
92
|
+
application_trace = wrapper.application_trace.map do |trace|
|
93
|
+
prev = id_counter
|
94
|
+
id_counter += 1
|
95
|
+
{ id: prev, trace: trace }
|
96
|
+
end
|
97
|
+
|
98
|
+
framework_trace = wrapper.framework_trace.map do |trace|
|
99
|
+
prev = id_counter
|
100
|
+
id_counter += 1
|
101
|
+
{ id: prev, trace: trace }
|
102
|
+
end
|
103
|
+
|
104
|
+
{
|
105
|
+
application_trace: application_trace,
|
106
|
+
framework_trace: framework_trace,
|
107
|
+
full_trace: application_trace + framework_trace
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
def binding_from_exception(exception)
|
112
|
+
exception.__web_console_bindings_stack[0]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ActionDispatch
|
2
|
+
class ExceptionWrapper
|
3
|
+
def extract_sources
|
4
|
+
exception.backtrace.map do |trace|
|
5
|
+
file, line = trace.split(":")
|
6
|
+
line_number = line.to_i
|
7
|
+
{
|
8
|
+
code: source_fragment(file, line_number),
|
9
|
+
file: file,
|
10
|
+
line_number: line_number
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|