kwartz 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +10 -3
- data/README.txt +6 -1
- data/bin/kwartz +1 -1
- data/doc-api/classes/Kwartz.html +2 -2
- data/doc-api/classes/Kwartz/Main.html +2 -2
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +6 -2
- data/doc-api/files/kwartz/assert_rb.html +1 -1
- data/doc-api/files/kwartz/binding/eperl_rb.html +1 -1
- data/doc-api/files/kwartz/binding/erubis_rb.html +1 -1
- data/doc-api/files/kwartz/binding/eruby_rb.html +1 -1
- data/doc-api/files/kwartz/binding/jstl_rb.html +1 -1
- data/doc-api/files/kwartz/binding/php_rb.html +1 -1
- data/doc-api/files/kwartz/binding/pierubis_rb.html +1 -1
- data/doc-api/files/kwartz/binding/rails_rb.html +1 -1
- data/doc-api/files/kwartz/binding/ruby_rb.html +1 -1
- data/doc-api/files/kwartz/binding/struts_rb.html +1 -1
- data/doc-api/files/kwartz/config_rb.html +1 -1
- data/doc-api/files/kwartz/converter_rb.html +1 -1
- data/doc-api/files/kwartz/defun_rb.html +1 -1
- data/doc-api/files/kwartz/error_rb.html +1 -1
- data/doc-api/files/kwartz/helper/rails_rb.html +1 -1
- data/doc-api/files/kwartz/main_rb.html +2 -2
- data/doc-api/files/kwartz/node_rb.html +1 -1
- data/doc-api/files/kwartz/parser_rb.html +1 -1
- data/doc-api/files/kwartz/translator_rb.html +1 -1
- data/doc-api/files/kwartz/util/assert-text-equal_rb.html +1 -1
- data/doc-api/files/kwartz/util/testcase-helper_rb.html +2 -2
- data/doc-api/files/kwartz/util_rb.html +1 -1
- data/doc-api/files/kwartz_rb.html +1 -1
- data/doc/img/fig01.png +0 -0
- data/doc/img/fig02.png +0 -0
- data/doc/img/fig03.png +0 -0
- data/doc/img/fig04.png +0 -0
- data/doc/{p-pattern.html → pattern-catalog.html} +29 -21
- data/doc/pattern-catalog/design.css +51 -0
- data/doc/pattern-catalog/design.html +42 -0
- data/doc/reference.html +23 -261
- data/doc/users-guide.html +70 -44
- data/kwartz.gemspec +13 -9
- data/lib/kwartz.rb +2 -2
- data/lib/kwartz/assert.rb +1 -1
- data/lib/kwartz/binding/eperl.rb +1 -1
- data/lib/kwartz/binding/erubis.rb +1 -1
- data/lib/kwartz/binding/eruby.rb +1 -1
- data/lib/kwartz/binding/jstl.rb +1 -1
- data/lib/kwartz/binding/php.rb +1 -1
- data/lib/kwartz/binding/pierubis.rb +1 -1
- data/lib/kwartz/binding/rails.rb +1 -1
- data/lib/kwartz/binding/ruby.rb +1 -1
- data/lib/kwartz/binding/struts.rb +1 -1
- data/lib/kwartz/config.rb +1 -1
- data/lib/kwartz/converter.rb +1 -1
- data/lib/kwartz/defun.rb +1 -1
- data/lib/kwartz/error.rb +1 -1
- data/lib/kwartz/helper/rails.rb +1 -1
- data/lib/kwartz/main.rb +4 -4
- data/lib/kwartz/node.rb +1 -1
- data/lib/kwartz/parser.rb +1 -1
- data/lib/kwartz/translator.rb +1 -1
- data/lib/kwartz/util.rb +1 -1
- data/lib/kwartz/util/assert-text-equal.rb +1 -1
- data/lib/kwartz/util/testcase-helper.rb +10 -4
- data/test/test-compile.rb +1 -1
- data/test/test-converter.rb +27 -12
- data/test/test-converter.yaml +173 -26
- data/test/test-directives.rb +1 -1
- data/test/test-main.rb +1 -1
- data/test/test-parser.rb +1 -1
- data/test/test-parser.yaml +1 -1
- data/test/test-rails.rb +1 -1
- data/test/test-ruleset.rb +1 -1
- data/test/test-ruleset.yaml +18 -18
- data/test/test.rb +1 -1
- metadata +10 -4
data/lib/kwartz/defun.rb
CHANGED
data/lib/kwartz/error.rb
CHANGED
data/lib/kwartz/helper/rails.rb
CHANGED
data/lib/kwartz/main.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 3.1.
|
2
|
+
### $Rev: 141 $
|
3
|
+
### $Release: 3.1.1 $
|
4
4
|
### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
|
5
5
|
###
|
6
6
|
|
@@ -175,8 +175,8 @@ module Kwartz
|
|
175
175
|
status = 0
|
176
176
|
begin
|
177
177
|
main = Kwartz::Main.new(argv)
|
178
|
-
|
179
|
-
print
|
178
|
+
output = main.execute()
|
179
|
+
print output unless output == nil
|
180
180
|
rescue Kwartz::KwartzError => ex
|
181
181
|
raise ex if $DEBUG
|
182
182
|
$stderr.puts ex.to_s
|
data/lib/kwartz/node.rb
CHANGED
data/lib/kwartz/parser.rb
CHANGED
data/lib/kwartz/translator.rb
CHANGED
data/lib/kwartz/util.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
2
|
### $Rev$
|
3
|
-
### $Release: 3.1.
|
3
|
+
### $Release: 3.1.1 $
|
4
4
|
### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
|
5
5
|
###
|
6
6
|
|
@@ -73,17 +73,21 @@ class Test::Unit::TestCase # :nodoc:
|
|
73
73
|
end
|
74
74
|
|
75
75
|
|
76
|
+
SPECIAL_KEYS = %[exception errormsg]
|
77
|
+
|
76
78
|
def self.load_yaml_testdata(filename, options={}) # :nodoc:
|
77
79
|
identkey = options[:identkey] || 'name'
|
78
80
|
testmethod = options[:testmethod] || '_test'
|
79
81
|
lang = options[:lang]
|
82
|
+
special_keys = options[:special_keys] || SPECIAL_KEYS
|
80
83
|
load_yaml_documents(filename, options) do |ydoc|
|
81
84
|
ident = ydoc[identkey]
|
82
85
|
s = "def test_#{ident}\n"
|
83
86
|
ydoc.each do |key, val|
|
84
87
|
if key[-1] == ?*
|
85
88
|
key = key[0, key.length-1]
|
86
|
-
|
89
|
+
k = special_keys.include?(key) ? 'ruby' : lang
|
90
|
+
val = val[k]
|
87
91
|
end
|
88
92
|
s << " @#{key} = #{val.inspect}\n"
|
89
93
|
end
|
@@ -103,9 +107,10 @@ class Test::Unit::TestCase # :nodoc:
|
|
103
107
|
def self.load_yaml_testdata_with_each_lang(filename, options={}) # :nodoc:
|
104
108
|
identkey = options[:identkey] || 'name'
|
105
109
|
testmethod = options[:testmethod] || '_test'
|
110
|
+
special_keys = options[:special_keys] || SPECIAL_KEYS
|
106
111
|
langs = defined?($lang) && $lang ? [ $lang ] : options[:langs]
|
107
112
|
langs or raise "*** #{method_name()}(): option ':langs' is required."
|
108
|
-
|
113
|
+
|
109
114
|
load_yaml_documents(filename, options) do |ydoc|
|
110
115
|
ident = ydoc[identkey]
|
111
116
|
langs.each do |lang|
|
@@ -114,7 +119,8 @@ class Test::Unit::TestCase # :nodoc:
|
|
114
119
|
ydoc.each do |key, val|
|
115
120
|
if key[-1] == ?*
|
116
121
|
key = key[0, key.length-1]
|
117
|
-
|
122
|
+
k = special_keys.include?(key) ? 'ruby' : lang
|
123
|
+
val = val[k]
|
118
124
|
end
|
119
125
|
s << " @#{key} = #{val.inspect}\n"
|
120
126
|
end
|
data/test/test-compile.rb
CHANGED
data/test/test-converter.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
###
|
2
|
-
### $Rev:
|
3
|
-
### $Release: 3.1.
|
2
|
+
### $Rev: 141 $
|
3
|
+
### $Release: 3.1.1 $
|
4
4
|
### copyright(c) 2004-2006 kuwata-lab.com all rights reserved
|
5
5
|
###
|
6
6
|
|
@@ -13,13 +13,11 @@ class ConverterTest < Test::Unit::TestCase
|
|
13
13
|
## define test methods
|
14
14
|
filename = __FILE__.sub(/\.rb$/, '.yaml')
|
15
15
|
#load_yaml_testdata(filename)
|
16
|
-
|
16
|
+
langs = %w[eruby php jstl eperl]
|
17
|
+
load_yaml_testdata_with_each_lang(filename, :langs=>langs)
|
17
18
|
|
18
19
|
|
19
20
|
def _test
|
20
|
-
#parser = Kwartz::PresentationLogicParser.get_class('css').new
|
21
|
-
#ruleset_list = parser.parse(@plogic)
|
22
|
-
ruleset_list = []
|
23
21
|
(@properties ||= {}).each do |key, val|
|
24
22
|
if key.is_a?(String)
|
25
23
|
key = key.intern
|
@@ -27,15 +25,32 @@ class ConverterTest < Test::Unit::TestCase
|
|
27
25
|
@properties[key] = val
|
28
26
|
end
|
29
27
|
end
|
28
|
+
parser = Kwartz::PresentationLogicParser.get_class('css').new
|
29
|
+
ruleset_list = parser.parse(@plogic.to_s)
|
30
|
+
#ruleset_list = []
|
30
31
|
handler = Kwartz::Handler.get_class(@lang).new(ruleset_list, @properties)
|
31
32
|
converter = Kwartz::TextConverter.new(handler, @properties)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
if @exception
|
34
|
+
error_class = @exception.split(/::/).inject(Object) {|cls, name| cls.const_get(name) }
|
35
|
+
errmsg = nil
|
36
|
+
assert_raise(error_class) do
|
37
|
+
begin
|
38
|
+
stmt_list = converter.convert(@pdata)
|
39
|
+
rescue => ex
|
40
|
+
errmsg = ex.message
|
41
|
+
raise ex
|
42
|
+
end
|
43
|
+
end
|
44
|
+
assert_equal(@errormsg, errmsg)
|
45
|
+
else
|
46
|
+
stmt_list = converter.convert(@pdata)
|
47
|
+
sb = ''
|
48
|
+
stmt_list.each do |stmt|
|
49
|
+
sb << (s = stmt._inspect)
|
50
|
+
sb << "\n" unless s[-1] == ?\n
|
51
|
+
end
|
52
|
+
assert_text_equal(@expected, sb)
|
37
53
|
end
|
38
|
-
assert_text_equal(@expected, sb)
|
39
54
|
end
|
40
55
|
|
41
56
|
|
data/test/test-converter.yaml
CHANGED
@@ -1,3 +1,176 @@
|
|
1
|
+
|
2
|
+
# --------------------------------------------------------------------------------
|
3
|
+
|
4
|
+
###
|
5
|
+
- name: convert01
|
6
|
+
desc: basic test
|
7
|
+
pdata: |
|
8
|
+
<ul>
|
9
|
+
<li>foo</li>
|
10
|
+
</ul>
|
11
|
+
expected: |
|
12
|
+
print("<ul>\n")
|
13
|
+
print(" <li>")
|
14
|
+
print("foo")
|
15
|
+
print("</li>\n")
|
16
|
+
print("</ul>\n")
|
17
|
+
|
18
|
+
###
|
19
|
+
- name: convert02
|
20
|
+
desc: marked element
|
21
|
+
pdata: |
|
22
|
+
<ul id="list">
|
23
|
+
<li id="mark:item">foo</li>
|
24
|
+
</ul>
|
25
|
+
expected: |
|
26
|
+
print("<ul id=\"list\">\n")
|
27
|
+
print(" <li>")
|
28
|
+
print("foo")
|
29
|
+
print("</li>\n")
|
30
|
+
print("</ul>\n")
|
31
|
+
|
32
|
+
###
|
33
|
+
- name: convert03
|
34
|
+
desc: nested element
|
35
|
+
pdata: |
|
36
|
+
<div>
|
37
|
+
<div>
|
38
|
+
<div id="list">
|
39
|
+
<div id="mark:item">
|
40
|
+
<div>foo</div>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
expected: |
|
46
|
+
print("<div>\n")
|
47
|
+
print(" <div>\n")
|
48
|
+
print(" <div id=\"list\">\n")
|
49
|
+
print(" <div>\n")
|
50
|
+
print(" <div>")
|
51
|
+
print("foo")
|
52
|
+
print("</div>\n")
|
53
|
+
print(" </div>\n")
|
54
|
+
print(" </div>\n")
|
55
|
+
print(" </div>\n")
|
56
|
+
print("</div>\n")
|
57
|
+
|
58
|
+
###
|
59
|
+
- name: convert04
|
60
|
+
desc: rest text
|
61
|
+
pdata: |
|
62
|
+
foo
|
63
|
+
bar
|
64
|
+
<ul id="mark:list">
|
65
|
+
</ul>
|
66
|
+
baz
|
67
|
+
boo
|
68
|
+
expected: |
|
69
|
+
print("foo\nbar\n")
|
70
|
+
print("<ul>\n")
|
71
|
+
print("</ul>\n")
|
72
|
+
print("baz\nboo\n")
|
73
|
+
|
74
|
+
###
|
75
|
+
- name: convert05
|
76
|
+
desc: no tags
|
77
|
+
pdata: |
|
78
|
+
foo
|
79
|
+
bar
|
80
|
+
baz
|
81
|
+
expected: |
|
82
|
+
print("foo\nbar\nbaz\n")
|
83
|
+
|
84
|
+
###
|
85
|
+
- name: convert06
|
86
|
+
desc: not well-formed
|
87
|
+
pdata: |
|
88
|
+
<div id="foo">
|
89
|
+
<p><span></b>
|
90
|
+
</div>
|
91
|
+
expected: |
|
92
|
+
print("<div id=\"foo\">\n")
|
93
|
+
print(" <p>")
|
94
|
+
print("<span>")
|
95
|
+
print("</b>\n")
|
96
|
+
print("</div>\n")
|
97
|
+
|
98
|
+
###
|
99
|
+
- name: convert08
|
100
|
+
desc: tag is not closed
|
101
|
+
pdata: |
|
102
|
+
<span>
|
103
|
+
<div id="list">
|
104
|
+
<div id="mark:item">
|
105
|
+
<div>foo
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
</span>
|
109
|
+
exception*:
|
110
|
+
ruby: Kwartz::ConvertError
|
111
|
+
php: KwartzConvertionException
|
112
|
+
java: kwartz.ConverterException
|
113
|
+
errormsg*:
|
114
|
+
ruby: ":2: '<div>' is not closed."
|
115
|
+
php: ":2: '<div>' is not closed."
|
116
|
+
java: ...error message...
|
117
|
+
|
118
|
+
# --------------------------------------------------------------------------------
|
119
|
+
|
120
|
+
###
|
121
|
+
- name: convert11
|
122
|
+
desc: pdata and plogic
|
123
|
+
pdata: |
|
124
|
+
<ul id="mark:list">
|
125
|
+
<li id="mark:item">foo</li>
|
126
|
+
</ul>
|
127
|
+
plogic: |
|
128
|
+
#list {
|
129
|
+
logic: {
|
130
|
+
_stag;
|
131
|
+
foreach (item in list) {
|
132
|
+
_cont;
|
133
|
+
}
|
134
|
+
_etag;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
#item {
|
138
|
+
value: item;
|
139
|
+
}
|
140
|
+
expected: |
|
141
|
+
print("<ul>\n")
|
142
|
+
<% foreach (item in list) {%>
|
143
|
+
print(" <li>")
|
144
|
+
print(<%=item%>)
|
145
|
+
print("</li>\n")
|
146
|
+
<% }%>
|
147
|
+
print("</ul>\n")
|
148
|
+
|
149
|
+
|
150
|
+
###
|
151
|
+
- name: convert12
|
152
|
+
desc: empty logic
|
153
|
+
pdata: |
|
154
|
+
<div>
|
155
|
+
<ul id="mark:list">
|
156
|
+
<li id="mark:item">foo</li>
|
157
|
+
</ul>
|
158
|
+
</div>
|
159
|
+
plogic: |
|
160
|
+
#list {
|
161
|
+
logic: {
|
162
|
+
}
|
163
|
+
}
|
164
|
+
#item {
|
165
|
+
value: item;
|
166
|
+
}
|
167
|
+
expected: |
|
168
|
+
print("<div>\n")
|
169
|
+
print("</div>\n")
|
170
|
+
|
171
|
+
|
172
|
+
# --------------------------------------------------------------------------------
|
173
|
+
|
1
174
|
###
|
2
175
|
- name: delspan1
|
3
176
|
desc: <span> and id="mark:foo"
|
@@ -330,29 +503,3 @@
|
|
330
503
|
#
|
331
504
|
|
332
505
|
|
333
|
-
###
|
334
|
-
- name: unmatched
|
335
|
-
desc: unmatched text to fetch pattern
|
336
|
-
bug: self found
|
337
|
-
pdata*:
|
338
|
-
eruby: &unmatched_pdata |
|
339
|
-
foo
|
340
|
-
bar
|
341
|
-
baz
|
342
|
-
php: *unmatched_pdata
|
343
|
-
jstl: *unmatched_pdata
|
344
|
-
eperl: *unmatched_pdata
|
345
|
-
|
346
|
-
plogic*:
|
347
|
-
eruby: |
|
348
|
-
php: |
|
349
|
-
jstl: |
|
350
|
-
eperl: |
|
351
|
-
|
352
|
-
expected*:
|
353
|
-
eruby: &unmatched_expected |
|
354
|
-
print("foo\nbar\nbaz\n")
|
355
|
-
php: *unmatched_expected
|
356
|
-
jstl: *unmatched_expected
|
357
|
-
eperl: *unmatched_expected
|
358
|
-
|
data/test/test-directives.rb
CHANGED
data/test/test-main.rb
CHANGED
data/test/test-parser.rb
CHANGED
data/test/test-parser.yaml
CHANGED