cuba 2.1.0 → 2.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cuba.rb +21 -24
- data/lib/cuba/version.rb +1 -1
- metadata +13 -13
data/lib/cuba.rb
CHANGED
@@ -70,15 +70,20 @@ class Cuba
|
|
70
70
|
@env = env
|
71
71
|
@req = Rack::Request.new(env)
|
72
72
|
@res = Rack::Response.new
|
73
|
-
@matched = false
|
74
73
|
|
75
|
-
catch
|
74
|
+
# This `catch` statement will either receive a
|
75
|
+
# rack response tuple via a `halt`, or will
|
76
|
+
# fall back to issuing a 404.
|
77
|
+
#
|
78
|
+
# When it `catch`es a throw, the return value
|
79
|
+
# of this whole `_call` method will be the
|
80
|
+
# rack response tuple, which is exactly what we want.
|
81
|
+
catch(:halt) do
|
76
82
|
instance_eval(&@blk)
|
77
83
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end.call(env)
|
84
|
+
res.status = 404
|
85
|
+
res.finish
|
86
|
+
end
|
82
87
|
end
|
83
88
|
|
84
89
|
# @private Used internally by #render to cache the
|
@@ -131,10 +136,6 @@ class Cuba
|
|
131
136
|
# end
|
132
137
|
#
|
133
138
|
def on(*args, &block)
|
134
|
-
# No use running any other matchers if we've already found a
|
135
|
-
# proper matcher.
|
136
|
-
return if @matched
|
137
|
-
|
138
139
|
try do
|
139
140
|
# For every block, we make sure to reset captures so that
|
140
141
|
# nesting matchers won't mess with each other's captures.
|
@@ -151,20 +152,12 @@ class Cuba
|
|
151
152
|
# on true, "signup"
|
152
153
|
return unless args.all? { |arg| match(arg) }
|
153
154
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
yield *captures
|
155
|
+
# The captures we yield here were generated and assembled
|
156
|
+
# by evaluating each of the `arg`s above. Most of these
|
157
|
+
# are carried out by #consume.
|
158
|
+
yield *captures
|
159
159
|
|
160
|
-
|
161
|
-
# Regardless of what happens in the `yield`, we should ensure that
|
162
|
-
# we successfully set `@matched` to true.
|
163
|
-
|
164
|
-
# At this point, we've successfully matched with some corresponding
|
165
|
-
# matcher, so we can skip all other matchers defined.
|
166
|
-
@matched = true
|
167
|
-
end
|
160
|
+
halt res.finish
|
168
161
|
end
|
169
162
|
end
|
170
163
|
|
@@ -292,7 +285,11 @@ class Cuba
|
|
292
285
|
# res.write "Super secure account info."
|
293
286
|
# end
|
294
287
|
def run(app)
|
295
|
-
|
288
|
+
halt app.call(req.env)
|
289
|
+
end
|
290
|
+
|
291
|
+
def halt(response)
|
292
|
+
throw :halt, response
|
296
293
|
end
|
297
294
|
|
298
295
|
# In order to prevent people from overriding the standard Cuba
|
data/lib/cuba/version.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
5
|
-
prerelease:
|
4
|
+
version: 2.2.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Michel Martens
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-10-19 00:00:00.000000000 -03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153812140 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153812140
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: tilt
|
28
|
-
requirement: &
|
28
|
+
requirement: &2153811720 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2153811720
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: cutest
|
39
|
-
requirement: &
|
39
|
+
requirement: &2153811300 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2153811300
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: capybara
|
50
|
-
requirement: &
|
50
|
+
requirement: &2153849280 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2153849280
|
59
59
|
description: Cuba is a microframework for web applications.
|
60
60
|
email:
|
61
61
|
- michel@soveran.com
|
@@ -104,9 +104,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- - ! '
|
107
|
+
- - ! '>'
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
109
|
+
version: 1.3.1
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
112
|
rubygems_version: 1.6.2
|