cuba-contrib 3.0.1 → 3.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/cuba-contrib.gemspec +2 -2
- data/lib/cuba/contrib/mote.rb +11 -6
- data/test/mote.rb +42 -9
- metadata +29 -14
data/cuba-contrib.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cuba-contrib"
|
3
|
-
s.version = "3.0.
|
3
|
+
s.version = "3.1.0.rc1"
|
4
4
|
s.summary = "Cuba plugins and utilities."
|
5
5
|
s.description = "Includes various helper tools for Cuba."
|
6
6
|
s.authors = ["Cyril David"]
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
"views/*.mote"
|
18
18
|
]
|
19
19
|
|
20
|
-
s.add_dependency "cuba", "
|
20
|
+
s.add_dependency "cuba", "3.0.1.rc3"
|
21
21
|
s.add_development_dependency "cutest"
|
22
22
|
s.add_development_dependency "capybara"
|
23
23
|
end
|
data/lib/cuba/contrib/mote.rb
CHANGED
@@ -5,28 +5,33 @@ class Cuba
|
|
5
5
|
include ::Mote::Helpers
|
6
6
|
|
7
7
|
def self.setup(app)
|
8
|
-
app.settings[:
|
9
|
-
app.settings[:
|
8
|
+
app.settings[:mote] ||= {}
|
9
|
+
app.settings[:mote][:views] ||= File.expand_path("views", Dir.pwd)
|
10
|
+
app.settings[:mote][:layout] ||= "layout"
|
10
11
|
end
|
11
12
|
|
12
13
|
def partial(template, locals = {})
|
13
|
-
mote(mote_path(template), locals)
|
14
|
+
mote(mote_path(template), locals.merge(this: self))
|
14
15
|
end
|
15
16
|
|
16
|
-
def view(template, locals = {}, layout = settings[:layout])
|
17
|
+
def view(template, locals = {}, layout = settings[:mote][:layout])
|
17
18
|
raise NoLayout.new(self) unless layout
|
18
19
|
|
19
20
|
partial(layout, locals.merge(mote_vars(partial(template, locals))))
|
20
21
|
end
|
21
22
|
|
23
|
+
def render(template, locals = {}, layout = settings[:mote][:layout])
|
24
|
+
res.write view(template, locals, layout)
|
25
|
+
end
|
26
|
+
|
22
27
|
def mote_path(template)
|
23
28
|
return template if template.end_with?(".mote")
|
24
29
|
|
25
|
-
File.join(settings[:views], "#{template}.mote")
|
30
|
+
File.join(settings[:mote][:views], "#{template}.mote")
|
26
31
|
end
|
27
32
|
|
28
33
|
def mote_vars(content)
|
29
|
-
{ content: content
|
34
|
+
{ content: content }
|
30
35
|
end
|
31
36
|
|
32
37
|
class NoLayout < StandardError
|
data/test/mote.rb
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
require_relative "helper"
|
2
2
|
|
3
3
|
test "doesn't override already existing settings" do
|
4
|
-
Cuba.settings[:
|
5
|
-
Cuba.settings[:
|
4
|
+
Cuba.settings[:mote] ||= {}
|
5
|
+
Cuba.settings[:mote][:views] = "./templates"
|
6
|
+
Cuba.settings[:mote][:layout] = "guest"
|
6
7
|
|
7
8
|
Cuba.plugin Cuba::Mote
|
8
9
|
|
9
|
-
assert_equal "./templates", Cuba.settings[:views]
|
10
|
-
assert_equal "guest", Cuba.settings[:layout]
|
10
|
+
assert_equal "./templates", Cuba.settings[:mote][:views]
|
11
|
+
assert_equal "guest", Cuba.settings[:mote][:layout]
|
11
12
|
end
|
12
13
|
|
13
14
|
Cuba.plugin Cuba::Mote
|
14
15
|
Cuba.use Rack::Session::Cookie
|
15
|
-
Cuba.settings[:views] = "./test/views"
|
16
|
-
Cuba.settings[:layout] = "layout"
|
16
|
+
Cuba.settings[:mote][:views] = "./test/views"
|
17
|
+
Cuba.settings[:mote][:layout] = "layout"
|
17
18
|
|
18
19
|
Cuba.define do
|
19
20
|
on "frag" do
|
@@ -24,25 +25,57 @@ Cuba.define do
|
|
24
25
|
res.write view("home", title: "Hola")
|
25
26
|
end
|
26
27
|
|
28
|
+
on "render" do
|
29
|
+
render("home", title: "Hola")
|
30
|
+
end
|
31
|
+
|
32
|
+
on "partial-fu" do
|
33
|
+
res.write partial("partial1")
|
34
|
+
end
|
35
|
+
|
27
36
|
on "abs_path" do
|
28
37
|
res.write view("./test/views/custom/abs_path.mote", title: "Absolute")
|
29
38
|
end
|
30
39
|
end
|
31
40
|
|
32
|
-
test do
|
41
|
+
test "view" do
|
33
42
|
_, _, body = Cuba.call({ "PATH_INFO" => "/", "SCRIPT_NAME" => "" })
|
34
43
|
|
35
44
|
assert_response body, ["<title>Hola</title>\n<h1>Home</h1>\n\n"]
|
36
45
|
end
|
37
46
|
|
38
|
-
test do
|
47
|
+
test "render" do
|
48
|
+
_, _, body = Cuba.call({ "PATH_INFO" => "/render", "SCRIPT_NAME" => "" })
|
49
|
+
|
50
|
+
assert_response body, ["<title>Hola</title>\n<h1>Home</h1>\n\n"]
|
51
|
+
end
|
52
|
+
|
53
|
+
test "partial-fu" do
|
54
|
+
# We verify that nesting partials and contexts are passed along properly.
|
55
|
+
_, _, body = Cuba.call({ "PATH_INFO" => "/partial-fu/A", "SCRIPT_NAME" => "" })
|
56
|
+
assert_response body, ["partial1\npartial2\n/partial-fu/A\n\n"]
|
57
|
+
|
58
|
+
# And that we're able to use req.path in the inner partials without an issue.
|
59
|
+
_, _, body = Cuba.call({ "PATH_INFO" => "/partial-fu/B", "SCRIPT_NAME" => "" })
|
60
|
+
assert_response body, ["partial1\npartial2\n/partial-fu/B\n\n"]
|
61
|
+
end
|
62
|
+
|
63
|
+
test "partial" do
|
39
64
|
_, _, body = Cuba.call({ "PATH_INFO" => "/frag", "SCRIPT_NAME" => "" })
|
40
65
|
|
41
66
|
assert_response body, ["<h1>Bar</h1>\n"]
|
42
67
|
end
|
43
68
|
|
44
|
-
test do
|
69
|
+
test "use of absolute mote path" do
|
45
70
|
_, _, body = Cuba.call({ "PATH_INFO" => "/abs_path", "SCRIPT_NAME" => "" })
|
46
71
|
|
47
72
|
assert_response body, ["<title>Absolute</title>\n<h1>Abs Path</h1>\n\n"]
|
48
73
|
end
|
74
|
+
|
75
|
+
test "use of absolute mote path for the layout" do
|
76
|
+
Cuba.settings[:mote][:layout] = "./test/views/custom_layout.mote"
|
77
|
+
|
78
|
+
_, _, body = Cuba.call({ "PATH_INFO" => "/", "SCRIPT_NAME" => "" })
|
79
|
+
|
80
|
+
assert_response body, ["<title>Custom Layout: Hola</title>\n<h1>Home</h1>\n\n"]
|
81
|
+
end
|
metadata
CHANGED
@@ -1,30 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuba-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
5
|
-
prerelease:
|
4
|
+
version: 3.1.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Cyril David
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cuba
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.0.1.rc3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.1.rc3
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: cutest
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: capybara
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
description: Includes various helper tools for Cuba.
|
48
63
|
email:
|
49
64
|
- me@cyrildavid.com
|
@@ -87,12 +102,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
103
|
none: false
|
89
104
|
requirements:
|
90
|
-
- - ! '
|
105
|
+
- - ! '>'
|
91
106
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
107
|
+
version: 1.3.1
|
93
108
|
requirements: []
|
94
109
|
rubyforge_project:
|
95
|
-
rubygems_version: 1.8.
|
110
|
+
rubygems_version: 1.8.23
|
96
111
|
signing_key:
|
97
112
|
specification_version: 3
|
98
113
|
summary: Cuba plugins and utilities.
|