rack-webconsole 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc +1 -1
- data/.travis.yml +2 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +18 -10
- data/History +6 -0
- data/Readme.md +16 -3
- data/lib/rack/webconsole.rb +19 -3
- data/lib/rack/webconsole/asset_helpers.rb +15 -0
- data/lib/rack/webconsole/assets.rb +1 -1
- data/lib/rack/webconsole/repl.rb +4 -22
- data/lib/rack/webconsole/shell.rb +74 -0
- data/lib/rack/webconsole/version.rb +1 -1
- data/public/webconsole.css +4 -0
- data/public/webconsole.html +1 -1
- data/public/webconsole.js +47 -8
- data/rack-webconsole.gemspec +9 -3
- data/spec/rack/webconsole/asset_helpers_spec.rb +12 -0
- data/spec/rack/webconsole/assets_spec.rb +13 -1
- data/spec/rack/webconsole/repl_spec.rb +3 -3
- data/spec/rack/webconsole/shell_spec.rb +73 -0
- data/spec/rack/webconsole_spec.rb +9 -0
- metadata +85 -33
data/.gitignore
CHANGED
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm --create use ruby-1.9.
|
1
|
+
rvm --create use ruby-1.9.3@rack-webconsole
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,25 +1,33 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rack-webconsole (0.1.
|
5
|
-
|
4
|
+
rack-webconsole (0.1.3)
|
5
|
+
multi_json (~> 1.0.3)
|
6
6
|
rack
|
7
|
+
ripl (~> 0.5.1)
|
8
|
+
ripl-multi_line (~> 0.3.0)
|
7
9
|
|
8
10
|
GEM
|
9
11
|
remote: http://rubygems.org/
|
10
12
|
specs:
|
11
|
-
bluecloth (2.
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
bluecloth (2.2.0)
|
14
|
+
bond (0.4.1)
|
15
|
+
metaclass (0.0.1)
|
16
|
+
minitest (2.11.4)
|
17
|
+
mocha (0.10.5)
|
18
|
+
metaclass (~> 0.0.1)
|
19
|
+
multi_json (1.0.4)
|
15
20
|
purdytest (1.0.0)
|
16
21
|
minitest (~> 2.2)
|
17
|
-
rack (1.
|
18
|
-
rake (0.9.2)
|
19
|
-
|
22
|
+
rack (1.4.1)
|
23
|
+
rake (0.9.2.2)
|
24
|
+
ripl (0.5.1)
|
25
|
+
bond (~> 0.4.0)
|
26
|
+
ripl-multi_line (0.3.0)
|
27
|
+
ripl (>= 0.3.6)
|
28
|
+
yard (0.7.5)
|
20
29
|
|
21
30
|
PLATFORMS
|
22
|
-
java
|
23
31
|
ruby
|
24
32
|
|
25
33
|
DEPENDENCIES
|
data/History
CHANGED
data/Readme.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#rack-webconsole
|
1
|
+
#rack-webconsole [![Build Status](http://travis-ci.org/codegram/rack-webconsole.png)](http://travis-ci.org/codegram/rack-webconsole.png)
|
2
2
|
|
3
3
|
Rack-webconsole is a Rack-based interactive console (à la Rails console) in
|
4
4
|
your web application's frontend. That means you can interact with your
|
@@ -41,6 +41,13 @@ some configuration file):
|
|
41
41
|
Rack::Webconsole.inject_jquery = true
|
42
42
|
```
|
43
43
|
|
44
|
+
You can also change the javascript key_code used to start webconsole:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
# ` = 96 (default), ^ = 94, ç = 231 ... etc.
|
48
|
+
Rack::Webconsole.key_code = "231"
|
49
|
+
```
|
50
|
+
|
44
51
|
##Usage with Rails 3
|
45
52
|
|
46
53
|
If you are using Rails 3, you have no further steps to do. It works! To give
|
@@ -107,6 +114,12 @@ You can also build the documentation with the following command:
|
|
107
114
|
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself we can ignore when we pull)
|
108
115
|
* Send us a pull request. Bonus points for topic branches.
|
109
116
|
|
110
|
-
##
|
117
|
+
## Released under the MIT License
|
118
|
+
|
119
|
+
Copyright (c) 2011 Codegram.
|
120
|
+
|
121
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
122
|
+
|
123
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
111
124
|
|
112
|
-
|
125
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/rack/webconsole.rb
CHANGED
@@ -3,6 +3,7 @@ require 'rack/webconsole/repl'
|
|
3
3
|
require 'rack/webconsole/asset_helpers'
|
4
4
|
require 'rack/webconsole/assets'
|
5
5
|
require 'rack/webconsole/sandbox'
|
6
|
+
require 'rack/webconsole/shell'
|
6
7
|
|
7
8
|
require 'rack/webconsole/railtie' if defined?(Rails::Railtie)
|
8
9
|
|
@@ -24,21 +25,36 @@ module Rack
|
|
24
25
|
# variables and giving a true IRB-esque experience.
|
25
26
|
#
|
26
27
|
class Webconsole
|
27
|
-
@@
|
28
|
+
@@config = {:inject_jquery => false, :key_code => "96"}
|
28
29
|
|
29
30
|
class << self
|
30
31
|
# Returns whether the Asset injecter must inject JQuery or not.
|
31
32
|
#
|
32
33
|
# @return [Boolean] whether to inject JQuery or not.
|
33
34
|
def inject_jquery
|
34
|
-
@@inject_jquery
|
35
|
+
@@config[:inject_jquery]
|
35
36
|
end
|
36
37
|
|
37
38
|
# Sets whether the Asset injecter must inject JQuery or not.
|
38
39
|
#
|
39
40
|
# @param [Boolean] value whether to inject JQuery or not.
|
40
41
|
def inject_jquery=(value)
|
41
|
-
@@inject_jquery = value
|
42
|
+
@@config[:inject_jquery] = value
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns key code used to start web console.
|
46
|
+
#
|
47
|
+
# @return [String] key code used at keypress event to start web console.
|
48
|
+
def key_code
|
49
|
+
@@config[:key_code]
|
50
|
+
end
|
51
|
+
|
52
|
+
# Sets key code used to start web console.
|
53
|
+
#
|
54
|
+
# @param [String] value key code used at keypress event to start web console.
|
55
|
+
def key_code=(value)
|
56
|
+
value = value.to_s unless value.is_a?(String)
|
57
|
+
@@config[:key_code] = value
|
42
58
|
end
|
43
59
|
end
|
44
60
|
|
@@ -44,6 +44,21 @@ module Rack
|
|
44
44
|
'</script>'
|
45
45
|
end
|
46
46
|
|
47
|
+
# Inteprolates the given variables inside the javascrpt code
|
48
|
+
#
|
49
|
+
# @param [String] javascript The javascript code to insert the variables
|
50
|
+
# @param [Hash] variables A hash containing the variables names (as keys)
|
51
|
+
# and its values
|
52
|
+
#
|
53
|
+
# @return [String] the javascript code with the interpolated variables
|
54
|
+
def render(javascript, variables = {})
|
55
|
+
javascript_with_variables = javascript.dup
|
56
|
+
variables.each_pair do |variable, value|
|
57
|
+
javascript_with_variables.gsub!("$#{variable}", value)
|
58
|
+
end
|
59
|
+
javascript_with_variables
|
60
|
+
end
|
61
|
+
|
47
62
|
private
|
48
63
|
|
49
64
|
def asset(file)
|
data/lib/rack/webconsole/repl.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require '
|
2
|
+
require 'multi_json'
|
3
3
|
require 'digest/sha1'
|
4
4
|
|
5
5
|
module Rack
|
@@ -67,27 +67,9 @@ module Rack
|
|
67
67
|
|
68
68
|
return [status, headers, response] unless check_legitimate(req)
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
# Force conversion to symbols due to issues with lovely 1.8.7
|
74
|
-
boilerplate = local_variables.map(&:to_sym) + [:ls]
|
75
|
-
|
76
|
-
result = $sandbox.instance_eval """
|
77
|
-
result = (#{params['query']})
|
78
|
-
ls = (local_variables.map(&:to_sym) - [#{boilerplate.map(&:inspect).join(', ')}])
|
79
|
-
@locals ||= {}
|
80
|
-
@locals.update(ls.inject({}) do |hash, value|
|
81
|
-
hash.update({value => eval(value.to_s)})
|
82
|
-
end)
|
83
|
-
result
|
84
|
-
"""
|
85
|
-
|
86
|
-
result.inspect
|
87
|
-
rescue=>e
|
88
|
-
"Error: " + e.message
|
89
|
-
end
|
90
|
-
response_body = {:result => result}.to_json
|
70
|
+
$sandbox ||= Sandbox.new
|
71
|
+
hash = Shell.eval_query params['query']
|
72
|
+
response_body = MultiJson.encode(hash)
|
91
73
|
headers = {}
|
92
74
|
headers['Content-Type'] = 'application/json'
|
93
75
|
headers['Content-Length'] = response_body.bytesize.to_s
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'ripl'
|
2
|
+
|
3
|
+
class Rack::Webconsole
|
4
|
+
module Shell
|
5
|
+
def self.eval_query(query)
|
6
|
+
# Initialize ripl plugins
|
7
|
+
@before_loop_called ||= Ripl.shell.before_loop
|
8
|
+
|
9
|
+
Ripl.shell.input = query
|
10
|
+
Ripl.shell.loop_once
|
11
|
+
{}.tap do |hash|
|
12
|
+
hash[:result] = Ripl.shell.return_result
|
13
|
+
hash[:multi_line] = Ripl.shell.multi_line?
|
14
|
+
hash[:previous_multi_line] = Ripl.shell.previous_multi_line?
|
15
|
+
hash[:prompt] = Ripl.shell.previous_multi_line? ?
|
16
|
+
Ripl.config[:multi_line_prompt] : Ripl.config[:prompt]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# TODO: move to plugin
|
21
|
+
def multi_line?
|
22
|
+
@buffer.is_a?(Array)
|
23
|
+
end
|
24
|
+
|
25
|
+
def previous_multi_line?
|
26
|
+
@old_buffer.is_a?(Array)
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_input
|
30
|
+
@old_buffer = @buffer
|
31
|
+
history << @input
|
32
|
+
@input
|
33
|
+
end
|
34
|
+
|
35
|
+
def loop_eval(query)
|
36
|
+
# Force conversion to symbols due to issues with lovely 1.8.7
|
37
|
+
boilerplate = local_variables.map(&:to_sym) + [:ls, :result]
|
38
|
+
|
39
|
+
$sandbox.instance_eval """
|
40
|
+
result = (#{query})
|
41
|
+
ls = (local_variables.map(&:to_sym) - [#{boilerplate.map(&:inspect).join(', ')}])
|
42
|
+
@locals ||= {}
|
43
|
+
@locals.update(ls.inject({}) do |hash, value|
|
44
|
+
hash.update({value => eval(value.to_s)})
|
45
|
+
end)
|
46
|
+
result
|
47
|
+
"""
|
48
|
+
end
|
49
|
+
|
50
|
+
def print_eval_error(err)
|
51
|
+
@result = "Error: " + err.message
|
52
|
+
end
|
53
|
+
|
54
|
+
def return_result
|
55
|
+
@error_raised ? result : result.inspect
|
56
|
+
end
|
57
|
+
|
58
|
+
def print_result(result) end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Disable readline's #get_input
|
63
|
+
Ripl.config[:readline] = false
|
64
|
+
Ripl.config[:multi_line_prompt] = '|| '
|
65
|
+
Ripl.config[:prompt] = '>> '
|
66
|
+
Ripl.config[:irbrc] = false
|
67
|
+
# Let ripl users detect web shells
|
68
|
+
Ripl.config[:web] = true
|
69
|
+
|
70
|
+
Ripl::Shell.include Rack::Webconsole::Shell
|
71
|
+
# must come after Webconsole plugin
|
72
|
+
require 'ripl/multi_line'
|
73
|
+
|
74
|
+
at_exit { Ripl.shell.after_loop }
|
data/public/webconsole.css
CHANGED
data/public/webconsole.html
CHANGED
data/public/webconsole.js
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
(function($) {
|
2
|
+
|
3
|
+
var webconsole = {
|
4
|
+
history:[],
|
5
|
+
pointer:0,
|
6
|
+
query:$('#webconsole_query')
|
7
|
+
}
|
8
|
+
|
2
9
|
$('#rack-webconsole form').submit(function(e){
|
3
10
|
e.preventDefault();
|
4
11
|
});
|
@@ -12,30 +19,62 @@
|
|
12
19
|
);
|
13
20
|
};
|
14
21
|
|
22
|
+
// enter
|
15
23
|
if (event.which == 13) {
|
16
|
-
|
17
|
-
|
24
|
+
webconsole.history.push(webconsole.query.val());
|
25
|
+
webconsole.pointer = webconsole.history.length - 1;
|
18
26
|
$.ajax({
|
19
27
|
url: '/webconsole',
|
20
28
|
type: 'POST',
|
21
29
|
dataType: 'json',
|
22
|
-
data: ({query: query, token: "TOKEN"}),
|
30
|
+
data: ({query: webconsole.query.val(), token: "$TOKEN"}),
|
23
31
|
success: function (data) {
|
24
|
-
var
|
25
|
-
var
|
26
|
-
|
32
|
+
var query_class = data.previous_multi_line ? 'query_multiline' : 'query';
|
33
|
+
var result = "<div class='" + query_class + "'>" +
|
34
|
+
escapeHTML(data.prompt + webconsole.query.val()) + "</div>";
|
35
|
+
if (!data.multi_line) {
|
36
|
+
result += "<div class='result'>" + escapeHTML("=> " + data.result) + "</div>";
|
37
|
+
}
|
38
|
+
$("#rack-webconsole .results").append(result);
|
27
39
|
$("#rack-webconsole .results_wrapper").scrollTop(
|
28
40
|
$("#rack-webconsole .results").height()
|
29
41
|
);
|
30
|
-
|
42
|
+
webconsole.query.val('');
|
31
43
|
}
|
32
44
|
});
|
33
45
|
}
|
46
|
+
|
47
|
+
// up
|
48
|
+
if (event.which == 38) {
|
49
|
+
if (webconsole.pointer < 0) {
|
50
|
+
webconsole.query.val('');
|
51
|
+
} else {
|
52
|
+
if (webconsole.pointer == webconsole.history.length) {
|
53
|
+
webconsole.pointer = webconsole.history.length - 1;
|
54
|
+
}
|
55
|
+
webconsole.query.val(webconsole.history[webconsole.pointer]);
|
56
|
+
webconsole.pointer--;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
// down
|
61
|
+
if (event.which == 40) {
|
62
|
+
if (webconsole.pointer == webconsole.history.length) {
|
63
|
+
webconsole.query.val('');
|
64
|
+
} else {
|
65
|
+
if (webconsole.pointer < 0) {
|
66
|
+
webconsole.pointer = 0;
|
67
|
+
}
|
68
|
+
webconsole.query.val(webconsole.history[webconsole.pointer]);
|
69
|
+
webconsole.pointer++;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
34
73
|
});
|
35
74
|
|
36
75
|
$(document).ready(function() {
|
37
76
|
$(this).keypress(function(event) {
|
38
|
-
if (event.which ==
|
77
|
+
if (event.which == $KEY_CODE) {
|
39
78
|
$("#rack-webconsole").slideToggle('fast', function() {
|
40
79
|
if ($(this).is(':visible')) {
|
41
80
|
$("#rack-webconsole form input").focus();
|
data/rack-webconsole.gemspec
CHANGED
@@ -14,17 +14,23 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.rubyforge_project = "rack-webconsole"
|
15
15
|
|
16
16
|
s.add_runtime_dependency 'rack'
|
17
|
-
s.add_runtime_dependency '
|
17
|
+
s.add_runtime_dependency 'multi_json', '~> 1.0.3'
|
18
|
+
s.add_runtime_dependency 'ripl', '~> 0.5.1'
|
19
|
+
s.add_runtime_dependency 'ripl-multi_line', '~> 0.3.0'
|
18
20
|
|
19
21
|
s.add_development_dependency 'minitest'
|
20
22
|
s.add_development_dependency 'purdytest'
|
21
|
-
|
23
|
+
|
24
|
+
# Since we can't have a git dependency in gemspec, we specify this
|
25
|
+
# dependency directly in the Gemfile. Once a new mocha version is released,
|
26
|
+
# we should uncomment this line and remove mocha from the Gemfile.
|
27
|
+
# s.add_development_dependency 'mocha'
|
28
|
+
|
22
29
|
s.add_development_dependency 'yard'
|
23
30
|
s.add_development_dependency 'bluecloth'
|
24
31
|
s.add_development_dependency 'rake'
|
25
32
|
|
26
33
|
s.files = `git ls-files`.split("\n")
|
27
34
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
28
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
29
35
|
s.require_paths = ["lib"]
|
30
36
|
end
|
@@ -40,5 +40,17 @@ module Rack
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
describe '#render' do
|
44
|
+
it 'knows how to replace $ vars' do
|
45
|
+
asset_class = AssetClass.new
|
46
|
+
|
47
|
+
text = "test $test test $test"
|
48
|
+
asset_class.render(text, :test => "123").must_equal("test 123 test 123")
|
49
|
+
|
50
|
+
text = "test $var1 test $var2"
|
51
|
+
asset_class.render(text, :var1 => "123", :var2 => "321").must_equal("test 123 test 321")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
43
55
|
end
|
44
56
|
end
|
@@ -8,10 +8,22 @@ module Rack
|
|
8
8
|
it 'initializes with an app' do
|
9
9
|
@app = stub
|
10
10
|
@assets = Webconsole::Assets.new(@app)
|
11
|
-
|
12
11
|
@assets.instance_variable_get(:@app).must_equal @app
|
13
12
|
end
|
14
13
|
|
14
|
+
describe "#code" do
|
15
|
+
it 'injects the token and key_code' do
|
16
|
+
Webconsole::Repl.stubs(:token).returns('fake_generated_token')
|
17
|
+
Webconsole.key_code = "96"
|
18
|
+
|
19
|
+
@assets = Webconsole::Assets.new(nil)
|
20
|
+
assets_code = @assets.code
|
21
|
+
|
22
|
+
assets_code.must_match /fake_generated_token/
|
23
|
+
assets_code.must_match /event\.which == 96/
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
15
27
|
describe "#call" do
|
16
28
|
|
17
29
|
describe 'when the call is not appropriate to inject the view code' do
|
@@ -23,7 +23,7 @@ module Rack
|
|
23
23
|
|
24
24
|
response = @repl.call(env).last.first
|
25
25
|
|
26
|
-
|
26
|
+
MultiJson.decode(response)['result'].must_equal "8"
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'maintains local state in subsequent calls thanks to an evil global variable' do
|
@@ -41,7 +41,7 @@ module Rack
|
|
41
41
|
|
42
42
|
response = @repl.call(env).last.first # call 2 retrieves a and multiplies it by 8
|
43
43
|
|
44
|
-
|
44
|
+
MultiJson.decode(response)['result'].must_equal "32"
|
45
45
|
$sandbox.instance_variable_get(:@locals)[:a].must_equal 4
|
46
46
|
$sandbox.instance_variable_get(:@locals).size.must_equal 1
|
47
47
|
end
|
@@ -56,7 +56,7 @@ module Rack
|
|
56
56
|
|
57
57
|
response = @repl.call(env).last.first
|
58
58
|
|
59
|
-
|
59
|
+
MultiJson.decode(response)['result'].must_match /Error:/
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'rejects non-post requests' do
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
describe Webconsole::Shell do
|
5
|
+
before do
|
6
|
+
Ripl.instance_variable_set(:@shell, nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".eval_query" do
|
10
|
+
describe "sets Ripl::Shell" do
|
11
|
+
before { Webconsole::Shell.eval_query('2 + 2') }
|
12
|
+
|
13
|
+
it "#input" do
|
14
|
+
Ripl.shell.input.must_equal '2 + 2'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "#result" do
|
18
|
+
Ripl.shell.result.must_equal 4
|
19
|
+
end
|
20
|
+
|
21
|
+
it "#history" do
|
22
|
+
Ripl.shell.history.must_equal ['2 + 2']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "for one line input" do
|
27
|
+
def response
|
28
|
+
Webconsole::Shell.eval_query("'input'")
|
29
|
+
end
|
30
|
+
|
31
|
+
it ":result returns inspected result" do
|
32
|
+
response[:result].must_equal '"input"'
|
33
|
+
end
|
34
|
+
|
35
|
+
it ":prompt returns normal prompt" do
|
36
|
+
response[:prompt] = '>> '
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns false for multi_line keys" do
|
40
|
+
response[:multi_line].must_equal false
|
41
|
+
response[:previous_multi_line].must_equal false
|
42
|
+
end
|
43
|
+
|
44
|
+
it "with an error :result returns error raised" do
|
45
|
+
Webconsole::Shell.eval_query("blah")[:result].must_match /^Error:/
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "for multi line input" do
|
50
|
+
def response
|
51
|
+
[
|
52
|
+
Webconsole::Shell.eval_query("[1,2,3].map do |num|"),
|
53
|
+
Webconsole::Shell.eval_query("num ** 2"),
|
54
|
+
Webconsole::Shell.eval_query("end")
|
55
|
+
]
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns correct results" do
|
59
|
+
response.map {|e| e[:result] }.must_equal [nil, nil, "[1, 4, 9]"]
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns correct prompts" do
|
63
|
+
response.map {|e| e[:prompt] }.must_equal ['>> ', '|| ', '|| ']
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns correct multi_line keys" do
|
67
|
+
response.map {|e| e[:multi_line] }.must_equal [true, true, false]
|
68
|
+
response.map {|e| e[:previous_multi_line] }.must_equal [false, true, true]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -42,6 +42,15 @@ module Rack
|
|
42
42
|
Webconsole.inject_jquery = true
|
43
43
|
Webconsole.inject_jquery.must_equal true
|
44
44
|
end
|
45
|
+
it '#key_code accessors' do
|
46
|
+
Webconsole.key_code.must_equal "96"
|
47
|
+
Webconsole.key_code = "97"
|
48
|
+
Webconsole.key_code.must_equal "97"
|
49
|
+
end
|
50
|
+
it '#key_code setter cast parameter type' do
|
51
|
+
Webconsole.key_code = 96
|
52
|
+
Webconsole.key_code.must_equal "96"
|
53
|
+
end
|
45
54
|
end
|
46
55
|
end
|
47
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-webconsole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,12 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
15
|
-
default_executable:
|
14
|
+
date: 2012-03-22 00:00:00.000000000 Z
|
16
15
|
dependencies:
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: rack
|
19
|
-
requirement:
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
20
19
|
none: false
|
21
20
|
requirements:
|
22
21
|
- - ! '>='
|
@@ -24,21 +23,63 @@ dependencies:
|
|
24
23
|
version: '0'
|
25
24
|
type: :runtime
|
26
25
|
prerelease: false
|
27
|
-
version_requirements:
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: json
|
30
|
-
requirement: &2156016220 !ruby/object:Gem::Requirement
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
27
|
none: false
|
32
28
|
requirements:
|
33
29
|
- - ! '>='
|
34
30
|
- !ruby/object:Gem::Version
|
35
31
|
version: '0'
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: multi_json
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.0.3
|
36
40
|
type: :runtime
|
37
41
|
prerelease: false
|
38
|
-
version_requirements:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.3
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: ripl
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.5.1
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.5.1
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: ripl-multi_line
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 0.3.0
|
72
|
+
type: :runtime
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ~>
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.3.0
|
39
80
|
- !ruby/object:Gem::Dependency
|
40
81
|
name: minitest
|
41
|
-
requirement:
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
42
83
|
none: false
|
43
84
|
requirements:
|
44
85
|
- - ! '>='
|
@@ -46,10 +87,15 @@ dependencies:
|
|
46
87
|
version: '0'
|
47
88
|
type: :development
|
48
89
|
prerelease: false
|
49
|
-
version_requirements:
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
50
96
|
- !ruby/object:Gem::Dependency
|
51
97
|
name: purdytest
|
52
|
-
requirement:
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
53
99
|
none: false
|
54
100
|
requirements:
|
55
101
|
- - ! '>='
|
@@ -57,21 +103,15 @@ dependencies:
|
|
57
103
|
version: '0'
|
58
104
|
type: :development
|
59
105
|
prerelease: false
|
60
|
-
version_requirements:
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: mocha
|
63
|
-
requirement: &2156010800 !ruby/object:Gem::Requirement
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
107
|
none: false
|
65
108
|
requirements:
|
66
109
|
- - ! '>='
|
67
110
|
- !ruby/object:Gem::Version
|
68
111
|
version: '0'
|
69
|
-
type: :development
|
70
|
-
prerelease: false
|
71
|
-
version_requirements: *2156010800
|
72
112
|
- !ruby/object:Gem::Dependency
|
73
113
|
name: yard
|
74
|
-
requirement:
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
75
115
|
none: false
|
76
116
|
requirements:
|
77
117
|
- - ! '>='
|
@@ -79,10 +119,15 @@ dependencies:
|
|
79
119
|
version: '0'
|
80
120
|
type: :development
|
81
121
|
prerelease: false
|
82
|
-
version_requirements:
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
83
128
|
- !ruby/object:Gem::Dependency
|
84
129
|
name: bluecloth
|
85
|
-
requirement:
|
130
|
+
requirement: !ruby/object:Gem::Requirement
|
86
131
|
none: false
|
87
132
|
requirements:
|
88
133
|
- - ! '>='
|
@@ -90,10 +135,15 @@ dependencies:
|
|
90
135
|
version: '0'
|
91
136
|
type: :development
|
92
137
|
prerelease: false
|
93
|
-
version_requirements:
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
94
144
|
- !ruby/object:Gem::Dependency
|
95
145
|
name: rake
|
96
|
-
requirement:
|
146
|
+
requirement: !ruby/object:Gem::Requirement
|
97
147
|
none: false
|
98
148
|
requirements:
|
99
149
|
- - ! '>='
|
@@ -101,7 +151,12 @@ dependencies:
|
|
101
151
|
version: '0'
|
102
152
|
type: :development
|
103
153
|
prerelease: false
|
104
|
-
version_requirements:
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
105
160
|
description: Rack-based console inside your web applications
|
106
161
|
email:
|
107
162
|
- info@codegram.com
|
@@ -124,6 +179,7 @@ files:
|
|
124
179
|
- lib/rack/webconsole/railtie.rb
|
125
180
|
- lib/rack/webconsole/repl.rb
|
126
181
|
- lib/rack/webconsole/sandbox.rb
|
182
|
+
- lib/rack/webconsole/shell.rb
|
127
183
|
- lib/rack/webconsole/version.rb
|
128
184
|
- public/jquery.html
|
129
185
|
- public/webconsole.css
|
@@ -134,9 +190,9 @@ files:
|
|
134
190
|
- spec/rack/webconsole/assets_spec.rb
|
135
191
|
- spec/rack/webconsole/repl_spec.rb
|
136
192
|
- spec/rack/webconsole/sandbox_spec.rb
|
193
|
+
- spec/rack/webconsole/shell_spec.rb
|
137
194
|
- spec/rack/webconsole_spec.rb
|
138
195
|
- spec/spec_helper.rb
|
139
|
-
has_rdoc: true
|
140
196
|
homepage: http://github.com/codegram/rack-webconsole
|
141
197
|
licenses: []
|
142
198
|
post_install_message:
|
@@ -149,21 +205,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
205
|
- - ! '>='
|
150
206
|
- !ruby/object:Gem::Version
|
151
207
|
version: '0'
|
152
|
-
segments:
|
153
|
-
- 0
|
154
|
-
hash: 1863180217222437049
|
155
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
209
|
none: false
|
157
210
|
requirements:
|
158
211
|
- - ! '>='
|
159
212
|
- !ruby/object:Gem::Version
|
160
213
|
version: '0'
|
161
|
-
segments:
|
162
|
-
- 0
|
163
|
-
hash: 1863180217222437049
|
164
214
|
requirements: []
|
165
215
|
rubyforge_project: rack-webconsole
|
166
|
-
rubygems_version: 1.
|
216
|
+
rubygems_version: 1.8.19
|
167
217
|
signing_key:
|
168
218
|
specification_version: 3
|
169
219
|
summary: Rack-based console inside your web applications
|
@@ -172,5 +222,7 @@ test_files:
|
|
172
222
|
- spec/rack/webconsole/assets_spec.rb
|
173
223
|
- spec/rack/webconsole/repl_spec.rb
|
174
224
|
- spec/rack/webconsole/sandbox_spec.rb
|
225
|
+
- spec/rack/webconsole/shell_spec.rb
|
175
226
|
- spec/rack/webconsole_spec.rb
|
176
227
|
- spec/spec_helper.rb
|
228
|
+
has_rdoc:
|