ramaze 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -12
- data/bin/ramaze +95 -171
- data/doc/CHANGELOG +387 -4
- data/doc/README +81 -13
- data/doc/meta/announcement.txt +51 -8
- data/doc/meta/configuration.txt +17 -34
- data/doc/meta/internals.txt +34 -4
- data/doc/migrate/1110_to_1111.txt +131 -0
- data/doc/readme_chunks/features.txt +81 -12
- data/doc/readme_chunks/installing.txt +0 -1
- data/doc/tutorial/todolist.html +293 -65
- data/doc/tutorial/{todolist.txt → todolist.mkd} +251 -51
- data/examples/blog/main.rb +1 -1
- data/examples/blog/src/model.rb +0 -1
- data/examples/hello.rb +2 -5
- data/examples/templates/template/external.haml +5 -5
- data/examples/templates/template/external.liquid +1 -1
- data/examples/templates/template/external.mab +8 -8
- data/examples/templates/template/external.rem +30 -0
- data/examples/templates/template/external.rhtml +6 -7
- data/examples/templates/template/external.zmr +13 -9
- data/examples/templates/template_amrita2.rb +8 -8
- data/examples/templates/template_erubis.rb +11 -11
- data/examples/templates/template_ezamar.rb +9 -11
- data/examples/templates/template_haml.rb +13 -13
- data/examples/templates/template_liquid.rb +10 -10
- data/examples/templates/template_markaby.rb +13 -10
- data/examples/templates/template_remarkably.rb +59 -0
- data/examples/todolist/main.rb +1 -7
- data/examples/todolist/src/controller/main.rb +26 -13
- data/examples/todolist/src/element/page.rb +5 -0
- data/examples/whywiki/main.rb +1 -1
- data/lib/proto/main.rb +0 -8
- data/lib/proto/public/css/ramaze_error.css +12 -4
- data/lib/proto/public/error.zmr +6 -25
- data/lib/ramaze.rb +35 -245
- data/lib/ramaze/action.rb +21 -0
- data/lib/ramaze/adapter.rb +94 -29
- data/lib/ramaze/adapter/base.rb +57 -0
- data/lib/ramaze/adapter/mongrel.rb +12 -19
- data/lib/ramaze/adapter/webrick.rb +21 -20
- data/lib/ramaze/cache.rb +47 -3
- data/lib/ramaze/cache/memcached.rb +22 -0
- data/lib/ramaze/cache/yaml_store.rb +19 -0
- data/lib/ramaze/controller.rb +47 -271
- data/lib/ramaze/controller/error.rb +43 -0
- data/lib/ramaze/controller/render.rb +90 -0
- data/lib/ramaze/controller/resolve.rb +147 -0
- data/lib/ramaze/dispatcher.rb +41 -9
- data/lib/ramaze/dispatcher/file.rb +1 -1
- data/lib/ramaze/global.rb +73 -158
- data/lib/ramaze/global/dsl.rb +29 -0
- data/lib/ramaze/global/globalstruct.rb +90 -0
- data/lib/ramaze/helper.rb +1 -1
- data/lib/ramaze/helper/aspect.rb +39 -179
- data/lib/ramaze/helper/cache.rb +8 -9
- data/lib/ramaze/helper/cgi.rb +23 -0
- data/lib/ramaze/helper/file.rb +3 -0
- data/lib/ramaze/helper/inform.rb +3 -0
- data/lib/ramaze/helper/link.rb +56 -63
- data/lib/ramaze/helper/nitroform.rb +4 -0
- data/lib/ramaze/helper/redirect.rb +1 -1
- data/lib/ramaze/inform.rb +6 -2
- data/lib/ramaze/inform/analogger.rb +5 -1
- data/lib/ramaze/inform/hub.rb +1 -1
- data/lib/ramaze/inform/informing.rb +7 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +2 -0
- data/lib/ramaze/snippets/kernel/constant.rb +2 -0
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +2 -0
- data/lib/ramaze/snippets/object/traits.rb +4 -0
- data/lib/ramaze/snippets/openstruct/temp.rb +3 -0
- data/lib/ramaze/snippets/string/DIVIDE.rb +2 -0
- data/lib/ramaze/snippets/string/camel_case.rb +2 -0
- data/lib/ramaze/snippets/string/color.rb +2 -0
- data/lib/ramaze/snippets/string/each.rb +2 -0
- data/lib/ramaze/snippets/string/snake_case.rb +3 -0
- data/lib/ramaze/snippets/struct/fill.rb +8 -2
- data/lib/ramaze/snippets/struct/values_at.rb +16 -0
- data/lib/ramaze/snippets/symbol/to_proc.rb +3 -0
- data/lib/ramaze/sourcereload.rb +89 -0
- data/lib/ramaze/template.rb +21 -12
- data/lib/ramaze/template/amrita2.rb +6 -6
- data/lib/ramaze/template/erubis.rb +4 -9
- data/lib/ramaze/template/ezamar.rb +13 -57
- data/lib/ramaze/template/ezamar/element.rb +10 -12
- data/lib/ramaze/template/ezamar/engine.rb +40 -101
- data/lib/ramaze/template/ezamar/morpher.rb +3 -3
- data/lib/ramaze/template/haml.rb +3 -6
- data/lib/ramaze/template/liquid.rb +4 -9
- data/lib/ramaze/template/markaby.rb +16 -22
- data/lib/ramaze/template/remarkably.rb +28 -0
- data/lib/ramaze/tool/mime.rb +2 -0
- data/lib/ramaze/tool/record.rb +6 -0
- data/lib/ramaze/trinity/request.rb +44 -54
- data/lib/ramaze/trinity/response.rb +1 -1
- data/lib/ramaze/trinity/session.rb +15 -37
- data/lib/ramaze/version.rb +1 -1
- data/rake_tasks/gem.rake +2 -2
- data/rake_tasks/maintaince.rake +42 -1
- data/rake_tasks/spec.rake +45 -0
- data/spec/examples/caching.rb +1 -1
- data/spec/examples/simple.rb +1 -1
- data/spec/examples/templates/template_amrita2.rb +1 -0
- data/spec/examples/templates/template_erubis.rb +2 -1
- data/spec/examples/templates/template_ezamar.rb +1 -1
- data/spec/examples/templates/template_haml.rb +2 -1
- data/spec/examples/templates/template_liquid.rb +2 -1
- data/spec/examples/templates/template_markaby.rb +2 -1
- data/spec/examples/templates/template_remarkably.rb +22 -0
- data/spec/examples/todolist.rb +125 -0
- data/spec/helper.rb +2 -23
- data/spec/helper/minimal.rb +20 -0
- data/spec/helper/mock_http.rb +24 -30
- data/spec/helper/simple_http.rb +2 -2
- data/spec/helper/wrap.rb +6 -9
- data/spec/ramaze/adapter.rb +1 -1
- data/spec/ramaze/adapter/record.rb +31 -0
- data/spec/ramaze/cache.rb +41 -54
- data/spec/ramaze/controller.rb +121 -137
- data/spec/ramaze/controller/template/list.xhtml +1 -0
- data/spec/ramaze/controller/template/other/greet/other.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +27 -3
- data/spec/ramaze/element.rb +11 -7
- data/spec/ramaze/error.rb +1 -1
- data/spec/ramaze/gestalt.rb +2 -0
- data/spec/ramaze/helper/aspect.rb +30 -21
- data/spec/ramaze/helper/auth.rb +1 -1
- data/spec/ramaze/helper/cache.rb +2 -1
- data/spec/ramaze/helper/form.rb +14 -11
- data/spec/ramaze/helper/link.rb +18 -41
- data/spec/ramaze/localize.rb +29 -2
- data/spec/ramaze/morpher.rb +23 -12
- data/spec/ramaze/params.rb +46 -24
- data/spec/ramaze/request.rb +6 -2
- data/spec/ramaze/store/yaml.rb +5 -0
- data/spec/ramaze/template.rb +22 -27
- data/spec/ramaze/template/amrita2.rb +1 -2
- data/spec/ramaze/template/erubis.rb +1 -1
- data/spec/ramaze/template/ezamar.rb +1 -2
- data/spec/ramaze/template/haml.rb +2 -2
- data/spec/ramaze/template/haml/with_vars.haml +1 -1
- data/spec/ramaze/template/liquid.rb +1 -1
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/remarkably.rb +56 -0
- data/spec/ramaze/template/remarkably/external.rem +8 -0
- data/spec/ramaze/template/remarkably/sum.rem +1 -0
- metadata +38 -63
- data/doc/README.html +0 -637
- data/doc/allison/LICENSE +0 -184
- data/doc/allison/README +0 -37
- data/doc/allison/allison.css +0 -299
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/allison.js +0 -307
- data/doc/allison/allison.rb +0 -287
- data/doc/allison/cache/BODY +0 -588
- data/doc/allison/cache/CLASS_INDEX +0 -4
- data/doc/allison/cache/CLASS_PAGE +0 -1
- data/doc/allison/cache/FILE_INDEX +0 -4
- data/doc/allison/cache/FILE_PAGE +0 -1
- data/doc/allison/cache/FONTS +0 -1
- data/doc/allison/cache/FR_INDEX_BODY +0 -1
- data/doc/allison/cache/IMGPATH +0 -1
- data/doc/allison/cache/INDEX +0 -1
- data/doc/allison/cache/JAVASCRIPT +0 -307
- data/doc/allison/cache/METHOD_INDEX +0 -4
- data/doc/allison/cache/METHOD_LIST +0 -1
- data/doc/allison/cache/SRC_PAGE +0 -1
- data/doc/allison/cache/STYLE +0 -321
- data/doc/allison/cache/URL +0 -1
- data/doc/changes.txt +0 -3375
- data/doc/changes.xml +0 -3378
- data/examples/todolist/conf/benchmark.yaml +0 -35
- data/examples/todolist/conf/debug.yaml +0 -34
- data/examples/todolist/conf/live.yaml +0 -33
- data/examples/todolist/conf/silent.yaml +0 -31
- data/examples/todolist/conf/stage.yaml +0 -33
- data/examples/todolist/public/css/coderay.css +0 -105
- data/examples/todolist/public/css/ramaze_error.css +0 -42
- data/lib/proto/conf/benchmark.yaml +0 -21
- data/lib/proto/conf/debug.yaml +0 -21
- data/lib/proto/conf/live.yaml +0 -21
- data/lib/proto/conf/silent.yaml +0 -21
- data/lib/proto/conf/stage.yaml +0 -21
- data/lib/proto/public/css/coderay.css +0 -105
- data/lib/ramaze/http_status.rb +0 -66
- data/lib/ramaze/snippets/hash/keys_to_sym.rb +0 -19
- data/lib/ramaze/snippets/kernel/method.rb +0 -26
- data/lib/ramaze/snippets/method/name.rb +0 -22
- data/lib/ramaze/snippets/ramaze/autoreload.rb +0 -135
- data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +0 -65
- data/spec/all.rb +0 -32
- data/spec/ramaze/conf/locale_de.yaml +0 -6
- data/spec/ramaze/conf/locale_en.yaml +0 -6
- data/spec/ramaze/dependencies.rb +0 -16
- data/spec/ramaze/global.rb +0 -44
data/spec/ramaze/element.rb
CHANGED
@@ -73,31 +73,35 @@ end
|
|
73
73
|
describe "Element" do
|
74
74
|
ramaze(:mapping => {'/' => TCElementController})
|
75
75
|
|
76
|
+
def retrieve(*url)
|
77
|
+
Ramaze::Controller.handle(*url).strip
|
78
|
+
end
|
79
|
+
|
76
80
|
it "simple request" do
|
77
|
-
|
81
|
+
retrieve('/').should == "The index"
|
78
82
|
end
|
79
83
|
|
80
84
|
it "with element" do
|
81
|
-
|
85
|
+
retrieve('/elementy').should == "<wrap> The index </wrap>"
|
82
86
|
end
|
83
87
|
|
84
88
|
it "nested element" do
|
85
|
-
|
89
|
+
retrieve('/nested').should == "<wrap> some stuff <wrap> The index </wrap> more stuff </wrap>"
|
86
90
|
end
|
87
91
|
|
88
92
|
it "with_params" do
|
89
|
-
|
93
|
+
retrieve('/with_params/one/two').should == {'@one' => 'two'}.inspect
|
90
94
|
end
|
91
95
|
|
92
96
|
it "little" do
|
93
|
-
|
97
|
+
retrieve('/little').should == 'little'
|
94
98
|
end
|
95
99
|
|
96
100
|
it "little params" do
|
97
|
-
|
101
|
+
retrieve('/little_params/one/eins').should == {'@one' => 'eins'}.inspect
|
98
102
|
end
|
99
103
|
|
100
104
|
it "templating" do
|
101
|
-
|
105
|
+
retrieve('/templating/10').should == (1..10).to_a.join(', ')
|
102
106
|
end
|
103
107
|
end
|
data/spec/ramaze/error.rb
CHANGED
data/spec/ramaze/gestalt.rb
CHANGED
@@ -5,49 +5,57 @@ require 'spec/helper'
|
|
5
5
|
|
6
6
|
class TCAspectController < Ramaze::Controller
|
7
7
|
map '/'
|
8
|
+
trait :foo => :bar
|
8
9
|
helper :aspect
|
9
10
|
|
10
|
-
def
|
11
|
-
|
12
|
-
def wrap_aspect() '<br />' end
|
13
|
-
|
14
|
-
def test() 'test' end
|
15
|
-
pre :test, :pre_aspect
|
16
|
-
post :test, :post_aspect
|
17
|
-
|
18
|
-
def test_pre() 'test pre' end
|
19
|
-
pre :test_pre, :pre_aspect
|
11
|
+
def test_before() 'test before' end
|
12
|
+
before(:test_before){ '<aspect>' }
|
20
13
|
|
21
|
-
def
|
22
|
-
|
14
|
+
def test_after() 'test after' end
|
15
|
+
after(:test_after){ '</aspect>' }
|
23
16
|
|
24
17
|
def test_wrap() 'test wrap' end
|
25
|
-
wrap
|
18
|
+
wrap(:test_wrap){ '<br />' }
|
26
19
|
end
|
27
20
|
|
28
21
|
class TCAspectAllController < Ramaze::Controller
|
29
22
|
map '/all'
|
30
|
-
trait :foo => :bar
|
31
23
|
|
32
24
|
helper :aspect
|
33
25
|
|
34
|
-
def pre_aspect() '<pre>' end
|
35
|
-
def post_aspect() '</pre>' end
|
36
|
-
|
37
26
|
def test_all_first() 'first' end
|
38
27
|
def test_all_second() 'second' end
|
39
28
|
|
40
|
-
pre
|
41
|
-
|
29
|
+
before_all{ '<pre>' }
|
30
|
+
after_all{ '</pre>' }
|
42
31
|
end
|
43
32
|
|
44
|
-
describe "
|
33
|
+
describe "AspectHelper" do
|
45
34
|
ramaze(:error_page => false)
|
46
35
|
|
47
36
|
it "shouldn't overwrite traits on inclusion" do
|
48
|
-
|
37
|
+
TCAspectController.trait[:foo].should == :bar
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should use before' do
|
41
|
+
get('/test_before').body.should == '<aspect>test before'
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should use after' do
|
45
|
+
get('/test_after').body.should == 'test after</aspect>'
|
49
46
|
end
|
50
47
|
|
48
|
+
it 'should use wrap' do
|
49
|
+
get('/test_wrap').body.should == '<br />test wrap<br />'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should before_all and after_all' do
|
53
|
+
get('/all/test_all_first').body.should == '<pre>first</pre>'
|
54
|
+
get('/all/test_all_second').body.should == '<pre>second</pre>'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
=begin
|
51
59
|
it "pre" do
|
52
60
|
get('/test_pre').body.should == '<aspect>test pre'
|
53
61
|
end
|
@@ -69,3 +77,4 @@ describe "Aspect" do
|
|
69
77
|
get('/all/test_all_second').body.should == '<pre>second</pre>'
|
70
78
|
end
|
71
79
|
end
|
80
|
+
=end
|
data/spec/ramaze/helper/auth.rb
CHANGED
data/spec/ramaze/helper/cache.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
require 'spec/helper'
|
5
5
|
|
6
6
|
class TCCacheHelperController < Ramaze::Controller
|
7
|
+
map '/'
|
7
8
|
helper :cache
|
8
9
|
|
9
10
|
trait :actions_cached => [:cached_action]
|
@@ -36,7 +37,7 @@ class TCCacheHelperController < Ramaze::Controller
|
|
36
37
|
end
|
37
38
|
|
38
39
|
describe "CacheHelper" do
|
39
|
-
ramaze
|
40
|
+
ramaze
|
40
41
|
|
41
42
|
it "testrun" do
|
42
43
|
get('/').body.should == 'TCCacheHelperController'
|
data/spec/ramaze/helper/form.rb
CHANGED
@@ -26,6 +26,7 @@ Logger.send(:class_variable_set, "@@global_logger", Ramaze::Informer.new)
|
|
26
26
|
Og.start :destroy => true
|
27
27
|
|
28
28
|
class TCFormHelperEntryController < Ramaze::Controller
|
29
|
+
map '/'
|
29
30
|
helper :form
|
30
31
|
|
31
32
|
def index
|
@@ -54,6 +55,7 @@ class TCFormHelperEntryController < Ramaze::Controller
|
|
54
55
|
end
|
55
56
|
|
56
57
|
class TCFormHelperEntryTimestampedController < Ramaze::Controller
|
58
|
+
map '/entry_timestamped'
|
57
59
|
helper :form
|
58
60
|
|
59
61
|
def index
|
@@ -66,6 +68,7 @@ class TCFormHelperEntryTimestampedController < Ramaze::Controller
|
|
66
68
|
end
|
67
69
|
|
68
70
|
class TCFormHelperEntryDatedController < Ramaze::Controller
|
71
|
+
map '/entry_dated'
|
69
72
|
helper :form
|
70
73
|
|
71
74
|
def index
|
@@ -79,40 +82,38 @@ end
|
|
79
82
|
|
80
83
|
describe "FormHelper" do
|
81
84
|
describe "Entry" do
|
82
|
-
ramaze
|
85
|
+
ramaze
|
83
86
|
|
84
87
|
it "testrun" do
|
85
|
-
get('/
|
88
|
+
get('/').body.should == 'FormHelper Entry'
|
86
89
|
end
|
87
90
|
|
88
91
|
it "with submit" do
|
89
|
-
get('/
|
92
|
+
get('/form_with_submit').body.should ==
|
90
93
|
%{title: <input type="text" name="title" value="" /><br />\n<input type="submit" />}
|
91
94
|
end
|
92
95
|
|
93
96
|
it "without submit" do
|
94
|
-
get('/
|
97
|
+
get('/form_without_submit').body.should ==
|
95
98
|
%{title: <input type="text" name="title" value="" />}
|
96
99
|
end
|
97
100
|
|
98
101
|
it "with title" do
|
99
|
-
get('/
|
102
|
+
get('/form_with_title').body.should ==
|
100
103
|
%{Title: <input type="text" name="title" value="" /><br />\n<input type="submit" />}
|
101
104
|
end
|
102
105
|
|
103
106
|
it "without title" do
|
104
|
-
get('/
|
107
|
+
get('/form_without_title').body.should ==
|
105
108
|
%{<input type="text" name="title" value="" /><br />\n<input type="submit" />}
|
106
109
|
end
|
107
110
|
|
108
111
|
it "with oid" do
|
109
|
-
get('/
|
112
|
+
get('/form_with_oid').body.should ==
|
110
113
|
%{title: <input type="text" name="title" value="" /><br />\noid: <input type="text" name="oid" value="0" /><br />\n<input type="submit" />}
|
111
114
|
end
|
112
115
|
|
113
116
|
describe "EntryTimestamped" do
|
114
|
-
ramaze :fake_start => true, :mapping => {'/entry_timestamped' => TCFormHelperEntryTimestampedController}
|
115
|
-
|
116
117
|
it "testrun" do
|
117
118
|
get('/entry_timestamped/').body.should == "FormHelper EntryTimestamped"
|
118
119
|
end
|
@@ -124,8 +125,6 @@ describe "FormHelper" do
|
|
124
125
|
end
|
125
126
|
|
126
127
|
describe "EntryDated" do
|
127
|
-
ramaze :fake_start => true, :mapping => {'/entry_dated' => TCFormHelperEntryDatedController}
|
128
|
-
|
129
128
|
it "testrun" do
|
130
129
|
get('/entry_dated').body.should ==
|
131
130
|
"FormHelper Dated"
|
@@ -139,5 +138,9 @@ describe "FormHelper" do
|
|
139
138
|
result.should =~ /<input type="submit" \/>/
|
140
139
|
end
|
141
140
|
end
|
141
|
+
|
142
|
+
after :all do
|
143
|
+
FileUtils.rm('data.db')
|
144
|
+
end
|
142
145
|
end
|
143
146
|
end
|
data/spec/ramaze/helper/link.rb
CHANGED
@@ -2,55 +2,32 @@
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
4
|
require 'spec/helper'
|
5
|
+
require 'ramaze/helper/link'
|
5
6
|
|
6
|
-
class
|
7
|
-
|
8
|
-
|
9
|
-
def index
|
10
|
-
link self
|
11
|
-
end
|
12
|
-
|
13
|
-
def index_with_title
|
14
|
-
link self, :title => 'Foo'
|
15
|
-
end
|
7
|
+
class TCLink < Ramaze::Controller
|
8
|
+
map '/'
|
16
9
|
end
|
17
10
|
|
18
|
-
|
19
|
-
describe "LinkHelper" do
|
20
|
-
ramaze(:mapping => {'/' => TCLinkHelperController})
|
21
|
-
|
11
|
+
describe "A" do
|
22
12
|
include Ramaze::LinkHelper
|
23
13
|
|
24
|
-
|
14
|
+
it 'should build links' do
|
15
|
+
A('title', :href => '/').should == %(<a href="/">title</a>)
|
16
|
+
A('title', :href => '/foo').should == %(<a href="/foo">title</a>)
|
25
17
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
it "link" do
|
32
|
-
link(:foo).should == %{<a href="foo">foo</a>}
|
33
|
-
link(:foo, :bar).should == %{<a href="foo/bar">bar</a>}
|
34
|
-
link(this, :bar).should == %{<a href="/bar">bar</a>}
|
35
|
-
link('/foo/bar').should == %{<a href="/foo/bar">bar</a>}
|
36
|
-
end
|
37
|
-
|
38
|
-
it "link with title" do
|
39
|
-
link(:foo, :title => 'bar').should == %{<a href="foo">bar</a>}
|
18
|
+
a = A('title', :href => '/foo', :class => :none)
|
19
|
+
a.should =~ /class="none"/
|
20
|
+
a.should =~ /href="\/foo"/
|
40
21
|
end
|
22
|
+
end
|
41
23
|
|
42
|
-
|
43
|
-
|
44
|
-
l = link(:foo, :first => :bar, :second => :foobar)
|
45
|
-
m = l.match(%r{<a href="foo\?(.*?)=(.*?);(.*?)=(.*?)">(.*?)</a>}).to_a
|
46
|
-
m.shift
|
47
|
-
m.pop.should == 'foo'
|
48
|
-
Hash[*m].should == {'first' => 'bar', 'second' => 'foobar'}
|
49
|
-
end
|
24
|
+
describe 'R' do
|
25
|
+
include Ramaze::LinkHelper
|
50
26
|
|
51
|
-
it
|
52
|
-
R(
|
53
|
-
R(
|
54
|
-
R(
|
27
|
+
it 'should build urls' do
|
28
|
+
R(TCLink).should == '/'
|
29
|
+
R(TCLink, :foo).should == '/foo'
|
30
|
+
R(TCLink, :foo, :bar).should == '/foo/bar'
|
31
|
+
R(TCLink, :foo, :bar => :baz).should == '/foo?bar=baz'
|
55
32
|
end
|
56
33
|
end
|
data/spec/ramaze/localize.rb
CHANGED
@@ -12,7 +12,7 @@ Ramaze::Tool::Localize.trait :enable => true,
|
|
12
12
|
Ramaze::Dispatcher::Action.trait[:filter] << Ramaze::Tool::Localize
|
13
13
|
|
14
14
|
class TCLocalize < Ramaze::Controller
|
15
|
-
|
15
|
+
map '/'
|
16
16
|
|
17
17
|
def hello lang = 'en'
|
18
18
|
session[:LOCALE] = lang
|
@@ -26,7 +26,30 @@ class TCLocalize < Ramaze::Controller
|
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "Localize" do
|
29
|
-
|
29
|
+
before :all do
|
30
|
+
@dir = File.join(File.dirname(__FILE__), 'conf')
|
31
|
+
FileUtils.mkdir_p(@dir)
|
32
|
+
|
33
|
+
dict = {
|
34
|
+
:de => {
|
35
|
+
'hello' => 'Hallo, Welt!',
|
36
|
+
'this' => 'Das',
|
37
|
+
'is' => 'ist',
|
38
|
+
'a' => 'ein',
|
39
|
+
'test' => 'Test',
|
40
|
+
},
|
41
|
+
:en => {
|
42
|
+
'hello' => 'Hello, World!',
|
43
|
+
'this' => 'this',
|
44
|
+
'is' => 'is',
|
45
|
+
'a' => 'a',
|
46
|
+
'test' => 'test',
|
47
|
+
} }
|
48
|
+
dict.each do |lang, dic|
|
49
|
+
File.open(@dir/"locale_#{lang}.yaml", 'w+'){|fp| fp.print(dic.to_yaml)}
|
50
|
+
end
|
51
|
+
ramaze
|
52
|
+
end
|
30
53
|
|
31
54
|
it "hello world" do
|
32
55
|
get('/hello').body.should == 'Hello, World!'
|
@@ -37,4 +60,8 @@ describe "Localize" do
|
|
37
60
|
get('/advanced').body.should == 'this is a test'
|
38
61
|
get('/advanced/de').body.should == 'Das ist ein Test'
|
39
62
|
end
|
63
|
+
|
64
|
+
after :all do
|
65
|
+
FileUtils.rm_rf(@dir)
|
66
|
+
end
|
40
67
|
end
|
data/spec/ramaze/morpher.rb
CHANGED
@@ -6,6 +6,8 @@ require 'spec/helper'
|
|
6
6
|
testcase_requires 'hpricot'
|
7
7
|
|
8
8
|
class TCMorpherController < Ramaze::Controller
|
9
|
+
map '/'
|
10
|
+
|
9
11
|
def index
|
10
12
|
self.class.name
|
11
13
|
end
|
@@ -49,34 +51,43 @@ class TCMorpherController < Ramaze::Controller
|
|
49
51
|
end
|
50
52
|
|
51
53
|
describe "Morpher" do
|
52
|
-
|
54
|
+
before :all do
|
55
|
+
ramaze
|
56
|
+
Ramaze::Template::Ezamar.trait[:transform_pipeline] = [
|
57
|
+
Ezamar::Element, Ezamar::Morpher, Ezamar::Template
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
def clean_get(*url)
|
62
|
+
get(*url).body.split("\n").join.strip
|
63
|
+
end
|
53
64
|
|
54
65
|
it "testrun" do
|
55
|
-
|
66
|
+
clean_get('/').should == 'TCMorpherController'
|
56
67
|
end
|
57
68
|
|
58
69
|
it "if" do
|
59
|
-
|
60
|
-
|
70
|
+
clean_get('/simple_if').should == '<p>orig</p>'
|
71
|
+
clean_get('/simple_if/bar').should == '<p>bar</p>'
|
61
72
|
end
|
62
73
|
|
63
74
|
it "unless" do
|
64
|
-
|
65
|
-
|
75
|
+
clean_get('/simple_unless').should == '<p>orig</p>'
|
76
|
+
clean_get('/simple_unless/bar').should == '<p>bar</p>'
|
66
77
|
end
|
67
78
|
|
68
79
|
it "for" do
|
69
|
-
|
70
|
-
|
80
|
+
clean_get('/simple_for').should == "<div>0</div><div>1</div>"
|
81
|
+
clean_get('/simple_for/3').should == "<div>0</div><div>1</div><div>2</div><div>3</div>"
|
71
82
|
end
|
72
83
|
|
73
84
|
it "times" do
|
74
|
-
|
75
|
-
|
85
|
+
clean_get('/simple_times').should == "<div>0</div>"
|
86
|
+
clean_get('/simple_times/3').should == "<div>0</div><div>1</div><div>2</div>"
|
76
87
|
end
|
77
88
|
|
78
89
|
it "each" do
|
79
|
-
|
80
|
-
|
90
|
+
clean_get('/simple_each').should == ''
|
91
|
+
clean_get('/simple_each/1/2/3').should == "<div>1</div><div>2</div><div>3</div>"
|
81
92
|
end
|
82
93
|
end
|