kazoo 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/MIT-License +21 -0
- data/Manifest +2 -0
- data/Rakefile +1 -1
- data/kazoo.gemspec +5 -6
- data/lib/kazoo/router.rb +1 -0
- data/lib/kazoo/sinatra.rb +1 -1
- data/readme.markdown +60 -0
- metadata +10 -6
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/MIT-License
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 Jeremy Nicoll
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Manifest
CHANGED
data/Rakefile
CHANGED
data/kazoo.gemspec
CHANGED
@@ -2,26 +2,25 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{kazoo}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jeremy Nicoll"]
|
9
9
|
s.cert_chain = ["/Users/eltiare/keys/gem-public_cert.pem"]
|
10
|
-
s.date = %q{2011-01-
|
10
|
+
s.date = %q{2011-01-28}
|
11
11
|
s.description = %q{Make your Ruby Rack apps act like one}
|
12
12
|
s.email = %q{jnicoll @nspam@ accentuate.me}
|
13
13
|
s.extra_rdoc_files = ["lib/kazoo.rb", "lib/kazoo/router.rb", "lib/kazoo/sinatra.rb"]
|
14
|
-
s.files = ["Manifest", "Rakefile", "lib/kazoo.rb", "lib/kazoo/router.rb", "lib/kazoo/sinatra.rb", "kazoo.gemspec"]
|
14
|
+
s.files = ["MIT-License", "Manifest", "Rakefile", "lib/kazoo.rb", "lib/kazoo/router.rb", "lib/kazoo/sinatra.rb", "readme.markdown", "kazoo.gemspec"]
|
15
15
|
s.homepage = %q{http://rubykazoo.com}
|
16
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Kazoo"]
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Kazoo", "--main", "readme.markdown"]
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.rubyforge_project = %q{kazoo}
|
19
|
-
s.rubygems_version = %q{1.
|
19
|
+
s.rubygems_version = %q{1.4.2}
|
20
20
|
s.signing_key = %q{/Users/eltiare/keys/gem-private_key.pem}
|
21
21
|
s.summary = %q{Make your Ruby Rack apps act like one}
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
24
|
s.specification_version = 3
|
26
25
|
|
27
26
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/lib/kazoo/router.rb
CHANGED
@@ -28,6 +28,7 @@ class Kazoo::Router
|
|
28
28
|
if matches = route[0].match(env['REQUEST_PATH'])
|
29
29
|
env['HTTP_PREFIX'] = matches[0]
|
30
30
|
env['PATH_INFO'] = env['PATH_INFO'].sub(route[0], '')
|
31
|
+
env['PATH_INFO'] = "/#{env['PATH_INFO']}" unless env['PATH_INFO'].match(%r'^/')
|
31
32
|
response = route[1].call(env)
|
32
33
|
return response if response[1]['X-Cascade'] != 'pass'
|
33
34
|
end
|
data/lib/kazoo/sinatra.rb
CHANGED
@@ -6,7 +6,7 @@ class Kazoo::Sinatra < Sinatra::Base
|
|
6
6
|
|
7
7
|
if !options[:views] && data.is_a?(Symbol) && !data.to_s.match('/')
|
8
8
|
data = :"#{decamelize(self.class.name)}/#{data}"
|
9
|
-
options[:layout]
|
9
|
+
options[:layout] = :'layouts/application' if options[:layout].nil?
|
10
10
|
end
|
11
11
|
|
12
12
|
if options[:layout] && !options[:layout].to_s.match('/')
|
data/readme.markdown
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
Kazoo
|
2
|
+
=====
|
3
|
+
|
4
|
+
Kazoo is a Ruby library that aims to make your Rack applications behave like one. So far, it's very minimal with a simple router and some methods added to Sinatra to make it easier to have multiple Sinatra apps act more cohesively. Please note the current version on this: 0.0.1. This is nowhere near finished! It is on rubygems.org so that you can install it by running:
|
5
|
+
|
6
|
+
gem install kazoo
|
7
|
+
|
8
|
+
The Kazoo router takes string paths and matches them to apps with no bells or whistles (yet). This is how you use it in a config.ru file:
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
require 'kazoo'
|
12
|
+
require 'kazoo/router'
|
13
|
+
|
14
|
+
# Omitted code that pulls in Sinatra apps...
|
15
|
+
|
16
|
+
run Kazoo::Router.map {
|
17
|
+
match '/feeds', :to => Feeds
|
18
|
+
match '/control/feeds', :to => Control::Feeds
|
19
|
+
error_handler DogCatcher
|
20
|
+
}
|
21
|
+
|
22
|
+
Use the match method to specify the route and the :to option to specify the application. You can specify an app to handle errors (like page not found or server errors), though this feature is not complete right now. I will get this up and going shortly, and when I do I will update this readme.
|
23
|
+
|
24
|
+
The `Kazoo::Sinatra` class overrides the render method to automatically add the name of the app to the view path. So an app named `Feeds` will have the default base path of "./views/feeds". `Admin::Feeds` will have a base path of './views/admin/feeds'. You can override this by putting a slash in your template path. See the Sinatra docs for more details. The default layout is './views/layouts/application.#{template_engine}' though you can override this with the same rules as above.
|
25
|
+
|
26
|
+
|
27
|
+
In order to facilitate the fact that apps can be mounted at different paths, url helpers are included.
|
28
|
+
|
29
|
+
require 'kazoo/sinatra'
|
30
|
+
|
31
|
+
class Feeds < Kazoo::Sinatra
|
32
|
+
|
33
|
+
set_paths(
|
34
|
+
:index => '/',
|
35
|
+
:show => '/:id'
|
36
|
+
)
|
37
|
+
|
38
|
+
get path(:index) do
|
39
|
+
erubis :index
|
40
|
+
end
|
41
|
+
|
42
|
+
get path(:show) do
|
43
|
+
@feed = Feed.find(params[:id])
|
44
|
+
erubis :show
|
45
|
+
end
|
46
|
+
|
47
|
+
#alternatively, you can declare paths inline
|
48
|
+
|
49
|
+
get path(:show, '/:id') do
|
50
|
+
@feed = Feed.find(params[:id])
|
51
|
+
erubis :show
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
#.views/feeds/show.erubis
|
57
|
+
<p>This is the generated URL for this page: <%= url(:show, :id => @feed.id) %></p>
|
58
|
+
|
59
|
+
|
60
|
+
If you run into any problems or have suggestions, feel free to send a ticket to /dev/null. Or you can submit one at https://github.com/eltiare/kazoo/issues, your choice.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kazoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremy Nicoll
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
ZVeyFF4suKZEIEKi
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2011-01-
|
39
|
+
date: 2011-01-28 00:00:00 -07:00
|
40
40
|
default_executable:
|
41
41
|
dependencies: []
|
42
42
|
|
@@ -51,11 +51,13 @@ extra_rdoc_files:
|
|
51
51
|
- lib/kazoo/router.rb
|
52
52
|
- lib/kazoo/sinatra.rb
|
53
53
|
files:
|
54
|
+
- MIT-License
|
54
55
|
- Manifest
|
55
56
|
- Rakefile
|
56
57
|
- lib/kazoo.rb
|
57
58
|
- lib/kazoo/router.rb
|
58
59
|
- lib/kazoo/sinatra.rb
|
60
|
+
- readme.markdown
|
59
61
|
- kazoo.gemspec
|
60
62
|
has_rdoc: true
|
61
63
|
homepage: http://rubykazoo.com
|
@@ -67,6 +69,8 @@ rdoc_options:
|
|
67
69
|
- --inline-source
|
68
70
|
- --title
|
69
71
|
- Kazoo
|
72
|
+
- --main
|
73
|
+
- readme.markdown
|
70
74
|
require_paths:
|
71
75
|
- lib
|
72
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -91,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
95
|
requirements: []
|
92
96
|
|
93
97
|
rubyforge_project: kazoo
|
94
|
-
rubygems_version: 1.
|
98
|
+
rubygems_version: 1.4.2
|
95
99
|
signing_key:
|
96
100
|
specification_version: 3
|
97
101
|
summary: Make your Ruby Rack apps act like one
|
metadata.gz.sig
CHANGED
Binary file
|