ripl-rack 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +22 -0
- data/LICENSE.txt +22 -0
- data/README.rdoc +50 -0
- data/Rakefile +35 -0
- data/bin/ripl-rack +5 -0
- data/deps.rip +3 -0
- data/lib/ripl/rack.rb +52 -0
- metadata +121 -0
data/.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubygems' unless Object.const_defined?(:Gem)
|
3
|
+
require File.dirname(__FILE__) + "/lib/ripl/rack"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ripl-rack"
|
7
|
+
s.version = Ripl::Rack::VERSION
|
8
|
+
s.authors = ["Gabriel Horner"]
|
9
|
+
s.email = "gabriel.horner@gmail.com"
|
10
|
+
s.homepage = "http://github.com/cldwalker/ripl-rack"
|
11
|
+
s.summary = "A script/console for rack apps using ripl"
|
12
|
+
s.description = "This ripl plugin provides a console for rack apps."
|
13
|
+
s.required_rubygems_version = ">= 1.3.6"
|
14
|
+
s.rubyforge_project = 'tagaholic'
|
15
|
+
s.executables = ['ripl-rack']
|
16
|
+
s.add_dependency 'ripl', '>= 0.2.7'
|
17
|
+
s.add_dependency 'rack', '>= 1.0'
|
18
|
+
s.add_dependency 'rack-test', '>= 0.5'
|
19
|
+
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
20
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
21
|
+
s.license = 'MIT'
|
22
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2010 Gabriel Horner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
== Description
|
2
|
+
This ripl plugin provides a console for rack apps.
|
3
|
+
|
4
|
+
== Install
|
5
|
+
Install the gem with:
|
6
|
+
|
7
|
+
sudo gem install ripl-rack
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
As an executable:
|
12
|
+
|
13
|
+
$ ripl rack
|
14
|
+
Loading development environment (Rack 1.1)
|
15
|
+
|
16
|
+
As a plugin:
|
17
|
+
|
18
|
+
$ ripl rails -r ripl/rack
|
19
|
+
|
20
|
+
Now let's use it:
|
21
|
+
|
22
|
+
$ ripl rack
|
23
|
+
Loading development environment (Rack 1.1)
|
24
|
+
|
25
|
+
# your rack app thanks to Rack::Test
|
26
|
+
>> rack
|
27
|
+
#<Ripl::Rack::App:0x3f8cc @env="development" ... >
|
28
|
+
|
29
|
+
# Make http requests
|
30
|
+
>> rack.get '/'
|
31
|
+
>> rack.post '/login', :user => 'x', :password => 'y'
|
32
|
+
...
|
33
|
+
|
34
|
+
# To see what actions you can perform on your app
|
35
|
+
>> rack.actions
|
36
|
+
=> [:request, :get, :post, :put, :delete, :head, :follow_redirect!, :header, :set_cookie,
|
37
|
+
:clear_cookies, :authorize, :basic_authorize, :digest_authorize, :last_response, :last_request]
|
38
|
+
|
39
|
+
# To perform these actions even more naturally
|
40
|
+
>> rackit!
|
41
|
+
=> [:request, :get, :post, :put, :delete, :head, :follow_redirect!, :header, :set_cookie,
|
42
|
+
:clear_cookies, :authorize, :basic_authorize, :digest_authorize, :last_response, :last_request]
|
43
|
+
|
44
|
+
# All of the above methods are now available at the top level
|
45
|
+
>> get '/'
|
46
|
+
>> post '/login', :user => 'x', :password => 'y'
|
47
|
+
....
|
48
|
+
|
49
|
+
== Credits
|
50
|
+
* Thanks to racksh for interesting rack-test bits
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
def gemspec
|
5
|
+
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Build the gem"
|
9
|
+
task :gem=>:gemspec do
|
10
|
+
sh "gem build .gemspec"
|
11
|
+
FileUtils.mkdir_p 'pkg'
|
12
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Install the gem locally"
|
16
|
+
task :install => :gem do
|
17
|
+
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Generate the gemspec"
|
21
|
+
task :generate do
|
22
|
+
puts gemspec.to_ruby
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Validate the gemspec"
|
26
|
+
task :gemspec do
|
27
|
+
gemspec.validate
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Run tests'
|
31
|
+
task :test do |t|
|
32
|
+
sh 'bacon -q -Ilib -I. test/*_test.rb'
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
data/bin/ripl-rack
ADDED
data/deps.rip
ADDED
data/lib/ripl/rack.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'ripl'
|
2
|
+
require 'rack'
|
3
|
+
require 'rack/test'
|
4
|
+
|
5
|
+
module Ripl::Rack
|
6
|
+
VERSION = '0.1.0'
|
7
|
+
|
8
|
+
def before_loop
|
9
|
+
Commands.rack
|
10
|
+
puts "Loading #{Commands.rack.env} environment (Rack #{Rack.version})"
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
module Commands
|
15
|
+
def self.rack
|
16
|
+
@rack ||= Ripl::Rack::App.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def rack
|
20
|
+
Commands.rack
|
21
|
+
end
|
22
|
+
|
23
|
+
def rackit!
|
24
|
+
Ripl::Rack::Commands.module_eval do
|
25
|
+
rack.actions.each do |meth|
|
26
|
+
define_method(meth) {|*args| rack.send(meth, *args) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class App
|
33
|
+
include Rack::Test::Methods
|
34
|
+
attr_reader :app, :env
|
35
|
+
|
36
|
+
def initialize(config_ru=nil)
|
37
|
+
config_ru ||= ENV['RACK_CONFIG'] || 'config.ru'
|
38
|
+
unless File.exists? config_ru
|
39
|
+
abort "Rack config file '#{config_ru}' doesn't exist. Specify with ENV['RACK_CONFIG']"
|
40
|
+
end
|
41
|
+
@app = Kernel.eval("Rack::Builder.new { #{File.read(config_ru)} }")
|
42
|
+
@env = ENV['RACK_ENV'] || 'development'
|
43
|
+
end
|
44
|
+
|
45
|
+
def actions
|
46
|
+
::Rack::Test::Methods::METHODS
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Ripl::Shell.send :include, Ripl::Rack
|
52
|
+
Ripl::Commands.send :include, Ripl::Rack::Commands
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ripl-rack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Gabriel Horner
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-11 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: ripl
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 25
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 2
|
33
|
+
- 7
|
34
|
+
version: 0.2.7
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rack
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 15
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 0
|
49
|
+
version: "1.0"
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: rack-test
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 1
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
- 5
|
64
|
+
version: "0.5"
|
65
|
+
type: :runtime
|
66
|
+
version_requirements: *id003
|
67
|
+
description: This ripl plugin provides a console for rack apps.
|
68
|
+
email: gabriel.horner@gmail.com
|
69
|
+
executables:
|
70
|
+
- ripl-rack
|
71
|
+
extensions: []
|
72
|
+
|
73
|
+
extra_rdoc_files:
|
74
|
+
- README.rdoc
|
75
|
+
- LICENSE.txt
|
76
|
+
files:
|
77
|
+
- lib/ripl/rack.rb
|
78
|
+
- bin/ripl-rack
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.rdoc
|
81
|
+
- deps.rip
|
82
|
+
- Rakefile
|
83
|
+
- .gemspec
|
84
|
+
has_rdoc: true
|
85
|
+
homepage: http://github.com/cldwalker/ripl-rack
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 23
|
108
|
+
segments:
|
109
|
+
- 1
|
110
|
+
- 3
|
111
|
+
- 6
|
112
|
+
version: 1.3.6
|
113
|
+
requirements: []
|
114
|
+
|
115
|
+
rubyforge_project: tagaholic
|
116
|
+
rubygems_version: 1.3.7
|
117
|
+
signing_key:
|
118
|
+
specification_version: 3
|
119
|
+
summary: A script/console for rack apps using ripl
|
120
|
+
test_files: []
|
121
|
+
|