rack-webconsole 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ # https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options
2
+ rvm:
3
+ - 1.8.7 # (current default)
4
+ - 1.9.2
5
+ - rbx
6
+ - rbx-2.0
7
+ - ree
8
+ - jruby
9
+ - ruby-head
10
+ - 1.8.6
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in rack-webconsole.gemspec
4
4
  gemspec
5
+ gem 'rake'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-webconsole (0.0.1)
4
+ rack-webconsole (0.0.3)
5
5
  json
6
6
  rack
7
7
 
@@ -19,6 +19,7 @@ GEM
19
19
  yard (0.7.2)
20
20
 
21
21
  PLATFORMS
22
+ java
22
23
  ruby
23
24
 
24
25
  DEPENDENCIES
data/Rakefile CHANGED
@@ -14,12 +14,10 @@ YARD::Rake::YardocTask.new(:docs) do |t|
14
14
  t.files = ['lib/**/*.rb']
15
15
  t.options = ['-m', 'markdown', '--no-private', '-r', 'Readme.md', '--title', 'rack-webconsole documentation']
16
16
  end
17
-
18
17
  task :doc => [:docs]
19
18
 
20
19
  desc "Generate and open class diagram (needs Graphviz installed)"
21
20
  task :graph do |t|
22
21
  `bundle exec yard graph -d --full --no-private | dot -Tpng -o graph.png && open graph.png`
23
22
  end
24
-
25
23
  task :default => [:test]
data/Readme.md CHANGED
@@ -4,14 +4,15 @@ 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
5
5
  application's backend from within the browser itself!
6
6
 
7
- To get a clearer idea, you can check out [this video](
8
- http://youtu.be/yKK5J01Dqts?hd=1) showing a live example :)
7
+ To get a clearer idea, you can check out this video showing a live example :)
8
+
9
+ [![YouTube video](http://img.youtube.com/vi/yKK5J01Dqts/0.jpg)](http://youtu.be/yKK5J01Dqts?hd=1)
9
10
 
10
11
  Rack-webconsole is a Rack middleware designed to be unobtrusive. With Rails 3,
11
12
  for example, you only have to include the gem in your Gemfile and it already
12
13
  works. Without any configuration.
13
14
 
14
- Tested with MRI 1.9.2 and ruby-head (1.9.3).
15
+ Tested with MRI versions 1.8.7, 1.9.2, ruby-head, and JRuby 1.6.3.
15
16
 
16
17
  ##Resources
17
18
 
@@ -24,6 +25,14 @@ In your Gemfile:
24
25
 
25
26
  gem 'rack-webconsole'
26
27
 
28
+ Rack-webconsole **needs JQuery**. If you are using Rails 3, JQuery is loaded by
29
+ default. In case you don't want to use JQuery in your application,
30
+ **rack-webconsole can inject it for you** only when it needs it. To do that you
31
+ should put this line somewhere in your application (a Rails initializer, or
32
+ some configuration file):
33
+
34
+ Rack::Webconsole.inject_jquery = true
35
+
27
36
 
28
37
  ##Usage with Rails 3
29
38
 
@@ -54,6 +63,7 @@ have to `require 'rack/webconsole'` manually, otherwise you have to.
54
63
 
55
64
  And it works! Fire up the server, go to any page and press the ` ` ` key.
56
65
 
66
+
57
67
  ##Commands
58
68
 
59
69
  In the console you can issue whatever Ruby commands you want, except multiline commands. Local variables are kept, so you can get a more IRB-esque feeling.
@@ -84,4 +94,3 @@ You can also build the documentation with the following command:
84
94
  Copyright (c) 2011 Codegram. See LICENSE for details.
85
95
 
86
96
 
87
-
@@ -16,7 +16,10 @@ module Rack
16
16
  #
17
17
  # @return [String] the injectable HTML.
18
18
  def html_code
19
- asset 'webconsole.html'
19
+ out = ""
20
+ out << asset('jquery.html') if Webconsole.inject_jquery
21
+ out << asset('webconsole.html')
22
+ out
20
23
  end
21
24
 
22
25
  # Loads the CSS from a file in `/public`.
@@ -36,11 +36,12 @@ module Rack
36
36
  result = begin
37
37
  $sandbox ||= Sandbox.new
38
38
 
39
- boilerplate = local_variables + [:ls]
39
+ # Force conversion to symbols due to issues with lovely 1.8.7
40
+ boilerplate = local_variables.map(&:to_sym) + [:ls]
40
41
 
41
42
  result = $sandbox.instance_eval """
42
43
  result = (#{params['query']})
43
- ls = (local_variables - #{boilerplate})
44
+ ls = (local_variables.map(&:to_sym) - [#{boilerplate.join(', ')}])
44
45
  @locals ||= {}
45
46
  @locals.update(ls.inject({}) do |hash, value|
46
47
  hash.update({value => eval(value.to_s)})
@@ -10,7 +10,7 @@ module Rack
10
10
  # method missing behavior.
11
11
  def method_missing(method, *args, &block)
12
12
  @locals ||= {}
13
- @locals[method] || super(method, *args, &block)
13
+ @locals[method.to_sym] || super(method, *args, &block)
14
14
  end
15
15
 
16
16
  # Makes the console use a fresh, new {Sandbox} with all local variables
@@ -2,6 +2,6 @@
2
2
  module Rack
3
3
  class Webconsole
4
4
  # rack-webconsole version number.
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.3"
6
6
  end
7
7
  end
@@ -24,6 +24,24 @@ module Rack
24
24
  # variables and giving a true IRB-esque experience.
25
25
  #
26
26
  class Webconsole
27
+ @@inject_jquery = false
28
+
29
+ class << self
30
+ # Returns whether the Asset injecter must inject JQuery or not.
31
+ #
32
+ # @return [Boolean] whether to inject JQuery or not.
33
+ def inject_jquery
34
+ @@inject_jquery
35
+ end
36
+
37
+ # Sets whether the Asset injecter must inject JQuery or not.
38
+ #
39
+ # @param [Boolean] value whether to inject JQuery or not.
40
+ def inject_jquery=(value)
41
+ @@inject_jquery = value
42
+ end
43
+ end
44
+
27
45
  # Honor the Rack contract by saving the passed Rack application in an ivar.
28
46
  #
29
47
  # @param [Rack::Application] app the previous Rack application in the
@@ -0,0 +1 @@
1
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
@@ -1,7 +1,3 @@
1
- body {
2
- margin:0;
3
- padding:0;
4
- }
5
1
  #console {
6
2
  opacity: 0.9;
7
3
  z-index: 999;
@@ -14,6 +10,8 @@ body {
14
10
  position: fixed;
15
11
  width: 100%;
16
12
  bottom: 0px;
13
+ left: 0px;
14
+ right:0px;
17
15
  border-top: 3px solid #DEDEDE;
18
16
  overflow: hidden;
19
17
  padding-top: 10px;
@@ -1,4 +1,3 @@
1
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
2
1
  <div id="console">
3
2
  <form accept-charset="UTF-8" action="/webconsole" method="post">
4
3
  <input name="utf8" type="hidden" value="✓"/>
@@ -36,5 +36,12 @@ module Rack
36
36
  end
37
37
  end
38
38
 
39
+ describe 'class methods' do
40
+ it '#inject_jquery accessors' do
41
+ Webconsole.inject_jquery.must_equal false
42
+ Webconsole.inject_jquery = true
43
+ Webconsole.inject_jquery.must_equal true
44
+ end
45
+ end
39
46
  end
40
47
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'rubygems'
2
+
1
3
  gem 'minitest'
2
4
  require 'minitest/spec'
3
5
  require 'minitest/autorun'
metadata CHANGED
@@ -1,120 +1,117 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack-webconsole
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
4
5
  prerelease:
5
- version: 0.0.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Josep M. Bach
9
9
  - Josep Jaume Rey
10
10
  - Oriol Gual
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
-
15
- date: 2011-07-24 00:00:00 +02:00
14
+ date: 2011-07-25 00:00:00.000000000 +02:00
16
15
  default_executable:
17
- dependencies:
18
- - !ruby/object:Gem::Dependency
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
19
18
  name: rack
20
- prerelease: false
21
- requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirement: &2151838500 !ruby/object:Gem::Requirement
22
20
  none: false
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: "0"
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
27
25
  type: :runtime
28
- version_requirements: *id001
29
- - !ruby/object:Gem::Dependency
30
- name: json
31
26
  prerelease: false
32
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ version_requirements: *2151838500
28
+ - !ruby/object:Gem::Dependency
29
+ name: json
30
+ requirement: &2151838000 !ruby/object:Gem::Requirement
33
31
  none: false
34
- requirements:
35
- - - ">="
36
- - !ruby/object:Gem::Version
37
- version: "0"
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
38
36
  type: :runtime
39
- version_requirements: *id002
40
- - !ruby/object:Gem::Dependency
41
- name: minitest
42
37
  prerelease: false
43
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ version_requirements: *2151838000
39
+ - !ruby/object:Gem::Dependency
40
+ name: minitest
41
+ requirement: &2151837320 !ruby/object:Gem::Requirement
44
42
  none: false
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: "0"
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
49
47
  type: :development
50
- version_requirements: *id003
51
- - !ruby/object:Gem::Dependency
52
- name: purdytest
53
48
  prerelease: false
54
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ version_requirements: *2151837320
50
+ - !ruby/object:Gem::Dependency
51
+ name: purdytest
52
+ requirement: &2151836620 !ruby/object:Gem::Requirement
55
53
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: "0"
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
60
58
  type: :development
61
- version_requirements: *id004
62
- - !ruby/object:Gem::Dependency
63
- name: mocha
64
59
  prerelease: false
65
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ version_requirements: *2151836620
61
+ - !ruby/object:Gem::Dependency
62
+ name: mocha
63
+ requirement: &2151835980 !ruby/object:Gem::Requirement
66
64
  none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: "0"
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
71
69
  type: :development
72
- version_requirements: *id005
73
- - !ruby/object:Gem::Dependency
74
- name: yard
75
70
  prerelease: false
76
- requirement: &id006 !ruby/object:Gem::Requirement
71
+ version_requirements: *2151835980
72
+ - !ruby/object:Gem::Dependency
73
+ name: yard
74
+ requirement: &2151835280 !ruby/object:Gem::Requirement
77
75
  none: false
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: "0"
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
82
80
  type: :development
83
- version_requirements: *id006
84
- - !ruby/object:Gem::Dependency
85
- name: bluecloth
86
81
  prerelease: false
87
- requirement: &id007 !ruby/object:Gem::Requirement
82
+ version_requirements: *2151835280
83
+ - !ruby/object:Gem::Dependency
84
+ name: bluecloth
85
+ requirement: &2151834420 !ruby/object:Gem::Requirement
88
86
  none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: "0"
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
93
91
  type: :development
94
- version_requirements: *id007
95
- - !ruby/object:Gem::Dependency
96
- name: rake
97
92
  prerelease: false
98
- requirement: &id008 !ruby/object:Gem::Requirement
93
+ version_requirements: *2151834420
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
96
+ requirement: &2151833560 !ruby/object:Gem::Requirement
99
97
  none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
104
102
  type: :development
105
- version_requirements: *id008
103
+ prerelease: false
104
+ version_requirements: *2151833560
106
105
  description: Rack-based console inside your web applications
107
- email:
106
+ email:
108
107
  - info@codegram.com
109
108
  executables: []
110
-
111
109
  extensions: []
112
-
113
110
  extra_rdoc_files: []
114
-
115
- files:
111
+ files:
116
112
  - .gitignore
117
113
  - .rvmrc
114
+ - .travis.yml
118
115
  - Gemfile
119
116
  - Gemfile.lock
120
117
  - Rakefile
@@ -127,6 +124,7 @@ files:
127
124
  - lib/rack/webconsole/repl.rb
128
125
  - lib/rack/webconsole/sandbox.rb
129
126
  - lib/rack/webconsole/version.rb
127
+ - public/jquery.html
130
128
  - public/webconsole.css
131
129
  - public/webconsole.html
132
130
  - public/webconsole.js
@@ -140,32 +138,35 @@ files:
140
138
  has_rdoc: true
141
139
  homepage: http://github.com/codegram/rack-webconsole
142
140
  licenses: []
143
-
144
141
  post_install_message:
145
142
  rdoc_options: []
146
-
147
- require_paths:
143
+ require_paths:
148
144
  - lib
149
- required_ruby_version: !ruby/object:Gem::Requirement
145
+ required_ruby_version: !ruby/object:Gem::Requirement
150
146
  none: false
151
- requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- version: "0"
155
- required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ! '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ segments:
152
+ - 0
153
+ hash: -158137327595966531
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
155
  none: false
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- version: "0"
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ segments:
161
+ - 0
162
+ hash: -158137327595966531
161
163
  requirements: []
162
-
163
164
  rubyforge_project: rack-webconsole
164
- rubygems_version: 1.6.1
165
+ rubygems_version: 1.6.2
165
166
  signing_key:
166
167
  specification_version: 3
167
168
  summary: Rack-based console inside your web applications
168
- test_files:
169
+ test_files:
169
170
  - spec/rack/webconsole/asset_helpers_spec.rb
170
171
  - spec/rack/webconsole/assets_spec.rb
171
172
  - spec/rack/webconsole/repl_spec.rb