cuba 3.0.0.rc4 → 3.0.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.markdown → README.md} +2 -3
- data/cuba.gemspec +2 -2
- data/lib/cuba.rb +12 -24
- data/test/helper.rb +1 -0
- data/test/root.rb +43 -0
- metadata +9 -10
- data/test/redefinition.rb +0 -17
@@ -42,7 +42,7 @@ Cuba.define do
|
|
42
42
|
res.write "Hello world!"
|
43
43
|
end
|
44
44
|
|
45
|
-
on
|
45
|
+
on root do
|
46
46
|
res.redirect "/hello"
|
47
47
|
end
|
48
48
|
end
|
@@ -86,7 +86,7 @@ Cuba.define do
|
|
86
86
|
on get do
|
87
87
|
|
88
88
|
# /
|
89
|
-
on
|
89
|
+
on root do
|
90
90
|
res.write "Home"
|
91
91
|
end
|
92
92
|
|
@@ -264,7 +264,6 @@ Admin.settings[:layout] = "admin"
|
|
264
264
|
|
265
265
|
assert_equal "guest", Users.settings[:layout]
|
266
266
|
assert_equal "admin", Admin.settings[:layout]
|
267
|
-
|
268
267
|
```
|
269
268
|
|
270
269
|
Feel free to store whatever you find convenient.
|
data/cuba.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cuba"
|
3
|
-
s.version = "3.0.0.
|
3
|
+
s.version = "3.0.0.rc5"
|
4
4
|
s.summary = "Microframework for web applications."
|
5
5
|
s.description = "Cuba is a microframework for web applications."
|
6
6
|
s.authors = ["Michel Martens"]
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.files = Dir[
|
11
11
|
"LICENSE",
|
12
12
|
"CHANGELOG",
|
13
|
-
"README.
|
13
|
+
"README.md",
|
14
14
|
"Rakefile",
|
15
15
|
"lib/**/*.rb",
|
16
16
|
"*.gemspec",
|
data/lib/cuba.rb
CHANGED
@@ -2,8 +2,6 @@ require "rack"
|
|
2
2
|
require "time"
|
3
3
|
|
4
4
|
class Cuba
|
5
|
-
class RedefinitionError < StandardError; end
|
6
|
-
|
7
5
|
class Response
|
8
6
|
attr_accessor :status
|
9
7
|
|
@@ -50,16 +48,6 @@ class Cuba
|
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
|
-
@@methods = []
|
54
|
-
|
55
|
-
class << self
|
56
|
-
undef method_added
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.method_added(meth)
|
60
|
-
@@methods << meth
|
61
|
-
end
|
62
|
-
|
63
51
|
def self.reset!
|
64
52
|
@app = nil
|
65
53
|
@prototype = nil
|
@@ -287,6 +275,18 @@ class Cuba
|
|
287
275
|
true
|
288
276
|
end
|
289
277
|
|
278
|
+
# Access the root of the application.
|
279
|
+
#
|
280
|
+
# @example
|
281
|
+
#
|
282
|
+
# # GET /
|
283
|
+
# on root do
|
284
|
+
# res.write "Home"
|
285
|
+
# end
|
286
|
+
def root
|
287
|
+
env["PATH_INFO"] == "/" || env["PATH_INFO"] == ""
|
288
|
+
end
|
289
|
+
|
290
290
|
# Syntatic sugar for providing HTTP Verb matching.
|
291
291
|
#
|
292
292
|
# @example
|
@@ -320,16 +320,4 @@ class Cuba
|
|
320
320
|
def halt(response)
|
321
321
|
throw :halt, response
|
322
322
|
end
|
323
|
-
|
324
|
-
class << self
|
325
|
-
undef method_added
|
326
|
-
end
|
327
|
-
|
328
|
-
# In order to prevent people from overriding the standard Cuba
|
329
|
-
# methods like `get`, `put`, etc, we add this as a safety measure.
|
330
|
-
def self.method_added(meth)
|
331
|
-
if @@methods.include?(meth)
|
332
|
-
raise RedefinitionError, meth
|
333
|
-
end
|
334
|
-
end
|
335
323
|
end
|
data/test/helper.rb
CHANGED
data/test/root.rb
CHANGED
@@ -38,3 +38,46 @@ test "nested empty segments" do
|
|
38
38
|
|
39
39
|
assert_response resp, ["IT WORKS!", "///1"]
|
40
40
|
end
|
41
|
+
|
42
|
+
test "/events/? scenario" do
|
43
|
+
class Events < Cuba
|
44
|
+
define do
|
45
|
+
on root do
|
46
|
+
res.write "Hooray"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Cuba.define do
|
52
|
+
on "events" do
|
53
|
+
run Events
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
env = {
|
58
|
+
"SCRIPT_NAME" => "",
|
59
|
+
"PATH_INFO" => "/events"
|
60
|
+
}
|
61
|
+
|
62
|
+
_, _, resp = Cuba.call(env)
|
63
|
+
|
64
|
+
assert_response resp, ["Hooray"]
|
65
|
+
|
66
|
+
env = {
|
67
|
+
"SCRIPT_NAME" => "",
|
68
|
+
"PATH_INFO" => "/events/"
|
69
|
+
}
|
70
|
+
|
71
|
+
_, _, resp = Cuba.call(env)
|
72
|
+
|
73
|
+
assert_response resp, ["Hooray"]
|
74
|
+
|
75
|
+
env = {
|
76
|
+
"SCRIPT_NAME" => "",
|
77
|
+
"PATH_INFO" => "/events/a"
|
78
|
+
}
|
79
|
+
|
80
|
+
_, _, resp = Cuba.call(env)
|
81
|
+
|
82
|
+
assert_response resp, []
|
83
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.rc5
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
16
|
-
requirement: &
|
16
|
+
requirement: &2151872760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2151872760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: cutest
|
27
|
-
requirement: &
|
27
|
+
requirement: &2151870200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2151870200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: capybara
|
38
|
-
requirement: &
|
38
|
+
requirement: &2151869640 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2151869640
|
47
47
|
description: Cuba is a microframework for web applications.
|
48
48
|
email:
|
49
49
|
- michel@soveran.com
|
@@ -53,7 +53,7 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- LICENSE
|
55
55
|
- CHANGELOG
|
56
|
-
- README.
|
56
|
+
- README.md
|
57
57
|
- Rakefile
|
58
58
|
- lib/cuba/render.rb
|
59
59
|
- lib/cuba/test.rb
|
@@ -74,7 +74,6 @@ files:
|
|
74
74
|
- test/param.rb
|
75
75
|
- test/path.rb
|
76
76
|
- test/plugin.rb
|
77
|
-
- test/redefinition.rb
|
78
77
|
- test/redirect.rb
|
79
78
|
- test/render.rb
|
80
79
|
- test/root.rb
|
data/test/redefinition.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require File.expand_path("helper", File.dirname(__FILE__))
|
2
|
-
|
3
|
-
test "adding your new custom helpers is ok" do
|
4
|
-
class Cuba
|
5
|
-
def foobar
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
test "redefining standard Cuba methods fails" do
|
11
|
-
assert_raise Cuba::RedefinitionError do
|
12
|
-
class Cuba
|
13
|
-
def get
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|