amrita2 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +5 -5
- data/Rakefile +85 -0
- data/lib/amrita2/gettext.rb +9 -4
- data/lib/amrita2/template.rb +20 -9
- data/lib/amrita2/testsupport.rb +25 -0
- data/lib/amrita2/version.rb +1 -1
- data/sample/depot/README +160 -0
- data/sample/depot/Rakefile +10 -0
- data/sample/depot/app/views/admin/_form.html.a2 +23 -0
- data/sample/depot/app/views/admin/_form.html.erb +14 -0
- data/sample/depot/app/views/admin/edit.html.a2 +22 -0
- data/sample/depot/app/views/admin/edit.html.erb +10 -0
- data/sample/depot/app/views/admin/list.html.a2 +34 -0
- data/sample/depot/app/views/admin/list.html.erb +37 -0
- data/sample/depot/app/views/admin/new.html.a2 +21 -0
- data/sample/depot/app/views/admin/new.html.erb +9 -0
- data/sample/depot/app/views/admin/show.html.a2 +12 -0
- data/sample/depot/app/views/admin/show.html.erb +13 -0
- data/sample/depot/app/views/info/who_bought.rhtml +14 -0
- data/sample/depot/app/views/info/who_bought.rxml +8 -0
- data/sample/depot/app/views/layouts/admin.a2html +32 -0
- data/sample/depot/app/views/layouts/admin.rhtml +40 -0
- data/sample/depot/app/views/layouts/store.a2html +37 -0
- data/sample/depot/app/views/layouts/store.rhtml +43 -0
- data/sample/depot/app/views/login/add_user.rhtml +33 -0
- data/sample/depot/app/views/login/index.rhtml +9 -0
- data/sample/depot/app/views/login/list_users.rhtml +20 -0
- data/sample/depot/app/views/login/login.rhtml +26 -0
- data/sample/depot/app/views/store/_cart.html.a2 +18 -0
- data/sample/depot/app/views/store/_cart.html.erb +17 -0
- data/sample/depot/app/views/store/_cart_item.html.a2 +16 -0
- data/sample/depot/app/views/store/_cart_item.html.erb +14 -0
- data/sample/depot/app/views/store/add_to_cart.rjs +11 -0
- data/sample/depot/app/views/store/checkout.html.a2 +45 -0
- data/sample/depot/app/views/store/checkout.html.a2.using_macro +32 -0
- data/sample/depot/app/views/store/checkout.html.a2.without_label +37 -0
- data/sample/depot/app/views/store/checkout.html.erb +41 -0
- data/sample/depot/app/views/store/index.html.a2 +19 -0
- data/sample/depot/app/views/store/index.html.erb +22 -0
- data/sample/depot/config/database.yml +24 -0
- data/sample/depot/db/create_database.sql +14 -0
- data/sample/depot/doc/README_FOR_APP +35 -0
- data/sample/depot/lib/tasks/db_schema_version.rake +6 -0
- data/sample/depot/log/development.log +116 -0
- data/sample/depot/log/test.log +347 -0
- data/sample/depot/public/404.html +13 -0
- data/sample/depot/public/500.html +13 -0
- data/sample/depot/public/dispatch.cgi +10 -0
- data/sample/depot/public/dispatch.fcgi +24 -0
- data/sample/depot/public/favicon.ico +0 -0
- data/sample/depot/public/images/auto.jpg +0 -0
- data/sample/depot/public/images/logo.png +0 -0
- data/sample/depot/public/images/rails.png +0 -0
- data/sample/depot/public/images/svn.jpg +0 -0
- data/sample/depot/public/images/utc.jpg +0 -0
- data/sample/depot/public/index.html +282 -0
- data/sample/depot/public/javascripts/application.js +2 -0
- data/sample/depot/public/javascripts/controls.js +832 -0
- data/sample/depot/public/javascripts/dragdrop.js +942 -0
- data/sample/depot/public/javascripts/effects.js +954 -0
- data/sample/depot/public/javascripts/prototype.js +2347 -0
- data/sample/depot/public/robots.txt +1 -0
- data/sample/depot/public/stylesheets/depot.css +227 -0
- data/sample/depot/public/stylesheets/scaffold.css +74 -0
- data/sample/depot/script/about +3 -0
- data/sample/depot/script/breakpointer +3 -0
- data/sample/depot/script/console +3 -0
- data/sample/depot/script/destroy +3 -0
- data/sample/depot/script/generate +3 -0
- data/sample/depot/script/performance/benchmarker +3 -0
- data/sample/depot/script/performance/profiler +3 -0
- data/sample/depot/script/plugin +3 -0
- data/sample/depot/script/process/inspector +3 -0
- data/sample/depot/script/process/reaper +3 -0
- data/sample/depot/script/process/spawner +3 -0
- data/sample/depot/script/runner +3 -0
- data/sample/depot/script/server +3 -0
- data/sample/depot/test/fixtures/line_items.yml +16 -0
- data/sample/depot/test/fixtures/orders.yml +4 -0
- data/sample/depot/test/fixtures/performance/products.yml +8 -0
- data/sample/depot/test/fixtures/products.yml +16 -0
- data/sample/depot/test/fixtures/users.yml +7 -0
- data/sample/depot/vendor/plugins/will_paginate/LICENSE +18 -0
- data/sample/depot/vendor/plugins/will_paginate/README +171 -0
- data/sample/depot/vendor/plugins/will_paginate/Rakefile +27 -0
- data/sample/depot/vendor/plugins/will_paginate/test/console +9 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/companies.yml +24 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +13 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/projects.yml +7 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/replies.yml +34 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/schema.sql +44 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/topics.yml +30 -0
- data/sample/depot/vendor/plugins/will_paginate/test/fixtures/users.yml +35 -0
- data/sample/login_engine/README +182 -0
- data/sample/login_engine/Rakefile +27 -0
- data/sample/login_engine/app/views/layouts/user.a2html +20 -0
- data/sample/login_engine/app/views/layouts/user.rhtml +16 -0
- data/sample/login_engine/app/views/user/_edit.a2html +16 -0
- data/sample/login_engine/app/views/user/_edit.rhtml +11 -0
- data/sample/login_engine/app/views/user/_password.a2html +18 -0
- data/sample/login_engine/app/views/user/_password.rhtml +9 -0
- data/sample/login_engine/app/views/user/change_password.a2html +17 -0
- data/sample/login_engine/app/views/user/change_password.rhtml +17 -0
- data/sample/login_engine/app/views/user/edit.a2html +22 -0
- data/sample/login_engine/app/views/user/edit.rhtml +23 -0
- data/sample/login_engine/app/views/user/forgot_password.rhtml +18 -0
- data/sample/login_engine/app/views/user/home.a2html +12 -0
- data/sample/login_engine/app/views/user/home.rhtml +7 -0
- data/sample/login_engine/app/views/user/login.a2html +16 -0
- data/sample/login_engine/app/views/user/login.rhtml +17 -0
- data/sample/login_engine/app/views/user/logout.rhtml +8 -0
- data/sample/login_engine/app/views/user/signup.a2html +14 -0
- data/sample/login_engine/app/views/user/signup.rhtml +17 -0
- data/sample/login_engine/app/views/user_notify/change_password.rhtml +10 -0
- data/sample/login_engine/app/views/user_notify/delete.rhtml +5 -0
- data/sample/login_engine/app/views/user_notify/forgot_password.rhtml +11 -0
- data/sample/login_engine/app/views/user_notify/pending_delete.rhtml +9 -0
- data/sample/login_engine/app/views/user_notify/signup.rhtml +12 -0
- data/sample/login_engine/config/database.yml +18 -0
- data/sample/login_engine/db/create_database.sql +14 -0
- data/sample/login_engine/db/dev.sqlite3 +0 -0
- data/sample/login_engine/db/test.sqlite3 +0 -0
- data/sample/login_engine/doc/README_FOR_APP +2 -0
- data/sample/login_engine/locale/ja/LC_MESSAGES/login_engine.mo +0 -0
- data/sample/login_engine/log/development.log +330 -0
- data/sample/login_engine/log/test.log +19026 -0
- data/sample/login_engine/po/ja/login_engine.po +248 -0
- data/sample/login_engine/po/login_engine.pot +245 -0
- data/sample/login_engine/public/404.html +30 -0
- data/sample/login_engine/public/500.html +30 -0
- data/sample/login_engine/public/dispatch.cgi +10 -0
- data/sample/login_engine/public/dispatch.fcgi +24 -0
- data/sample/login_engine/public/favicon.ico +0 -0
- data/sample/login_engine/public/images/rails.png +0 -0
- data/sample/login_engine/public/index.html +277 -0
- data/sample/login_engine/public/javascripts/application.js +2 -0
- data/sample/login_engine/public/javascripts/controls.js +833 -0
- data/sample/login_engine/public/javascripts/dragdrop.js +942 -0
- data/sample/login_engine/public/javascripts/effects.js +1088 -0
- data/sample/login_engine/public/javascripts/prototype.js +2385 -0
- data/sample/login_engine/public/robots.txt +1 -0
- data/sample/login_engine/public/stylesheets/login_engine.css +81 -0
- data/sample/login_engine/script/about +3 -0
- data/sample/login_engine/script/breakpointer +3 -0
- data/sample/login_engine/script/console +3 -0
- data/sample/login_engine/script/destroy +3 -0
- data/sample/login_engine/script/generate +3 -0
- data/sample/login_engine/script/performance/benchmarker +3 -0
- data/sample/login_engine/script/performance/profiler +3 -0
- data/sample/login_engine/script/plugin +3 -0
- data/sample/login_engine/script/process/inspector +3 -0
- data/sample/login_engine/script/process/reaper +3 -0
- data/sample/login_engine/script/process/spawner +3 -0
- data/sample/login_engine/script/runner +3 -0
- data/sample/login_engine/script/server +3 -0
- data/sample/login_engine/test/fixtures/users.yml +41 -0
- data/specs/erb_cdata.rb +11 -0
- data/specs/filters.rb +5 -4
- data/specs/gettext/static_text.rb +30 -13
- data/specs/impl/preprocess.rb +58 -54
- metadata +375 -120
- data/sample/hello/test1.rb +0 -23
@@ -0,0 +1 @@
|
|
1
|
+
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
This CSS file is basically the scaffold.css file, and is only
|
4
|
+
included here to demonstrate using CSS files with Engines.
|
5
|
+
|
6
|
+
*/
|
7
|
+
|
8
|
+
body { background-color: #fff; color: #333; }
|
9
|
+
|
10
|
+
body, p, ol, ul, td {
|
11
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
12
|
+
font-size: 13px;
|
13
|
+
line-height: 18px;
|
14
|
+
}
|
15
|
+
|
16
|
+
pre {
|
17
|
+
background-color: #eee;
|
18
|
+
padding: 10px;
|
19
|
+
font-size: 11px;
|
20
|
+
}
|
21
|
+
|
22
|
+
a { color: #000; }
|
23
|
+
a:visited { color: #666; }
|
24
|
+
a:hover { color: #fff; background-color:#000; }
|
25
|
+
|
26
|
+
.fieldWithErrors {
|
27
|
+
padding: 2px;
|
28
|
+
background-color: red;
|
29
|
+
display: table;
|
30
|
+
}
|
31
|
+
|
32
|
+
#ErrorExplanation {
|
33
|
+
width: 400px;
|
34
|
+
border: 2px solid red;
|
35
|
+
padding: 7px;
|
36
|
+
padding-bottom: 12px;
|
37
|
+
margin-bottom: 20px;
|
38
|
+
background-color: #f0f0f0;
|
39
|
+
}
|
40
|
+
|
41
|
+
#ErrorExplanation h2 {
|
42
|
+
text-align: left;
|
43
|
+
font-weight: bold;
|
44
|
+
padding: 5px 5px 5px 15px;
|
45
|
+
font-size: 12px;
|
46
|
+
margin: -7px;
|
47
|
+
background-color: #c00;
|
48
|
+
color: #fff;
|
49
|
+
}
|
50
|
+
|
51
|
+
#ErrorExplanation p {
|
52
|
+
color: #333;
|
53
|
+
margin-bottom: 0;
|
54
|
+
padding: 5px;
|
55
|
+
}
|
56
|
+
|
57
|
+
#ErrorExplanation ul li {
|
58
|
+
font-size: 12px;
|
59
|
+
list-style: square;
|
60
|
+
}
|
61
|
+
|
62
|
+
div.uploadStatus {
|
63
|
+
margin: 5px;
|
64
|
+
}
|
65
|
+
|
66
|
+
div.progressBar {
|
67
|
+
margin: 5px;
|
68
|
+
}
|
69
|
+
|
70
|
+
div.progressBar div.border {
|
71
|
+
background-color: #fff;
|
72
|
+
border: 1px solid grey;
|
73
|
+
width: 100%;
|
74
|
+
}
|
75
|
+
|
76
|
+
div.progressBar div.background {
|
77
|
+
background-color: #333;
|
78
|
+
height: 18px;
|
79
|
+
width: 0%;
|
80
|
+
}
|
81
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
+
|
3
|
+
bob:
|
4
|
+
id: 1000001
|
5
|
+
login: bob
|
6
|
+
salted_password: b1de1d1d2aec05df2be6f02995537c1783f08490 # atest
|
7
|
+
salt: bf3c47e71c0bfeb6288c9b6b5e24e15256a0e407
|
8
|
+
email: bob@test.com
|
9
|
+
verified: 1
|
10
|
+
|
11
|
+
existingbob:
|
12
|
+
id: 1000002
|
13
|
+
login: existingbob
|
14
|
+
salted_password: b1de1d1d2aec05df2be6f02995537c1783f08490 # atest
|
15
|
+
salt: bf3c47e71c0bfeb6288c9b6b5e24e15256a0e407
|
16
|
+
email: existingbob@test.com
|
17
|
+
verified: 1
|
18
|
+
|
19
|
+
longbob:
|
20
|
+
id: 1000003
|
21
|
+
login: longbob
|
22
|
+
salted_password: 53427dca242488e885216a579e362ee888c3ebc1 # alongtest
|
23
|
+
salt: d35a9cc89af83799d9a938a74cb06a11d295aa9c
|
24
|
+
email: longbob@test.com
|
25
|
+
verified: 1
|
26
|
+
|
27
|
+
deletebob1:
|
28
|
+
id: 1000004
|
29
|
+
login: deletebob1
|
30
|
+
salted_password: 53427dca242488e885216a579e362ee888c3ebc1 # alongtest
|
31
|
+
salt: d35a9cc89af83799d9a938a74cb06a11d295aa9c
|
32
|
+
email: deletebob1@test.com
|
33
|
+
verified: 1
|
34
|
+
|
35
|
+
deletebob2:
|
36
|
+
id: 1000005
|
37
|
+
login: deletebob2
|
38
|
+
salted_password: 53427dca242488e885216a579e362ee888c3ebc1 # alongtest
|
39
|
+
salt: d35a9cc89af83799d9a938a74cb06a11d295aa9c
|
40
|
+
email: deletebob2@test.com
|
41
|
+
verified: 1
|
data/specs/erb_cdata.rb
CHANGED
@@ -185,3 +185,14 @@ context "amxml cdata_erb block(keep cdata)" do
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
188
|
+
|
189
|
+
context "erb in amxml " do
|
190
|
+
include Amrita2::Runtime
|
191
|
+
specify " " do
|
192
|
+
text = "<<p %= 1+2 >>"
|
193
|
+
t = Amrita2::Template.new(text, :inline_ruby)
|
194
|
+
t.test_with(binding) do |result|
|
195
|
+
result.should == "<p>3</p>"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
data/specs/filters.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'rexml/document'
|
3
3
|
require 'amrita2'
|
4
4
|
require 'amrita2/testsupport'
|
5
|
+
require 'time'
|
5
6
|
|
6
7
|
include Amrita2
|
7
8
|
include Amrita2::Runtime
|
@@ -13,7 +14,7 @@ context "Repeat Filter" do
|
|
13
14
|
|
14
15
|
specify "with string" do
|
15
16
|
#t = Amrita2::Template.new('<div><span am:src="aaa|Repeat[5]" /></div>')
|
16
|
-
|
17
|
+
|
17
18
|
t = Amrita2::Template.new('<div><<:aaa | Repeat[5] >></div>')
|
18
19
|
t.render_with(:aaa => "A").should_be_samexml_as '<div>AAAAA</div>'
|
19
20
|
end
|
@@ -27,7 +28,7 @@ context "Default Filter" do
|
|
27
28
|
specify "with not nil data" do
|
28
29
|
begin
|
29
30
|
#t = Amrita2::Template.new('<div><span am:src="aaa|Default[123]">aaa</span></div>')
|
30
|
-
|
31
|
+
|
31
32
|
t = Amrita2::Template.new('<div><<:aaa | Default[123] >></div>')
|
32
33
|
t.test_with(:aaa => "xyz") do |result|
|
33
34
|
result.should_be_samexml_as '<div>xyz</div>'
|
@@ -82,7 +83,7 @@ context "Format Filter" do
|
|
82
83
|
|
83
84
|
specify "Integer" do
|
84
85
|
#t = Amrita2::Template.new(%q[<span><span am:src="aaa|Format['(%s)']">aaa</span></span>])
|
85
|
-
|
86
|
+
|
86
87
|
t = Amrita2::Template.new(%q[<span><<:aaa | Format['(%s)']>></span>])
|
87
88
|
t.test_with(:aaa => 123) do |result|
|
88
89
|
result.should_be_samexml_as '(123)'
|
@@ -499,7 +500,7 @@ context "ToHash Filter" do
|
|
499
500
|
|
500
501
|
t.render_with(:a => "A").should_be_samexml_as 'A'
|
501
502
|
end
|
502
|
-
|
503
|
+
|
503
504
|
specify "many keys" do
|
504
505
|
t = Amrita2::Template.new <<-END
|
505
506
|
<<:time | ToHash[:h=>:hour, :m=>:min, :s=>:sec] <
|
@@ -22,15 +22,15 @@ context "gettext static element" do
|
|
22
22
|
Locale.set_current("ja", "JP", "utf8")
|
23
23
|
test_gettext("test1",
|
24
24
|
TEMPFILE,
|
25
|
-
"<span>test message</span>",
|
25
|
+
"<span>test message</span>",
|
26
26
|
[
|
27
27
|
%r[#: /tmp/test.a2html:-],
|
28
28
|
%r[msgid "test message"],
|
29
29
|
],
|
30
|
-
{},
|
30
|
+
{},
|
31
31
|
"テストメッセージ"
|
32
32
|
) do |l|
|
33
|
-
l.sub!(%r[msgid "test message"\nmsgstr ""]m,
|
33
|
+
l.sub!(%r[msgid "test message"\nmsgstr ""]m,
|
34
34
|
%[msgid "test message"\nmsgstr "テストメッセージ"])
|
35
35
|
l
|
36
36
|
end
|
@@ -40,15 +40,15 @@ context "gettext static element" do
|
|
40
40
|
Locale.set_current("ja", "JP", "utf8")
|
41
41
|
test_gettext("test1",
|
42
42
|
TEMPFILE,
|
43
|
-
"<span> test message </span>",
|
43
|
+
"<span> test message </span>",
|
44
44
|
[
|
45
45
|
%r[#: /tmp/test.a2html:-],
|
46
46
|
%r[msgid "test message"],
|
47
47
|
],
|
48
|
-
{},
|
48
|
+
{},
|
49
49
|
"テストメッセージ"
|
50
50
|
) do |l|
|
51
|
-
l.sub!(%r[msgid "test message"\nmsgstr ""]m,
|
51
|
+
l.sub!(%r[msgid "test message"\nmsgstr ""]m,
|
52
52
|
%[msgid "test message"\nmsgstr "テストメッセージ"])
|
53
53
|
l
|
54
54
|
end
|
@@ -57,23 +57,40 @@ context "gettext static element" do
|
|
57
57
|
specify "two messages" do
|
58
58
|
test_gettext("test3",
|
59
59
|
TEMPFILE,
|
60
|
-
"<div><span> test message1 </span><span>test message2</span></div>",
|
60
|
+
"<div><span> test message1 </span><span>test message2</span></div>",
|
61
61
|
[
|
62
62
|
%r[#: /tmp/test.a2html:-],
|
63
63
|
%r[msgid "test message1"],
|
64
64
|
%r[msgid "test message2"],
|
65
65
|
],
|
66
|
-
{},
|
66
|
+
{},
|
67
67
|
"<div>あああいいい</div>"
|
68
68
|
) do |l|
|
69
|
-
l.sub!(%r[msgid "test message1"\nmsgstr ""]m,
|
69
|
+
l.sub!(%r[msgid "test message1"\nmsgstr ""]m,
|
70
70
|
%[msgid "test message1"\nmsgstr "あああ"])
|
71
|
-
l.sub!(%r[msgid "test message2"\nmsgstr ""]m,
|
71
|
+
l.sub!(%r[msgid "test message2"\nmsgstr ""]m,
|
72
72
|
%[msgid "test message2"\nmsgstr "いいい"])
|
73
73
|
l
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
specify "text with html comment" do
|
78
|
+
Locale.set_current("ja", "JP", "utf8")
|
79
|
+
test_gettext("test1",
|
80
|
+
TEMPFILE,
|
81
|
+
"<!-- comment --><span>test message</span>",
|
82
|
+
[
|
83
|
+
%r[#: /tmp/test.a2html:-],
|
84
|
+
%r[msgid "test message"],
|
85
|
+
],
|
86
|
+
{},
|
87
|
+
"<!-- comment -->\nテストメッセージ"
|
88
|
+
) do |l|
|
89
|
+
l.sub!(%r[msgid "test message"\nmsgstr ""]m,
|
90
|
+
%[msgid "test message"\nmsgstr "テストメッセージ"])
|
91
|
+
l
|
92
|
+
end
|
93
|
+
end
|
77
94
|
end
|
78
95
|
|
79
96
|
context "format with gettext" do
|
@@ -84,18 +101,18 @@ context "format with gettext" do
|
|
84
101
|
test_gettext(
|
85
102
|
"format1",
|
86
103
|
TEMPFILE,
|
87
|
-
"<span>%{filename} is %{filesize} byte</span>",
|
104
|
+
"<span>%{filename} is %{filesize} byte</span>",
|
88
105
|
[
|
89
106
|
%r[#: #{TEMPFILE}:-],
|
90
107
|
%r[msgid "%\{filename\} is %\{filesize\} byte"],
|
91
108
|
],
|
92
109
|
{
|
93
|
-
:filename => "foo.rb",
|
110
|
+
:filename => "foo.rb",
|
94
111
|
:filesize => 100
|
95
112
|
},
|
96
113
|
"foo.rbの大きさは100バイトです"
|
97
114
|
) do |l|
|
98
|
-
l.sub!(%r[msgid "%\{filename\} is %\{filesize\} byte"\nmsgstr ""]m,
|
115
|
+
l.sub!(%r[msgid "%\{filename\} is %\{filesize\} byte"\nmsgstr ""]m,
|
99
116
|
%[msgid "%\{filename\} is %\{filesize\} byte"\nmsgstr "%{filename}の大きさは%{filesize}バイトです"])
|
100
117
|
l
|
101
118
|
end
|
data/specs/impl/preprocess.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'rexml/element'
|
3
1
|
require 'amrita2'
|
4
2
|
require 'amrita2/testsupport'
|
5
3
|
|
6
4
|
context "amxml parser" do
|
7
5
|
include Amrita2
|
8
|
-
|
6
|
+
|
9
7
|
it "tag only" do
|
10
8
|
amxml = Amrita2::Core::PreProcessor::AmXml
|
11
9
|
a = amxml.parse(%[a])
|
@@ -13,26 +11,26 @@ context "amxml parser" do
|
|
13
11
|
a.attr.should == ""
|
14
12
|
a.should_not be_has_amxml_attrs
|
15
13
|
end
|
16
|
-
|
14
|
+
|
17
15
|
specify "tag with namespace only" do
|
18
16
|
amxml = Amrita2::Core::PreProcessor::AmXml
|
19
17
|
a = amxml.parse(%[xx:a/])
|
20
18
|
a.tag.should == "xx:a"
|
21
19
|
a.attr.should == ""
|
22
20
|
a.should_not be_has_amxml_attrs
|
23
|
-
|
21
|
+
|
24
22
|
a = amxml.parse(%[xx:a])
|
25
23
|
a.tag.should == "xx"
|
26
24
|
a.attr.should == ""
|
27
25
|
a.should be_has_amxml_attrs
|
28
26
|
a.src_name.should == "a"
|
29
|
-
|
27
|
+
|
30
28
|
a = amxml.parse(%[xx:a b="c"])
|
31
29
|
a.tag.should == "xx:a"
|
32
30
|
a.attr.should == ' b="c"'
|
33
31
|
a.should_not be_has_amxml_attrs
|
34
32
|
end
|
35
|
-
|
33
|
+
|
36
34
|
specify "tag and attrs" do
|
37
35
|
amxml = Amrita2::Core::PreProcessor::AmXml
|
38
36
|
a = amxml.parse(%[a href="http://amrita2.rubyforge.org/"])
|
@@ -59,7 +57,7 @@ context "amxml parser" do
|
|
59
57
|
a.attr.should == %[ y:href='http://amrita2.rubyforge.org/' zz:class="xxx"]
|
60
58
|
a.should_not be_has_amxml_attrs
|
61
59
|
end
|
62
|
-
|
60
|
+
|
63
61
|
specify "src" do
|
64
62
|
amxml = Amrita2::Core::PreProcessor::AmXml
|
65
63
|
a = amxml.parse(%[:xxx])
|
@@ -67,14 +65,14 @@ context "amxml parser" do
|
|
67
65
|
a.attr.should == ""
|
68
66
|
a.should be_has_amxml_attrs
|
69
67
|
a.src_name.should == "xxx"
|
70
|
-
|
68
|
+
|
71
69
|
a = amxml.parse(%[a:xxx])
|
72
70
|
a.tag.should == "a"
|
73
71
|
a.attr.should == ""
|
74
72
|
a.should be_has_amxml_attrs
|
75
73
|
a.src_name.should == "xxx"
|
76
74
|
end
|
77
|
-
|
75
|
+
|
78
76
|
specify "src and filters" do
|
79
77
|
amxml = Amrita2::Core::PreProcessor::AmXml
|
80
78
|
a = amxml.parse(%[a:xxx|Attr])
|
@@ -83,7 +81,7 @@ context "amxml parser" do
|
|
83
81
|
a.should be_has_amxml_attrs
|
84
82
|
a.src_name.should == "xxx"
|
85
83
|
a.filters.should == "Attr"
|
86
|
-
|
84
|
+
|
87
85
|
a = amxml.parse(%[a:xxx| \n Attr])
|
88
86
|
a.tag.should == "a"
|
89
87
|
a.attr.should == ""
|
@@ -91,7 +89,7 @@ context "amxml parser" do
|
|
91
89
|
a.src_name.should == "xxx"
|
92
90
|
a.filters.should == "Attr"
|
93
91
|
end
|
94
|
-
|
92
|
+
|
95
93
|
specify "loop" do
|
96
94
|
amxml = Amrita2::Core::PreProcessor::AmXml
|
97
95
|
a = amxml.parse(%[ [1..5] ])
|
@@ -110,7 +108,7 @@ context "amxml parser" do
|
|
110
108
|
a.filters.should == nil
|
111
109
|
a.for.should == %[1..5]
|
112
110
|
end
|
113
|
-
|
111
|
+
|
114
112
|
specify "cond" do
|
115
113
|
amxml = Amrita2::Core::PreProcessor::AmXml
|
116
114
|
'?![a == 1]'.should match(%r[#{ amxml::S_AMVARS}])
|
@@ -121,7 +119,7 @@ context "amxml parser" do
|
|
121
119
|
a.src_name.should == nil
|
122
120
|
a.filters.should == nil
|
123
121
|
a.skipif.should == "a == 1"
|
124
|
-
|
122
|
+
|
125
123
|
a = amxml.parse(%[a ?[ b == 1 ] ])
|
126
124
|
a.tag.should == "a"
|
127
125
|
a.attr.should == ""
|
@@ -131,7 +129,7 @@ context "amxml parser" do
|
|
131
129
|
a.skipif.should == nil
|
132
130
|
a.skipunless.should == "b == 1"
|
133
131
|
end
|
134
|
-
|
132
|
+
|
135
133
|
specify "value" do
|
136
134
|
amxml = Amrita2::Core::PreProcessor::AmXml
|
137
135
|
a = amxml.parse(%[a { :xxx=>1 }])
|
@@ -176,7 +174,7 @@ context "preprocessor" do
|
|
176
174
|
$3.should == "bbb"
|
177
175
|
end
|
178
176
|
|
179
|
-
specify "check regexp"do
|
177
|
+
specify "check regexp"do
|
180
178
|
tag = %r[\w*]
|
181
179
|
attr = %r[(?:\s*\w+=(?:".*?"|'.*?'))*] #"
|
182
180
|
src_start = %r[(?::| \[|\?\[|\{)]
|
@@ -208,7 +206,7 @@ context "preprocessor" do
|
|
208
206
|
ret = p.process("aaa<![CDATA[bbb]]>cccAAA<![CDATA[BBB]]>CCC")
|
209
207
|
ret.should == "aaa<![CDATA[bbb]]>cccAAA<![CDATA[BBB]]>CCC"
|
210
208
|
end
|
211
|
-
|
209
|
+
|
212
210
|
specify "replace <% %>" do
|
213
211
|
p = Amrita2::Core::PreProcessor.new
|
214
212
|
ret = p.process("<%aaa%>")
|
@@ -216,7 +214,7 @@ context "preprocessor" do
|
|
216
214
|
ret = p.process("a<%b%>c<%d%>e")
|
217
215
|
ret.should == "a<![CDATA[<%b%>]]>c<![CDATA[<%d%>]]>e"
|
218
216
|
end
|
219
|
-
|
217
|
+
|
220
218
|
specify "replace <%= %>" do
|
221
219
|
p = Amrita2::Core::PreProcessor.new
|
222
220
|
ret = p.process("<%=aaa%>")
|
@@ -224,14 +222,14 @@ context "preprocessor" do
|
|
224
222
|
ret = p.process("a<%b%>c<%=d%>e")
|
225
223
|
ret.should == "a<![CDATA[<%b%>]]>c<![CDATA[<%=d%>]]>e"
|
226
224
|
end
|
227
|
-
|
225
|
+
|
228
226
|
specify "don't replace <%= %> in cdata" do
|
229
227
|
p = Amrita2::Core::PreProcessor.new
|
230
228
|
ret = p.process("<![CDATA[<%=aaa%>]]>")
|
231
229
|
ret.should == "<![CDATA[<%=aaa%>]]>"
|
232
230
|
ret = p.process("a<%=b%>c<![CDATA[<%d%>]]>e")
|
233
231
|
ret.should == "a<![CDATA[<%=b%>]]>c<![CDATA[<%d%>]]>e"
|
234
|
-
|
232
|
+
|
235
233
|
s = <<-END
|
236
234
|
<![CDATA[
|
237
235
|
<% a = 1 %>
|
@@ -240,7 +238,7 @@ context "preprocessor" do
|
|
240
238
|
END
|
241
239
|
p.process(s).should == s
|
242
240
|
end
|
243
|
-
|
241
|
+
|
244
242
|
specify "not replace <%= %> in cdata in real" do
|
245
243
|
text = <<-'END'
|
246
244
|
<ul>
|
@@ -259,21 +257,21 @@ context "preprocessor" do
|
|
259
257
|
|
260
258
|
text.should == ret
|
261
259
|
end
|
262
|
-
|
260
|
+
|
263
261
|
specify "section" do
|
264
262
|
pp = Amrita2::Core::PreProcessor.new
|
265
263
|
ret = pp.process("aaa<%(Section1)xxx%>bbb")
|
266
264
|
ret.should == "aaabbb"
|
267
265
|
pp.sections[:Section1].should == "xxx"
|
268
266
|
end
|
269
|
-
|
267
|
+
|
270
268
|
specify "section and cdata" do
|
271
269
|
pp = Amrita2::Core::PreProcessor.new
|
272
270
|
ret = pp.process("aaa<%(Section1)xxx%>bbb<%ccc%>ddd")
|
273
271
|
ret.should == "aaabbb<![CDATA[<%ccc%>]]>ddd"
|
274
272
|
pp.sections[:Section1].should == "xxx"
|
275
273
|
end
|
276
|
-
|
274
|
+
|
277
275
|
specify "two sections and cdata" do
|
278
276
|
pp = Amrita2::Core::PreProcessor.new
|
279
277
|
ret = pp.process("aaa<%(Section1)xxx%>bbb<%ccc%>ddd<%(Section2)yyy%>eee")
|
@@ -281,7 +279,7 @@ context "preprocessor" do
|
|
281
279
|
pp.sections[:Section1].should == "xxx"
|
282
280
|
pp.sections[:Section2].should == "yyy"
|
283
281
|
end
|
284
|
-
|
282
|
+
|
285
283
|
specify "two sections and cdata with nest" do
|
286
284
|
pp = Amrita2::Core::PreProcessor.new
|
287
285
|
ret = pp.process("aaa<%(Section1)<%=1%>xxx%>bbb<%%<%=2%>ccc%>ddd<%(Section2)<%=3%>yyy%>eee")
|
@@ -289,7 +287,7 @@ context "preprocessor" do
|
|
289
287
|
pp.sections[:Section1].should == "<%=1%>xxx"
|
290
288
|
pp.sections[:Section2].should == "<%=3%>yyy"
|
291
289
|
end
|
292
|
-
|
290
|
+
|
293
291
|
specify "nbsp" do
|
294
292
|
pp = Amrita2::Core::PreProcessor.new
|
295
293
|
ret = pp.process(" &")
|
@@ -300,11 +298,11 @@ end
|
|
300
298
|
|
301
299
|
context "amxml inline" do
|
302
300
|
include Amrita2
|
303
|
-
|
301
|
+
|
304
302
|
specify "inline" do
|
305
303
|
p = Amrita2::Core::PreProcessor.new
|
306
304
|
ret = p.process("<<a>>") #"
|
307
|
-
ret.should == "<a />"
|
305
|
+
ret.should == "<a />"
|
308
306
|
ret = p.process("<<a:xxx>>")
|
309
307
|
ret.should == "<a am:src='xxx' />"
|
310
308
|
ret = p.process("<<p class='text':aaa>>")
|
@@ -317,21 +315,21 @@ context "amxml inline" do
|
|
317
315
|
p.process("<<h3:title>>").should == "<h3 am:src='title' />"
|
318
316
|
p.process("<<h3 class='title':title>>").should == "<h3 am:src='title' class='title' />"
|
319
317
|
end
|
320
|
-
|
318
|
+
|
321
319
|
specify "inline skipif" do
|
322
320
|
p = Amrita2::Core::PreProcessor.new
|
323
|
-
ret = p.process("<<a ?[a == 1]>>")
|
321
|
+
ret = p.process("<<a ?[a == 1]>>")
|
324
322
|
ret.should == "<a am:skipif='not(a == 1)' />"
|
325
|
-
ret = p.process("<<a ?![a == 1]>>")
|
323
|
+
ret = p.process("<<a ?![a == 1]>>")
|
326
324
|
ret.should == "<a am:skipif='a == 1' />"
|
327
325
|
end
|
328
|
-
|
326
|
+
|
329
327
|
specify "inline anonymous tag" do
|
330
328
|
p = Amrita2::Core::PreProcessor.new
|
331
329
|
ret = p.process("<<:xxx>>")
|
332
330
|
ret.should == "<_ am:src='xxx' />"
|
333
331
|
end
|
334
|
-
|
332
|
+
|
335
333
|
specify "inline filter" do
|
336
334
|
r = %r[#{Amrita2::Core::PreProcessor::AmXml::S_SRC_AND_FILTERS }]
|
337
335
|
":a|A|B".should match(r)
|
@@ -347,15 +345,15 @@ context "amxml inline" do
|
|
347
345
|
|
348
346
|
ret = p.process(%[<<a:|Attr[:href=>:url, :body=>:description]>>])
|
349
347
|
ret.should == %[<a am:filter='Attr[:href=>:url, :body=>:description]' />]
|
350
|
-
|
348
|
+
|
351
349
|
ret = p.process(%[<<:|Each[:class=>[:odd, :even]]|Attr[:class,:body=>:no]>>])
|
352
350
|
ret.should == %[<_ am:filter='Each[:class=>[:odd, :even]]|Attr[:class,:body=>:no]' />]
|
353
351
|
ret = p.process(%[<<:|Each[:class=>[:odd, :even]]|\nAttr[:class,:body=>:no]>>])
|
354
352
|
ret.should == %[<_ am:filter='Each[:class=>[:odd, :even]]|\nAttr[:class,:body=>:no]' />]
|
355
353
|
ret = p.process(%[<<a:website\|Attr>>])
|
356
354
|
ret.should == %[<a am:src='website|Attr' />]
|
357
|
-
end
|
358
|
-
|
355
|
+
end
|
356
|
+
|
359
357
|
specify "css selecter like" do
|
360
358
|
p = Amrita2::Core::PreProcessor.new
|
361
359
|
|
@@ -372,24 +370,30 @@ context "amxml inline" do
|
|
372
370
|
ret = p.process("<<div.cart-title>>")
|
373
371
|
ret.should == '<div class="cart-title" />'
|
374
372
|
end
|
373
|
+
specify "css selecter like" do
|
374
|
+
p = Amrita2::Core::PreProcessor.new
|
375
|
+
|
376
|
+
ret = p.process("<<p %= 1+2 >>")
|
377
|
+
ret.should == '<p><![CDATA[<%= 1+2 %>]]></p>'
|
378
|
+
end
|
375
379
|
end
|
376
380
|
|
377
381
|
context "amxml block" do
|
378
382
|
include Amrita2
|
379
|
-
|
383
|
+
|
380
384
|
specify "simple" do
|
381
385
|
|
382
386
|
p = Amrita2::Core::PreProcessor.new
|
383
387
|
p.process(<<-END).should_be_samexml_as("<_ am:src='title' /> ")
|
384
388
|
<<:title>>
|
385
389
|
END
|
386
|
-
|
390
|
+
|
387
391
|
p = Amrita2::Core::PreProcessor.new
|
388
392
|
p.process(<<-END).should_be_samexml_as("<html>test</html>")
|
389
393
|
<<html<
|
390
394
|
test
|
391
395
|
END
|
392
|
-
|
396
|
+
|
393
397
|
p = Amrita2::Core::PreProcessor.new
|
394
398
|
p.process(<<-END).should_be_samexml_as('<div class="cart-title">test</div>')
|
395
399
|
<<div.cart-title<
|
@@ -497,7 +501,7 @@ context "amxml block" do
|
|
497
501
|
:style => @cart.items.empty? ? "display: none" : nil
|
498
502
|
} <
|
499
503
|
%= render(:partial => "cart", :object => @cart)
|
500
|
-
|
504
|
+
|
501
505
|
END
|
502
506
|
<div am:v='HashDelegator.new($_) { {:style => @cart.items.empty? ? "display: none" : nil} }' id="cart">
|
503
507
|
<![CDATA[<%
|
@@ -512,7 +516,7 @@ END
|
|
512
516
|
|
513
517
|
p.process(<<-END).should_be_samexml_as(<<-END)
|
514
518
|
<<table<
|
515
|
-
<<tr:clients
|
519
|
+
<<tr:clients
|
516
520
|
|NVar[:surname, :firstname, :email]<
|
517
521
|
<td>$1, $2</td>
|
518
522
|
<td><a href="mailto:$3">$3</a></td>
|
@@ -558,16 +562,16 @@ END
|
|
558
562
|
END
|
559
563
|
|
560
564
|
a = p.process(<<-END)
|
561
|
-
<<
|
562
|
-
[1..5] <
|
565
|
+
<<
|
566
|
+
[1..5] <
|
563
567
|
<<?[ ($_%2) == 0
|
564
|
-
|
568
|
+
|
565
569
|
] <
|
566
570
|
<< {
|
567
571
|
:no => $_,
|
568
572
|
:square=> $_*$_
|
569
573
|
} <
|
570
|
-
|
574
|
+
|
571
575
|
<<li<
|
572
576
|
<<:no>> * <<:no>> = <<:square>>
|
573
577
|
END
|
@@ -585,25 +589,25 @@ end
|
|
585
589
|
|
586
590
|
context "amxml erb" do
|
587
591
|
include Amrita2
|
588
|
-
|
592
|
+
|
589
593
|
specify "simple" do
|
590
594
|
p = Amrita2::Core::PreProcessor.new
|
591
595
|
|
592
|
-
p.process(<<-END).should == (<<-END).strip
|
596
|
+
p.process(<<-END).gsub("% ", '%').should == (<<-END).strip
|
593
597
|
<<div<
|
594
598
|
% a = 1
|
595
599
|
END
|
596
|
-
<div ><![CDATA[<%
|
600
|
+
<div ><![CDATA[<%
|
597
601
|
a = 1
|
598
602
|
%>]]>
|
599
603
|
</div>
|
600
604
|
END
|
601
|
-
p.process(<<-END).should == (<<-END).strip
|
605
|
+
p.process(<<-END).gsub("% ", '%').gsub(" \n", "\n").should == (<<-END).strip
|
602
606
|
<<div<
|
603
607
|
%= a + 1
|
604
608
|
END
|
605
|
-
<div ><![CDATA[<%
|
606
|
-
_erbout.concat(eval(%{ a + 1}).to_s)
|
609
|
+
<div ><![CDATA[<%
|
610
|
+
_erbout.concat(eval(%{ a + 1}).to_s)
|
607
611
|
%>]]>
|
608
612
|
</div>
|
609
613
|
END
|
@@ -611,12 +615,12 @@ a = 1
|
|
611
615
|
p.process(<<-END).should_be_samexml_as(<<-END)
|
612
616
|
<<div<
|
613
617
|
% form_remote_tag :url => { :action => :add_to_cart, :id => $_ } do
|
614
|
-
%= submit_tag "Add to Cart"
|
618
|
+
%= submit_tag "Add to Cart"
|
615
619
|
% end
|
616
620
|
END
|
617
621
|
<div>
|
618
622
|
<% form_remote_tag :url => { :action => :add_to_cart, :id => $_ } do
|
619
|
-
_erbout.concat(eval(%{ submit_tag "Add to Cart"
|
623
|
+
_erbout.concat(eval(%{ submit_tag "Add to Cart"}).to_s)
|
620
624
|
end %>
|
621
625
|
</div>
|
622
626
|
END
|
@@ -625,7 +629,7 @@ end
|
|
625
629
|
|
626
630
|
context "cell processor" do
|
627
631
|
include Amrita2
|
628
|
-
|
632
|
+
|
629
633
|
specify "not cell" do
|
630
634
|
l = Amrita2::Core::PreProcessor::LineProcessor.new do |s|
|
631
635
|
s
|