kazoo 0.0.2 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/Manifest +9 -0
- data/Rakefile +11 -3
- data/kazoo.gemspec +7 -7
- data/lib/kazoo.rb +10 -2
- data/lib/kazoo/accessors.rb +9 -0
- data/lib/kazoo/router.rb +35 -17
- data/lib/kazoo/router/context.rb +46 -0
- data/lib/kazoo/router/route.rb +110 -0
- data/lib/kazoo/sinatra.rb +51 -20
- data/lib/kazoo/support.rb +40 -0
- data/readme.markdown +3 -4
- data/spec/router/context_spec.rb +6 -0
- data/spec/router/route_spec.rb +39 -0
- data/spec/router_spec.rb +38 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +7 -0
- metadata +20 -7
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/Manifest
CHANGED
@@ -2,6 +2,15 @@ MIT-License
|
|
2
2
|
Manifest
|
3
3
|
Rakefile
|
4
4
|
lib/kazoo.rb
|
5
|
+
lib/kazoo/accessors.rb
|
5
6
|
lib/kazoo/router.rb
|
7
|
+
lib/kazoo/router/context.rb
|
8
|
+
lib/kazoo/router/route.rb
|
6
9
|
lib/kazoo/sinatra.rb
|
10
|
+
lib/kazoo/support.rb
|
7
11
|
readme.markdown
|
12
|
+
spec/router/context_spec.rb
|
13
|
+
spec/router/route_spec.rb
|
14
|
+
spec/router_spec.rb
|
15
|
+
spec/spec.opts
|
16
|
+
spec/spec_helper.rb
|
data/Rakefile
CHANGED
@@ -2,11 +2,19 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
require 'rspec'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
|
8
|
+
Echoe.new('kazoo', '0.0.5') do |p|
|
9
|
+
p.description = "A moduler framework to facilitate the development of content management systems"
|
7
10
|
p.url = "http://rubykazoo.com"
|
8
11
|
p.author = "Jeremy Nicoll"
|
9
12
|
p.email = "jnicoll @nspam@ accentuate.me"
|
10
13
|
p.ignore_pattern = ['*.kpf', "tmp/*", "script/*"]
|
11
14
|
p.development_dependencies = []
|
12
|
-
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
desc "Run all specs"
|
19
|
+
RSpec::Core::RakeTask.new(:spec)
|
20
|
+
task :default => :spec
|
data/kazoo.gemspec
CHANGED
@@ -2,23 +2,23 @@
|
|
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.5"
|
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-
|
11
|
-
s.description = %q{
|
10
|
+
s.date = %q{2011-02-16}
|
11
|
+
s.description = %q{A moduler framework to facilitate the development of content management systems}
|
12
12
|
s.email = %q{jnicoll @nspam@ accentuate.me}
|
13
|
-
s.extra_rdoc_files = ["lib/kazoo.rb", "lib/kazoo/router.rb", "lib/kazoo/sinatra.rb"]
|
14
|
-
s.files = ["MIT-License", "Manifest", "Rakefile", "lib/kazoo.rb", "lib/kazoo/router.rb", "lib/kazoo/sinatra.rb", "readme.markdown", "kazoo.gemspec"]
|
13
|
+
s.extra_rdoc_files = ["lib/kazoo.rb", "lib/kazoo/accessors.rb", "lib/kazoo/router.rb", "lib/kazoo/router/context.rb", "lib/kazoo/router/route.rb", "lib/kazoo/sinatra.rb", "lib/kazoo/support.rb"]
|
14
|
+
s.files = ["MIT-License", "Manifest", "Rakefile", "lib/kazoo.rb", "lib/kazoo/accessors.rb", "lib/kazoo/router.rb", "lib/kazoo/router/context.rb", "lib/kazoo/router/route.rb", "lib/kazoo/sinatra.rb", "lib/kazoo/support.rb", "readme.markdown", "spec/router/context_spec.rb", "spec/router/route_spec.rb", "spec/router_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "kazoo.gemspec"]
|
15
15
|
s.homepage = %q{http://rubykazoo.com}
|
16
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.5.0}
|
20
20
|
s.signing_key = %q{/Users/eltiare/keys/gem-private_key.pem}
|
21
|
-
s.summary = %q{
|
21
|
+
s.summary = %q{A moduler framework to facilitate the development of content management systems}
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
s.specification_version = 3
|
data/lib/kazoo.rb
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
+
$LOAD_PATH.push(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
1
5
|
module Kazoo; end
|
2
6
|
|
3
|
-
|
4
|
-
|
7
|
+
require "kazoo/support"
|
8
|
+
require "kazoo/accessors"
|
9
|
+
|
10
|
+
require 'kazoo/router/route'
|
11
|
+
require 'kazoo/router/context'
|
12
|
+
require "kazoo/router"
|
data/lib/kazoo/router.rb
CHANGED
@@ -1,37 +1,55 @@
|
|
1
1
|
class Kazoo::Router
|
2
2
|
|
3
3
|
def self.map(&blk)
|
4
|
-
|
5
|
-
instance.instance_eval(&blk)
|
6
|
-
instance
|
4
|
+
new.map(&blk)
|
7
5
|
end
|
8
6
|
|
9
|
-
def
|
10
|
-
@
|
7
|
+
def map(&blk)
|
8
|
+
@context ||= Context.new(self)
|
9
|
+
@context.instance_eval(&blk)
|
10
|
+
self
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
13
|
+
def routes
|
14
|
+
@routes ||= []
|
15
|
+
end
|
16
|
+
|
17
|
+
def named_routes
|
18
|
+
@named_routes ||= {}
|
20
19
|
end
|
21
20
|
|
22
21
|
def error_handler(app)
|
23
22
|
@error_handler = app
|
24
23
|
end
|
25
24
|
|
25
|
+
def general_handler(app)
|
26
|
+
@general_handler = app
|
27
|
+
end
|
28
|
+
|
29
|
+
def kenv
|
30
|
+
@env['kazoo'] ||= {}
|
31
|
+
end
|
32
|
+
|
26
33
|
def call(env)
|
34
|
+
@env = env
|
27
35
|
@routes.each do |route|
|
28
|
-
|
29
|
-
|
30
|
-
|
36
|
+
env['PATH_INFO'] = "#{env["PATH_INFO"]}/" unless %r'/$'.match(env['PATH_INFO'])
|
37
|
+
params = route.extract_params(env['PATH_INFO'])
|
38
|
+
|
39
|
+
if params && route.app
|
40
|
+
kenv['params'] ||= {}
|
41
|
+
kenv['params'].merge!(params)
|
42
|
+
|
43
|
+
match = route.to_regexp.match(env['PATH_INFO'])[0]
|
44
|
+
kenv['path_prefix'] = kenv['path_prefix'] ? File.join(kenv['path_prefix'], match) : match
|
45
|
+
|
46
|
+
env['PATH_INFO'] = env['PATH_INFO'].sub(match, '')
|
31
47
|
env['PATH_INFO'] = "/#{env['PATH_INFO']}" unless env['PATH_INFO'].match(%r'^/')
|
32
|
-
|
33
|
-
|
48
|
+
|
49
|
+
response = route.app.call(env)
|
50
|
+
return response unless response[1]['X-Cascade'] == 'pass'
|
34
51
|
end
|
52
|
+
|
35
53
|
end
|
36
54
|
|
37
55
|
# If no routes found
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Kazoo::Router
|
2
|
+
|
3
|
+
class Context
|
4
|
+
|
5
|
+
def initialize(router, opts = {})
|
6
|
+
@router = router
|
7
|
+
@opts = opts
|
8
|
+
end
|
9
|
+
|
10
|
+
def match(path, opts)
|
11
|
+
opts = @opts.merge(opts)
|
12
|
+
name = extract_name(opts)
|
13
|
+
route = Route.new(path, opts)
|
14
|
+
@router.named_routes[name] = route if name
|
15
|
+
@router.routes << route
|
16
|
+
route
|
17
|
+
end
|
18
|
+
|
19
|
+
def context(opts = {})
|
20
|
+
opts = opts.dup
|
21
|
+
|
22
|
+
if @opts[:path_prefix] && opts[:path_prefix]
|
23
|
+
opts[:path_prefix] = File.join(@opts[:path_prefix], opts[:path_prefix])
|
24
|
+
end
|
25
|
+
|
26
|
+
if @opts[:name_prefix] && opts[:name_prefix]
|
27
|
+
opts[:name_prefix] = @opts[:name_prefix] + '_' + opts[:name_prefix]
|
28
|
+
end
|
29
|
+
|
30
|
+
c = self.class.new(@router, opts)
|
31
|
+
yield c
|
32
|
+
c
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def extract_name(opts)
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
def error_handler(app)
|
41
|
+
@router.error_handler(app)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
class Kazoo::Router
|
2
|
+
|
3
|
+
class Route
|
4
|
+
|
5
|
+
def initialize(path, opts = {})
|
6
|
+
|
7
|
+
@named_params = []
|
8
|
+
@opts = opts
|
9
|
+
|
10
|
+
# Extract & delete the special options
|
11
|
+
@app = opts.delete(:to)
|
12
|
+
|
13
|
+
@path_prefix = opts.delete(:path_prefix)
|
14
|
+
@regex_prefix = opts.delete(:regex_prefix)
|
15
|
+
opts.delete(:name_prefix)
|
16
|
+
|
17
|
+
# Parse the path
|
18
|
+
if path.is_a?(String)
|
19
|
+
|
20
|
+
path = File.join(@path_prefix, path) if @path_prefix
|
21
|
+
|
22
|
+
@passed_string = path
|
23
|
+
|
24
|
+
@parts = path.split('/')
|
25
|
+
@parts.shift if @parts[0].nil?
|
26
|
+
|
27
|
+
regexp_parts = @parts.map { |part|
|
28
|
+
# extracts the names of the path
|
29
|
+
if matches = part.match(/^:([a-z]+[a-z0-9_]*)$/i)
|
30
|
+
@named_params << matches[1].downcase
|
31
|
+
"([^\/]+)"
|
32
|
+
elsif part
|
33
|
+
part
|
34
|
+
else
|
35
|
+
raise ArgumentError, 'Paths may not have blank parts'
|
36
|
+
end
|
37
|
+
}
|
38
|
+
final_path = regexp_parts.join('/')
|
39
|
+
elsif path.is_a?(Regexp)
|
40
|
+
final_path = path.inspect
|
41
|
+
final_path.gsub!(/(^\^)|(\$$)/, '') # Remove anchors
|
42
|
+
final_path = File.join(@regex_prefix, file_path) if @regex_prefix
|
43
|
+
else
|
44
|
+
raise ArgumentError, "Invalid type passed to a route: #{path.class.name}. Must be either a string or regexp."
|
45
|
+
end
|
46
|
+
|
47
|
+
final_path = "/#{final_path}" unless final_path.match(%r"^\/")
|
48
|
+
final_path = "#{final_path}/" unless final_path.match(%r"\/$")
|
49
|
+
@matcher = Regexp.new("^#{final_path}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_s
|
53
|
+
@passed_string || @matcher.inspect
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_regexp
|
57
|
+
@matcher
|
58
|
+
end
|
59
|
+
|
60
|
+
def app
|
61
|
+
@app
|
62
|
+
end
|
63
|
+
|
64
|
+
def named_params
|
65
|
+
@named_params
|
66
|
+
end
|
67
|
+
|
68
|
+
def extract_params(path)
|
69
|
+
if matches = @matcher.match(path)
|
70
|
+
obj = @opts.dup
|
71
|
+
named_params.each_with_index { |np, i| obj[np] = matches[i + 1] }
|
72
|
+
obj
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def path(opts = {})
|
77
|
+
|
78
|
+
opts = @opts.merge(opts)
|
79
|
+
|
80
|
+
raise "Path cannot be generated from a Regexp" unless @passed_string
|
81
|
+
|
82
|
+
unused_params = @named_params - opts.keys.map { |key| key.to_s }
|
83
|
+
raise ArgumentError, "You must supply the following params: #{unused_params.inspect}" if unused_params.size > 0
|
84
|
+
|
85
|
+
str = @passed_string.dup
|
86
|
+
|
87
|
+
extra_keys = []
|
88
|
+
|
89
|
+
opts.keys.each { |key|
|
90
|
+
if test = str.sub!(%r"(\:|\*)#{key}", opts[key].to_s)
|
91
|
+
raise ArgumentError, "#{key} requires a value" if opts[key].nil?
|
92
|
+
else
|
93
|
+
extra_keys << key
|
94
|
+
end
|
95
|
+
}
|
96
|
+
|
97
|
+
if extra_keys.size > 0
|
98
|
+
pstring = extra_keys.map { |key|
|
99
|
+
"#{CGI.escape(key.to_s)}=#{CGI.escape(opts[key].to_s)}" unless opts[key].nil?
|
100
|
+
}.compact.join('&')
|
101
|
+
"#{str}?#{pstring}"
|
102
|
+
else
|
103
|
+
str
|
104
|
+
end#if
|
105
|
+
|
106
|
+
end#def
|
107
|
+
|
108
|
+
end#class
|
109
|
+
|
110
|
+
end
|
data/lib/kazoo/sinatra.rb
CHANGED
@@ -2,6 +2,34 @@ require 'sinatra/base'
|
|
2
2
|
|
3
3
|
class Kazoo::Sinatra < Sinatra::Base
|
4
4
|
|
5
|
+
enable :sessions
|
6
|
+
|
7
|
+
before do
|
8
|
+
params.merge!(kenv['params']) if kenv['params']
|
9
|
+
end
|
10
|
+
|
11
|
+
def ksession
|
12
|
+
session['kazoo'] ||= {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def kenv
|
16
|
+
@request.env['kazoo'] ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def current_user=(user)
|
20
|
+
if user
|
21
|
+
ksession['user_id'] = user.id
|
22
|
+
ksession['user_class'] = user.class.name
|
23
|
+
else
|
24
|
+
ksession['user_class'] = ksession['user_id'] = nil
|
25
|
+
end
|
26
|
+
user
|
27
|
+
end
|
28
|
+
|
29
|
+
def current_user
|
30
|
+
@_kcu ||= Kernal.const_get(k).find(ksession['user_id']) if ksession['user_id']
|
31
|
+
end
|
32
|
+
|
5
33
|
def render(engine, data, options = {}, *args)
|
6
34
|
|
7
35
|
if !options[:views] && data.is_a?(Symbol) && !data.to_s.match('/')
|
@@ -45,27 +73,30 @@ class Kazoo::Sinatra < Sinatra::Base
|
|
45
73
|
self.class.paths
|
46
74
|
end
|
47
75
|
|
48
|
-
def url(name, opts = {})
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
url_path = paths[n].split('/').map { |part|
|
53
|
-
next unless part.is_a?(String)
|
54
|
-
if matches = part.match(/^:([a-z_]+)$/i)
|
55
|
-
matched = matches[1].downcase
|
56
|
-
opts[matched] || opts[matched.to_sym] || params[matched] || raise("You need to pass '#{matched}' to generate URL")
|
57
|
-
else
|
58
|
-
part
|
59
|
-
end
|
60
|
-
}.join('/')
|
76
|
+
def url(name = '', opts = {})
|
77
|
+
if name.is_a?(Symbol)
|
78
|
+
raise ArgumentError, "Invalid url name: #{name}" unless paths[name]
|
61
79
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
80
|
+
url_path = paths[name].split('/').map { |part|
|
81
|
+
next unless part.is_a?(String)
|
82
|
+
if matches = part.match(/^:([a-z_]+)$/i)
|
83
|
+
matched = matches[1].downcase
|
84
|
+
opts[matched] || opts[matched.to_sym] || params[matched] || raise("You need to pass '#{matched}' to generate URL")
|
85
|
+
else
|
86
|
+
part
|
87
|
+
end
|
88
|
+
}.join('/')
|
89
|
+
|
90
|
+
# Check for prefix
|
91
|
+
full_path = kenv['HTTP_PREFIX'] ? File.join(kenv['HTTP_PREFIX'], url_path) : url_path
|
92
|
+
|
93
|
+
format = opts[:format] || opts['format']
|
94
|
+
full_path << ".#{format}" if format
|
95
|
+
|
96
|
+
full_path
|
97
|
+
else
|
98
|
+
kenv['HTTP_PREFIX'] ? File.join(kenv['HTTP_PREFIX'], name) : name
|
99
|
+
end
|
69
100
|
end
|
70
101
|
|
71
102
|
private
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Kazoo::Support
|
2
|
+
|
3
|
+
|
4
|
+
def load_files(files)
|
5
|
+
excepted_inits = []
|
6
|
+
files.sort.each do |init|
|
7
|
+
begin
|
8
|
+
require init
|
9
|
+
rescue => e
|
10
|
+
excepted_inits.push([init, {e => 0}])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Go through the ones that might have dependencies on other inits.
|
15
|
+
max_error_size = excepted_inits.size * 4
|
16
|
+
|
17
|
+
while excepted_inits.size > 0
|
18
|
+
|
19
|
+
begin
|
20
|
+
excepted_init = excepted_inits.pop
|
21
|
+
require excepted_init[0]
|
22
|
+
rescue => e
|
23
|
+
c = e.class
|
24
|
+
excepted_init[1][c] ||= 0
|
25
|
+
|
26
|
+
if excepted_init[1][c] > max_error_size
|
27
|
+
raise
|
28
|
+
else
|
29
|
+
excepted_init[1][c] += 1
|
30
|
+
excepted_inits.unshift(excepted_init)
|
31
|
+
end#if
|
32
|
+
|
33
|
+
end#begin
|
34
|
+
|
35
|
+
end#while
|
36
|
+
|
37
|
+
end#def
|
38
|
+
|
39
|
+
|
40
|
+
end#module
|
data/readme.markdown
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
Kazoo
|
2
2
|
=====
|
3
3
|
|
4
|
-
Kazoo is a Ruby
|
4
|
+
Kazoo is a Ruby framework to faciliate modular content management applications. So far, it's a 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.4, so please be aware that it is not production ready yet. Kazoo is on rubygems.org so that you can install it by running:
|
5
5
|
|
6
6
|
gem install kazoo
|
7
7
|
|
8
|
-
The Kazoo router takes
|
8
|
+
The Kazoo router takes paths and matches them to apps. This is how you use it in a config.ru file:
|
9
9
|
|
10
10
|
require 'rubygems'
|
11
11
|
require 'kazoo'
|
12
|
-
require 'kazoo/router'
|
13
12
|
|
14
13
|
# Omitted code that pulls in Sinatra apps...
|
15
14
|
|
@@ -57,4 +56,4 @@ In order to facilitate the fact that apps can be mounted at different paths, url
|
|
57
56
|
<p>This is the generated URL for this page: <%= url(:show, :id => @feed.id) %></p>
|
58
57
|
|
59
58
|
|
60
|
-
If you run into any problems or have suggestions
|
59
|
+
If you run into any problems or have suggestions please submit a ticket at https://github.com/eltiare/kazoo/issues
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../spec_helper')
|
2
|
+
|
3
|
+
describe Kazoo::Router::Route do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@route = Kazoo::Router::Route.new('/your/:relative/is/:adjective')
|
7
|
+
@route2 = Kazoo::Router::Route.new('/testing')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "extracts the variables from a path" do
|
11
|
+
@route.named_params.should eq(['relative', 'adjective'])
|
12
|
+
end
|
13
|
+
|
14
|
+
it "generates a path with variables" do
|
15
|
+
@route.path(:relative => 'mom', :adjective => 'huge').should eq(
|
16
|
+
'/your/mom/is/huge'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "generates a path with extranous variables" do
|
21
|
+
@route.path(:relative => 'mom', :adjective => 'huge', :laughs => 1, :true => 'yes').should eq(
|
22
|
+
'/your/mom/is/huge?laughs=1&true=yes'
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "throws an error if a required var is left out" do
|
27
|
+
lambda { @route.path(:relative => 'mom') }.should raise_error(ArgumentError, /adjective/)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "properly forms a matching regexp" do
|
31
|
+
@route2.to_regexp.inspect.should eq('/^\/testing\//')
|
32
|
+
@route.to_regexp.inspect.should eq('/^\/your\/([^\/]+)\/is\/([^\/]+)\//')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "doesn't match similar segments" do
|
36
|
+
@route2.extract_params('/testing_and_stuff').should eq(nil)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/spec/router_spec.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
|
3
|
+
|
4
|
+
describe Kazoo::Router do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
@proper_response = [200, {'Content-Type' => 'text/plain'}, 'Yay!']
|
8
|
+
@proper_response2 = [200, {'Content-Type' => 'text/plain'}, 'Response2']
|
9
|
+
@not_found_response = [404, {"X-Cascade"=>"pass", "Content-Type"=>"text/plain"}, "The requested URI is not found"]
|
10
|
+
|
11
|
+
handler = lambda { @proper_response }
|
12
|
+
handler2 = lambda { @proper_response2 }
|
13
|
+
|
14
|
+
@router = Kazoo::Router.map do
|
15
|
+
match '/something/:id', :to => handler
|
16
|
+
match '/something', :to => handler
|
17
|
+
match '/something_else', :to => handler2
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
it "routes to the proper handler" do
|
23
|
+
@router.call({ 'PATH_INFO' => '/something' }).should eq(@proper_response)
|
24
|
+
@router.call({ 'PATH_INFO' => '/something/else'}).should eq(@proper_response)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "sets the kazoo params" do
|
28
|
+
env = { 'PATH_INFO' => '/something/123' }
|
29
|
+
@router.call(env)
|
30
|
+
env['kazoo']['params'].should eq({'id' => '123'})
|
31
|
+
end
|
32
|
+
|
33
|
+
it "matches later routes properly" do
|
34
|
+
env = { 'PATH_INFO' => '/something_else/testing_blah' }
|
35
|
+
@router.call(env).should eq(@proper_response2)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
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:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremy Nicoll
|
@@ -36,11 +36,11 @@ cert_chain:
|
|
36
36
|
ZVeyFF4suKZEIEKi
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2011-
|
39
|
+
date: 2011-02-16 00:00:00 -07:00
|
40
40
|
default_executable:
|
41
41
|
dependencies: []
|
42
42
|
|
43
|
-
description:
|
43
|
+
description: A moduler framework to facilitate the development of content management systems
|
44
44
|
email: jnicoll @nspam@ accentuate.me
|
45
45
|
executables: []
|
46
46
|
|
@@ -48,16 +48,29 @@ extensions: []
|
|
48
48
|
|
49
49
|
extra_rdoc_files:
|
50
50
|
- lib/kazoo.rb
|
51
|
+
- lib/kazoo/accessors.rb
|
51
52
|
- lib/kazoo/router.rb
|
53
|
+
- lib/kazoo/router/context.rb
|
54
|
+
- lib/kazoo/router/route.rb
|
52
55
|
- lib/kazoo/sinatra.rb
|
56
|
+
- lib/kazoo/support.rb
|
53
57
|
files:
|
54
58
|
- MIT-License
|
55
59
|
- Manifest
|
56
60
|
- Rakefile
|
57
61
|
- lib/kazoo.rb
|
62
|
+
- lib/kazoo/accessors.rb
|
58
63
|
- lib/kazoo/router.rb
|
64
|
+
- lib/kazoo/router/context.rb
|
65
|
+
- lib/kazoo/router/route.rb
|
59
66
|
- lib/kazoo/sinatra.rb
|
67
|
+
- lib/kazoo/support.rb
|
60
68
|
- readme.markdown
|
69
|
+
- spec/router/context_spec.rb
|
70
|
+
- spec/router/route_spec.rb
|
71
|
+
- spec/router_spec.rb
|
72
|
+
- spec/spec.opts
|
73
|
+
- spec/spec_helper.rb
|
61
74
|
- kazoo.gemspec
|
62
75
|
has_rdoc: true
|
63
76
|
homepage: http://rubykazoo.com
|
@@ -95,9 +108,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
108
|
requirements: []
|
96
109
|
|
97
110
|
rubyforge_project: kazoo
|
98
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.5.0
|
99
112
|
signing_key:
|
100
113
|
specification_version: 3
|
101
|
-
summary:
|
114
|
+
summary: A moduler framework to facilitate the development of content management systems
|
102
115
|
test_files: []
|
103
116
|
|
metadata.gz.sig
CHANGED
Binary file
|