cuba 2.0.0.rc2 → 2.0.0.rc3
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/LICENSE +1 -1
- data/cuba.gemspec +2 -2
- data/lib/cuba/ron.rb +14 -13
- data/lib/cuba/version.rb +2 -2
- data/test/composition.rb +21 -0
- data/test/on.rb +15 -21
- data/test/path.rb +0 -1
- metadata +4 -3
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2010 Michel Martens, Damian Janowski and Cyril David
|
1
|
+
Copyright (c) 2010, 2011 Michel Martens, Damian Janowski and Cyril David
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
of this software and associated documentation files (the "Software"), to deal
|
data/cuba.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cuba"
|
3
|
-
s.version = "2.0.0.
|
3
|
+
s.version = "2.0.0.rc3"
|
4
4
|
s.summary = "Rum based microframework for web applications."
|
5
5
|
s.description = "Cuba is a light wrapper for Rum, a microframework for Rack applications."
|
6
6
|
s.authors = ["Michel Martens"]
|
7
7
|
s.email = ["michel@soveran.com"]
|
8
8
|
s.homepage = "http://github.com/soveran/cuba"
|
9
|
-
s.files = ["LICENSE", "README.markdown", "Rakefile", "lib/cuba/ron.rb", "lib/cuba/test.rb", "lib/cuba/version.rb", "lib/cuba.rb", "cuba.gemspec", "test/accept.rb", "test/captures.rb", "test/extension.rb", "test/helper.rb", "test/host.rb", "test/integration.rb", "test/match.rb", "test/number.rb", "test/on.rb", "test/path.rb", "test/run.rb", "test/segment.rb"]
|
9
|
+
s.files = ["LICENSE", "README.markdown", "Rakefile", "lib/cuba/ron.rb", "lib/cuba/test.rb", "lib/cuba/version.rb", "lib/cuba.rb", "cuba.gemspec", "test/accept.rb", "test/captures.rb", "test/composition.rb", "test/extension.rb", "test/helper.rb", "test/host.rb", "test/integration.rb", "test/match.rb", "test/number.rb", "test/on.rb", "test/path.rb", "test/run.rb", "test/segment.rb"]
|
10
10
|
s.add_dependency "rack", "~> 1.2"
|
11
11
|
s.add_dependency "tilt", "~> 1.2"
|
12
12
|
s.add_development_dependency "cutest", "~> 1.0"
|
data/lib/cuba/ron.rb
CHANGED
@@ -69,11 +69,6 @@ module Cuba
|
|
69
69
|
}.render(self, locals)
|
70
70
|
end
|
71
71
|
|
72
|
-
# Basic wrapper for using Rack session.
|
73
|
-
def session
|
74
|
-
@session ||= env['rack.session']
|
75
|
-
end
|
76
|
-
|
77
72
|
# The heart of the path / verb / any condition matching.
|
78
73
|
#
|
79
74
|
# @example
|
@@ -115,14 +110,20 @@ module Cuba
|
|
115
110
|
# on true, "signup"
|
116
111
|
return unless args.all? { |arg| match(arg) }
|
117
112
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
113
|
+
begin
|
114
|
+
# The captures we yield here were generated and assembled
|
115
|
+
# by evaluating each of the `arg`s above. Most of these
|
116
|
+
# are carried out by #consume.
|
117
|
+
yield *captures
|
118
|
+
|
119
|
+
ensure
|
120
|
+
# Regardless of what happens in the `yield`, we should ensure that
|
121
|
+
# we successfully set `@matched` to true.
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
# At this point, we've successfully matched with some corresponding
|
124
|
+
# matcher, so we can skip all other matchers defined.
|
125
|
+
@matched = true
|
126
|
+
end
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
@@ -134,7 +135,7 @@ module Cuba
|
|
134
135
|
yield
|
135
136
|
|
136
137
|
ensure
|
137
|
-
env["SCRIPT_NAME"], env["PATH_INFO"] = script, path
|
138
|
+
env["SCRIPT_NAME"], env["PATH_INFO"] = script, path unless @matched
|
138
139
|
end
|
139
140
|
private :try
|
140
141
|
|
data/lib/cuba/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Cuba
|
2
|
-
VERSION = "2.0.0.
|
3
|
-
end
|
2
|
+
VERSION = "2.0.0.rc3"
|
3
|
+
end
|
data/test/composition.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path("helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
test "composing on top of a PATH" do
|
4
|
+
Services = Cuba::Ron.new {
|
5
|
+
on "services/:id" do |id|
|
6
|
+
res.write "View #{id}"
|
7
|
+
end
|
8
|
+
}
|
9
|
+
|
10
|
+
Cuba.define do
|
11
|
+
on "provider" do
|
12
|
+
run Services
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/provider/services/101" }
|
17
|
+
|
18
|
+
_, _, resp = Cuba.call(env)
|
19
|
+
|
20
|
+
assert_equal ["View 101"], resp.body
|
21
|
+
end
|
data/test/on.rb
CHANGED
@@ -24,27 +24,6 @@ test "executes on non-false" do
|
|
24
24
|
assert_equal ["+1"], resp.body
|
25
25
|
end
|
26
26
|
|
27
|
-
test "restores SCRIPT_NAME and PATH_INFO" do
|
28
|
-
Cuba.define do
|
29
|
-
on true do
|
30
|
-
env["SCRIPT_NAME"] = "foo"
|
31
|
-
env["PATH_INFO"] = "/hello"
|
32
|
-
|
33
|
-
raise "Something went wrong"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
env = { "SCRIPT_NAME" => "/", "PATH_INFO" => "/hello" }
|
38
|
-
|
39
|
-
begin
|
40
|
-
_, _, resp = Cuba.call(env)
|
41
|
-
rescue
|
42
|
-
end
|
43
|
-
|
44
|
-
assert_equal "/", env["SCRIPT_NAME"]
|
45
|
-
assert_equal "/hello", env["PATH_INFO"]
|
46
|
-
end
|
47
|
-
|
48
27
|
test "ensures SCRIPT_NAME and PATH_INFO are reverted" do
|
49
28
|
Cuba.define do
|
50
29
|
on lambda { env["SCRIPT_NAME"] = "/hello"; false } do
|
@@ -100,4 +79,19 @@ test "finds first match available" do
|
|
100
79
|
_, _, resp = Cuba.call({})
|
101
80
|
|
102
81
|
assert_equal ["bar"], resp.body
|
82
|
+
end
|
83
|
+
|
84
|
+
test "reverts a half-met matcher" do
|
85
|
+
Cuba.define do
|
86
|
+
on "post", false do
|
87
|
+
res.write "Should be unmet"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
env = { "PATH_INFO" => "/post", "SCRIPT_NAME" => "/" }
|
92
|
+
_, _, resp = Cuba.call(env)
|
93
|
+
|
94
|
+
assert_equal [], resp.body
|
95
|
+
assert_equal "/post", env["PATH_INFO"]
|
96
|
+
assert_equal "/", env["SCRIPT_NAME"]
|
103
97
|
end
|
data/test/path.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cuba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 2.0.0.
|
5
|
+
version: 2.0.0.rc3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michel Martens
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-03-03 00:00:00 -03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- cuba.gemspec
|
78
78
|
- test/accept.rb
|
79
79
|
- test/captures.rb
|
80
|
+
- test/composition.rb
|
80
81
|
- test/extension.rb
|
81
82
|
- test/helper.rb
|
82
83
|
- test/host.rb
|
@@ -111,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
112
|
requirements: []
|
112
113
|
|
113
114
|
rubyforge_project:
|
114
|
-
rubygems_version: 1.
|
115
|
+
rubygems_version: 1.6.0
|
115
116
|
signing_key:
|
116
117
|
specification_version: 3
|
117
118
|
summary: Rum based microframework for web applications.
|