web-console 2.1.3 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.markdown +45 -0
  3. data/README.markdown +26 -6
  4. data/Rakefile +37 -0
  5. data/lib/web_console/extensions.rb +2 -1
  6. data/lib/web_console/integration/cruby.rb +2 -1
  7. data/lib/web_console/integration/rubinius.rb +2 -1
  8. data/lib/web_console/railtie.rb +19 -1
  9. data/lib/web_console/session.rb +4 -3
  10. data/lib/web_console/templates/_inner_console_markup.html.erb +8 -3
  11. data/lib/web_console/templates/console.js.erb +169 -46
  12. data/lib/web_console/templates/error_page.js.erb +2 -15
  13. data/lib/web_console/templates/main.js.erb +1 -24
  14. data/lib/web_console/templates/style.css.erb +22 -9
  15. data/lib/web_console/tracer.rb +11 -0
  16. data/lib/web_console/version.rb +1 -1
  17. metadata +5 -155
  18. data/test/dummy/README.rdoc +0 -28
  19. data/test/dummy/Rakefile +0 -6
  20. data/test/dummy/app/assets/javascripts/application.js +0 -13
  21. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  22. data/test/dummy/app/controllers/application_controller.rb +0 -5
  23. data/test/dummy/app/controllers/controller_helper_test_controller.rb +0 -7
  24. data/test/dummy/app/controllers/exception_test_controller.rb +0 -15
  25. data/test/dummy/app/controllers/helper_error_controller.rb +0 -4
  26. data/test/dummy/app/controllers/helper_test_controller.rb +0 -5
  27. data/test/dummy/app/controllers/tests_controller.rb +0 -16
  28. data/test/dummy/app/helpers/application_helper.rb +0 -2
  29. data/test/dummy/app/views/controller_helper_test/index.html.erb +0 -1
  30. data/test/dummy/app/views/exception_test/xhr.html.erb +0 -1
  31. data/test/dummy/app/views/helper_error/index.html.erb +0 -2
  32. data/test/dummy/app/views/helper_test/index.html.erb +0 -220
  33. data/test/dummy/app/views/layouts/application.html.erb +0 -16
  34. data/test/dummy/bin/bundle +0 -3
  35. data/test/dummy/bin/rails +0 -4
  36. data/test/dummy/bin/rake +0 -4
  37. data/test/dummy/config.ru +0 -4
  38. data/test/dummy/config/application.rb +0 -19
  39. data/test/dummy/config/boot.rb +0 -5
  40. data/test/dummy/config/database.yml +0 -25
  41. data/test/dummy/config/environment.rb +0 -5
  42. data/test/dummy/config/environments/development.rb +0 -29
  43. data/test/dummy/config/environments/production.rb +0 -80
  44. data/test/dummy/config/environments/test.rb +0 -34
  45. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  46. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  47. data/test/dummy/config/initializers/inflections.rb +0 -16
  48. data/test/dummy/config/initializers/mime_types.rb +0 -5
  49. data/test/dummy/config/initializers/secret_token.rb +0 -12
  50. data/test/dummy/config/initializers/session_store.rb +0 -3
  51. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  52. data/test/dummy/config/locales/en.yml +0 -23
  53. data/test/dummy/config/routes.rb +0 -15
  54. data/test/dummy/db/schema.rb +0 -16
  55. data/test/dummy/db/test.sqlite3 +0 -0
  56. data/test/dummy/log/test.log +0 -808
  57. data/test/dummy/public/404.html +0 -58
  58. data/test/dummy/public/422.html +0 -58
  59. data/test/dummy/public/500.html +0 -57
  60. data/test/dummy/public/favicon.ico +0 -0
  61. data/test/dummy/tmp/cache/assets/test/sprockets/0c9b99b1b975b36a5b686845ae729db3 +0 -0
  62. data/test/dummy/tmp/cache/assets/test/sprockets/12e9f58adcf819cf65fd68b6859a438f +0 -0
  63. data/test/dummy/tmp/cache/assets/test/sprockets/1fd6abead3df36a4e4a2cb042a551b39 +0 -0
  64. data/test/dummy/tmp/cache/assets/test/sprockets/33b5eb81b5aaaa1e6dd5dcb6517792b4 +0 -0
  65. data/test/dummy/tmp/cache/assets/test/sprockets/3e460b2e021085f88b5597b38d194932 +0 -0
  66. data/test/dummy/tmp/cache/assets/test/sprockets/52f04b2ea6e461f4661b6d0be393fa94 +0 -0
  67. data/test/dummy/tmp/cache/assets/test/sprockets/688c344c2919f882338f06c5daaea209 +0 -0
  68. data/test/dummy/tmp/cache/assets/test/sprockets/7f079298e19bbef40a5d6a37dc03033a +0 -0
  69. data/test/dummy/tmp/cache/assets/test/sprockets/91aa709f89e465f58056fabe5f75eef4 +0 -0
  70. data/test/dummy/tmp/cache/assets/test/sprockets/95f4e4e5217aec9f71b2c1a65a9a9231 +0 -0
  71. data/test/dummy/tmp/cache/assets/test/sprockets/9c41be9b6625756fbb6d05b7665dd911 +0 -0
  72. data/test/dummy/tmp/cache/assets/test/sprockets/a95f64d41fcf8244b8f5b84a55f07822 +0 -0
  73. data/test/dummy/tmp/cache/assets/test/sprockets/c5e6bf1efd5929bee63e28ad7c9f6f83 +0 -0
  74. data/test/dummy/tmp/cache/assets/test/sprockets/d863259e9eeca657a1624135cfe24446 +0 -0
  75. data/test/dummy/tmp/cache/assets/test/sprockets/e1d2fc4601b6423ec8a42415ee05dd14 +0 -0
  76. data/test/dummy/tmp/cache/assets/test/sprockets/e82616536a759c2e87d703adc77d65da +0 -0
  77. data/test/support/scenarios/bad_custom_error_scenario.rb +0 -17
  78. data/test/support/scenarios/basic_nested_scenario.rb +0 -15
  79. data/test/support/scenarios/custom_error_scenario.rb +0 -11
  80. data/test/support/scenarios/eval_nested_scenario.rb +0 -15
  81. data/test/support/scenarios/flat_scenario.rb +0 -9
  82. data/test/support/scenarios/reraised_scenario.rb +0 -21
  83. data/test/test_helper.rb +0 -78
  84. data/test/web_console/evaluator_test.rb +0 -73
  85. data/test/web_console/extensions_test.rb +0 -28
  86. data/test/web_console/helper_test.rb +0 -76
  87. data/test/web_console/integration_test.rb +0 -47
  88. data/test/web_console/middleware_test.rb +0 -116
  89. data/test/web_console/railtie_test.rb +0 -99
  90. data/test/web_console/request_test.rb +0 -82
  91. data/test/web_console/session_test.rb +0 -59
  92. data/test/web_console/whiny_request_test.rb +0 -33
  93. data/test/web_console/whitelist_test.rb +0 -43
@@ -1,58 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/404.html -->
52
- <div class="dialog">
53
- <h1>The page you were looking for doesn't exist.</h1>
54
- <p>You may have mistyped the address or the page may have moved.</p>
55
- </div>
56
- <p>If you are the application owner check the logs for more information.</p>
57
- </body>
58
- </html>
@@ -1,58 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/422.html -->
52
- <div class="dialog">
53
- <h1>The change you wanted was rejected.</h1>
54
- <p>Maybe you tried to change something you didn't have access to.</p>
55
- </div>
56
- <p>If you are the application owner check the logs for more information.</p>
57
- </body>
58
- </html>
@@ -1,57 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/500.html -->
52
- <div class="dialog">
53
- <h1>We're sorry, but something went wrong.</h1>
54
- </div>
55
- <p>If you are the application owner check the logs for more information.</p>
56
- </body>
57
- </html>
File without changes
@@ -1,17 +0,0 @@
1
- module WebConsole
2
- class BadCustomErrorScenario
3
- class Error < StandardError
4
- def initialize(*)
5
- # Bad exceptions are exceptions that don't call super in there
6
- # #initialize method.
7
- end
8
- end
9
-
10
- def call
11
- raise Error
12
- rescue => exc
13
- exc
14
- end
15
- end
16
- end
17
-
@@ -1,15 +0,0 @@
1
- module WebConsole
2
- class BasicNestedScenario
3
- def call
4
- raise_an_error
5
- rescue => exc
6
- exc
7
- end
8
-
9
- private
10
-
11
- def raise_an_error
12
- raise
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- module WebConsole
2
- class CustomErrorScenario
3
- Error = Class.new(StandardError)
4
-
5
- def call
6
- raise Error
7
- rescue => exc
8
- exc
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- module WebConsole
2
- class EvalNestedScenario
3
- def call
4
- tap { raise_an_error_in_eval }
5
- rescue => exc
6
- exc
7
- end
8
-
9
- private
10
-
11
- def raise_an_error_in_eval
12
- eval 'raise', binding, __FILE__, __LINE__
13
- end
14
- end
15
- end
@@ -1,9 +0,0 @@
1
- module WebConsole
2
- class FlatScenario
3
- def call
4
- raise
5
- rescue => exc
6
- exc
7
- end
8
- end
9
- end
@@ -1,21 +0,0 @@
1
- module WebConsole
2
- class ReraisedScenario
3
- def call
4
- reraise_an_error
5
- rescue => exc
6
- exc
7
- end
8
-
9
- private
10
-
11
- def raise_an_error_in_eval
12
- method_that_raises
13
- rescue => exc
14
- raise exc
15
- end
16
-
17
- def method_that_raises
18
- raise
19
- end
20
- end
21
- end
@@ -1,78 +0,0 @@
1
- case RUBY_ENGINE
2
- when 'ruby', 'rbx'
3
- require 'simplecov'
4
- SimpleCov.start 'rails'
5
- end
6
-
7
- # Configure Rails Environment
8
- ENV["RAILS_ENV"] = "test"
9
-
10
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
11
- require "rails/test_help"
12
-
13
- Rails.backtrace_cleaner.remove_silencers!
14
-
15
- # Load support files
16
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
17
-
18
- # rails-dom-testing assertions doesn't like the JavaScript we inject into the page.
19
- module SilenceRailsDomTesting
20
- def assert_select(*)
21
- silence_warnings { super }
22
- end
23
- end
24
-
25
- # Allows you to specify test to run only on specific Ruby platforms.
26
- #
27
- # Example:
28
- #
29
- # test 'CRuby specific feature', only: :ruby
30
- # test 'CRuby and JRuby specific feature', only: %w(ruby jruby)
31
- #
32
- # If the :only option isn't present, the test is defined for all the platforms.
33
- module PlatformSpecificTestMacro
34
- def test(name, options = {})
35
- platforms = Array(options[:only]).map(&:to_s)
36
-
37
- if platforms.blank? || RUBY_ENGINE.in?(platforms)
38
- super(name)
39
- end
40
- end
41
- end
42
-
43
- ActiveSupport::TestCase.class_eval do
44
- extend PlatformSpecificTestMacro
45
- end
46
-
47
- ActionDispatch::IntegrationTest.class_eval do
48
- include SilenceRailsDomTesting
49
- end
50
-
51
- # A copy of Kernel#capture in active_support/core_ext/kernel/reporting.rb as
52
- # its getting deprecated past 4.2. Its not thread safe, but I don't need it to
53
- # be in the tests
54
- def capture(stream)
55
- stream = stream.to_s
56
- captured_stream = Tempfile.new(stream)
57
- stream_io = eval("$#{stream}")
58
- origin_stream = stream_io.dup
59
- stream_io.reopen(captured_stream)
60
-
61
- yield
62
-
63
- stream_io.rewind
64
- return captured_stream.read
65
- ensure
66
- captured_stream.close
67
- captured_stream.unlink
68
- stream_io.reopen(origin_stream)
69
- end
70
-
71
- alias silence capture
72
-
73
- # Load fixtures from the engine
74
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
75
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
76
- end
77
-
78
- require 'mocha/mini_test'
@@ -1,73 +0,0 @@
1
- require 'test_helper'
2
-
3
- module WebConsole
4
- class EvaluatorTest < ActiveSupport::TestCase
5
- class TestError < StandardError
6
- def backtrace
7
- [
8
- "/web-console/lib/web_console/repl.rb:16:in `eval'",
9
- "/web-console/lib/web_console/repl.rb:16:in `eval'"
10
- ]
11
- end
12
- end
13
-
14
- class BadlyDefinedError < StandardError
15
- def backtrace
16
- nil
17
- end
18
- end
19
-
20
- setup do
21
- @repl1 = @repl = Evaluator.new
22
- @repl2 = Evaluator.new
23
- end
24
-
25
- test 'sending input returns the result as output' do
26
- assert_equal "=> 42\n", @repl.eval('foo = 42')
27
- end
28
-
29
- test 'preserves the session in the binding' do
30
- assert_equal "=> 42\n", @repl.eval('foo = 42')
31
- assert_equal "=> 50\n", @repl.eval('foo + 8')
32
- end
33
-
34
- test 'session preservation requires same bindings' do
35
- assert_equal "=> 42\n", @repl1.eval('foo = 42')
36
- assert_equal "=> 42\n", @repl2.eval('foo')
37
- end
38
-
39
- test 'formats exceptions similarly to IRB' do
40
- repl = Evaluator.new(binding)
41
-
42
- assert_equal <<-END.strip_heredoc, repl.eval("raise TestError, 'panic'")
43
- #{TestError.name}: panic
44
- \tfrom /web-console/lib/web_console/repl.rb:16:in `eval'
45
- \tfrom /web-console/lib/web_console/repl.rb:16:in `eval'
46
- END
47
- end
48
-
49
- test 'no backtrace is shown if exception backtrace is blank' do
50
- repl = Evaluator.new(binding)
51
-
52
- assert_equal <<-END.strip_heredoc, repl.eval("raise BadlyDefinedError")
53
- #{BadlyDefinedError.name}: #{BadlyDefinedError.name}
54
- END
55
- end
56
-
57
- test 'Evaluator callers are cleaned up of unneeded backtraces', only: :ruby do
58
- # Those have to be on the same line to get the same trace.
59
- repl, trace = Evaluator.new(binding), current_trace
60
-
61
- assert_equal <<-END.strip_heredoc, repl.eval("raise")
62
- RuntimeError:
63
- \tfrom #{trace}
64
- END
65
- end
66
-
67
- private
68
-
69
- def current_trace
70
- caller.first
71
- end
72
- end
73
- end