kwartz 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +340 -0
- data/ChangeLog +103 -0
- data/README.txt +37 -0
- data/bin/kwartz +12 -0
- data/doc-api/classes/Kwartz.html +218 -0
- data/doc-api/classes/Kwartz/Assertion.html +140 -0
- data/doc-api/classes/Kwartz/AssertionError.html +148 -0
- data/doc-api/classes/Kwartz/AttrInfo.html +320 -0
- data/doc-api/classes/Kwartz/BaseError.html +206 -0
- data/doc-api/classes/Kwartz/BaseTranslator.html +331 -0
- data/doc-api/classes/Kwartz/CharacterType.html +212 -0
- data/doc-api/classes/Kwartz/CommandOptionError.html +154 -0
- data/doc-api/classes/Kwartz/CommandOptions.html +374 -0
- data/doc-api/classes/Kwartz/Config.html +150 -0
- data/doc-api/classes/Kwartz/ConvertError.html +191 -0
- data/doc-api/classes/Kwartz/Converter.html +252 -0
- data/doc-api/classes/Kwartz/CssStyleParser.html +483 -0
- data/doc-api/classes/Kwartz/DocumentRuleset.html +369 -0
- data/doc-api/classes/Kwartz/ElementExpander.html +325 -0
- data/doc-api/classes/Kwartz/ElementInfo.html +312 -0
- data/doc-api/classes/Kwartz/ElementRuleset.html +582 -0
- data/doc-api/classes/Kwartz/EperlHandler.html +338 -0
- data/doc-api/classes/Kwartz/EperlTranslator.html +167 -0
- data/doc-api/classes/Kwartz/ErubisHandler.html +113 -0
- data/doc-api/classes/Kwartz/ErubisTranslator.html +168 -0
- data/doc-api/classes/Kwartz/ErubyHandler.html +337 -0
- data/doc-api/classes/Kwartz/ErubyTranslator.html +167 -0
- data/doc-api/classes/Kwartz/ExpandStatement.html +227 -0
- data/doc-api/classes/Kwartz/Expression.html +119 -0
- data/doc-api/classes/Kwartz/Handler.html +558 -0
- data/doc-api/classes/Kwartz/JstlHandler.html +657 -0
- data/doc-api/classes/Kwartz/JstlTranslator.html +226 -0
- data/doc-api/classes/Kwartz/KwartzError.html +146 -0
- data/doc-api/classes/Kwartz/Main.html +384 -0
- data/doc-api/classes/Kwartz/NativeExpression.html +236 -0
- data/doc-api/classes/Kwartz/NativeStatement.html +254 -0
- data/doc-api/classes/Kwartz/Node.html +156 -0
- data/doc-api/classes/Kwartz/ParseError.html +148 -0
- data/doc-api/classes/Kwartz/PhpHandler.html +333 -0
- data/doc-api/classes/Kwartz/PhpTranslator.html +194 -0
- data/doc-api/classes/Kwartz/PresentationLogicParser.html +830 -0
- data/doc-api/classes/Kwartz/PrintStatement.html +221 -0
- data/doc-api/classes/Kwartz/RailsHandler.html +587 -0
- data/doc-api/classes/Kwartz/RailsTranslator.html +167 -0
- data/doc-api/classes/Kwartz/RubyStyleParser.html +558 -0
- data/doc-api/classes/Kwartz/Ruleset.html +117 -0
- data/doc-api/classes/Kwartz/Statement.html +119 -0
- data/doc-api/classes/Kwartz/StrutsTranslator.html +190 -0
- data/doc-api/classes/Kwartz/TagInfo.html +314 -0
- data/doc-api/classes/Kwartz/TextConverter.html +270 -0
- data/doc-api/classes/Kwartz/Translator.html +318 -0
- data/doc-api/classes/Test.html +107 -0
- data/doc-api/classes/Test/Unit.html +101 -0
- data/doc-api/created.rid +1 -0
- data/doc-api/files/__/README_txt.html +150 -0
- data/doc-api/files/kwartz/assert_rb.html +114 -0
- data/doc-api/files/kwartz/binding/eperl_rb.html +116 -0
- data/doc-api/files/kwartz/binding/erubis_rb.html +116 -0
- data/doc-api/files/kwartz/binding/eruby_rb.html +115 -0
- data/doc-api/files/kwartz/binding/jstl_rb.html +116 -0
- data/doc-api/files/kwartz/binding/php_rb.html +116 -0
- data/doc-api/files/kwartz/binding/rails_rb.html +115 -0
- data/doc-api/files/kwartz/binding/struts_rb.html +117 -0
- data/doc-api/files/kwartz/config_rb.html +107 -0
- data/doc-api/files/kwartz/converter_rb.html +119 -0
- data/doc-api/files/kwartz/error_rb.html +107 -0
- data/doc-api/files/kwartz/main_rb.html +124 -0
- data/doc-api/files/kwartz/node_rb.html +114 -0
- data/doc-api/files/kwartz/parser_rb.html +117 -0
- data/doc-api/files/kwartz/translator_rb.html +115 -0
- data/doc-api/files/kwartz/util/assert-text-equal_rb.html +115 -0
- data/doc-api/files/kwartz/util/testcase-helper_rb.html +115 -0
- data/doc-api/files/kwartz_rb.html +120 -0
- data/doc-api/fr_class_index.html +75 -0
- data/doc-api/fr_file_index.html +45 -0
- data/doc-api/fr_method_index.html +216 -0
- data/doc-api/index.html +24 -0
- data/doc-api/rdoc-style.css +208 -0
- data/doc/docstyle.css +188 -0
- data/doc/p-pattern.html +1207 -0
- data/doc/reference.html +3396 -0
- data/doc/users-guide.html +1670 -0
- data/examples/breadcrumbs1/Makefile +15 -0
- data/examples/breadcrumbs1/breadcrumbs.eruby.plogic +27 -0
- data/examples/breadcrumbs1/breadcrumbs.html +12 -0
- data/examples/breadcrumbs1/breadcrumbs.jstl.plogic +28 -0
- data/examples/breadcrumbs1/breadcrumbs.php.plogic +26 -0
- data/examples/breadcrumbs1/main.php +12 -0
- data/examples/breadcrumbs1/main.rb +12 -0
- data/examples/breadcrumbs2/Makefile +15 -0
- data/examples/breadcrumbs2/breadcrumbs.eruby.plogic +22 -0
- data/examples/breadcrumbs2/breadcrumbs.html +14 -0
- data/examples/breadcrumbs2/breadcrumbs.jstl.plogic +24 -0
- data/examples/breadcrumbs2/breadcrumbs.php.plogic +23 -0
- data/examples/breadcrumbs2/main.php +12 -0
- data/examples/breadcrumbs2/main.rb +12 -0
- data/examples/pagelayout/Makefile +47 -0
- data/examples/pagelayout/content.eruby.plogic +44 -0
- data/examples/pagelayout/content.jstl.plogic +36 -0
- data/examples/pagelayout/content.php.plogic +37 -0
- data/examples/pagelayout/content1.html +36 -0
- data/examples/pagelayout/content2.html +29 -0
- data/examples/pagelayout/design.css +40 -0
- data/examples/pagelayout/layout.html +50 -0
- data/examples/pagelayout/main.php +55 -0
- data/examples/pagelayout/main.rb +77 -0
- data/examples/pagelayout/menu.eruby.plogic +14 -0
- data/examples/pagelayout/menu.html +13 -0
- data/examples/pagelayout/menu.jstl.plogic +14 -0
- data/examples/pagelayout/menu.php.plogic +14 -0
- data/examples/rails1/Makefile +36 -0
- data/examples/rails1/README +19 -0
- data/examples/rails1/application_helper.rb +31 -0
- data/examples/rails1/edit.html +28 -0
- data/examples/rails1/edit.plogic +10 -0
- data/examples/rails1/form.html +52 -0
- data/examples/rails1/form.plogic +33 -0
- data/examples/rails1/layout.plogic +15 -0
- data/examples/rails1/link_to.plogic +19 -0
- data/examples/rails1/list.html +48 -0
- data/examples/rails1/list.plogic +28 -0
- data/examples/rails1/new.html +27 -0
- data/examples/rails1/new.plogic +10 -0
- data/examples/rails1/reader.plogic +29 -0
- data/examples/rails1/show.html +40 -0
- data/examples/rails1/show.plogic +4 -0
- data/examples/rails1/writer.plogic +8 -0
- data/examples/table1/Makefile +15 -0
- data/examples/table1/main.php +11 -0
- data/examples/table1/main.rb +11 -0
- data/examples/table1/table1.eruby.plogic +21 -0
- data/examples/table1/table1.html +16 -0
- data/examples/table1/table1.jstl.plogic +21 -0
- data/examples/table1/table1.php.plogic +22 -0
- data/kwartz.gemspec +55 -0
- data/lib/kwartz.rb +13 -0
- data/lib/kwartz/assert.rb +31 -0
- data/lib/kwartz/binding/eperl.rb +166 -0
- data/lib/kwartz/binding/erubis.rb +61 -0
- data/lib/kwartz/binding/eruby.rb +164 -0
- data/lib/kwartz/binding/jstl.rb +334 -0
- data/lib/kwartz/binding/php.rb +167 -0
- data/lib/kwartz/binding/rails.rb +295 -0
- data/lib/kwartz/binding/struts.rb +109 -0
- data/lib/kwartz/config.rb +28 -0
- data/lib/kwartz/converter.rb +920 -0
- data/lib/kwartz/error.rb +41 -0
- data/lib/kwartz/main.rb +464 -0
- data/lib/kwartz/node.rb +454 -0
- data/lib/kwartz/parser.rb +903 -0
- data/lib/kwartz/translator.rb +153 -0
- data/lib/kwartz/util/assert-text-equal.rb +44 -0
- data/lib/kwartz/util/testcase-helper.rb +112 -0
- data/setup.rb +1331 -0
- data/test/test-compile.rb +36 -0
- data/test/test-compile.yaml +178 -0
- data/test/test-converter.rb +34 -0
- data/test/test-converter.yaml +127 -0
- data/test/test-directives.rb +32 -0
- data/test/test-directives.yaml +1411 -0
- data/test/test-main.rb +464 -0
- data/test/test-parser.rb +54 -0
- data/test/test-parser.yaml +394 -0
- data/test/test-rails.rb +28 -0
- data/test/test-rails.yaml +301 -0
- data/test/test-ruleset.rb +36 -0
- data/test/test-ruleset.yaml +804 -0
- data/test/test.rb +44 -0
- metadata +236 -0
@@ -0,0 +1,226 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Kwartz::JstlTranslator</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Kwartz::JstlTranslator</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/kwartz/binding/jstl_rb.html">
|
59
|
+
kwartz/binding/jstl.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="BaseTranslator.html">
|
69
|
+
BaseTranslator
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
translator for php
|
86
|
+
</p>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
<div id="method-list">
|
94
|
+
<h3 class="section-bar">Methods</h3>
|
95
|
+
|
96
|
+
<div class="name-list">
|
97
|
+
<a href="#M000172">new</a>
|
98
|
+
<a href="#M000173">translate_native_expr</a>
|
99
|
+
</div>
|
100
|
+
</div>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
|
105
|
+
<!-- if includes -->
|
106
|
+
|
107
|
+
<div id="section">
|
108
|
+
|
109
|
+
|
110
|
+
<div id="constants-list">
|
111
|
+
<h3 class="section-bar">Constants</h3>
|
112
|
+
|
113
|
+
<div class="name-list">
|
114
|
+
<table summary="Constants">
|
115
|
+
<tr class="top-aligned-row context-row">
|
116
|
+
<td class="context-item-name">JSTL11_EMBED_PATTERNS</td>
|
117
|
+
<td>=</td>
|
118
|
+
<td class="context-item-value">[ '', '', # statement '<c:out value="${', '}" escapeXml="false"/>', # expression '<c:out value="${', '}"/>'</td>
|
119
|
+
</tr>
|
120
|
+
<tr class="top-aligned-row context-row">
|
121
|
+
<td class="context-item-name">JSTL12_EMBED_PATTERNS</td>
|
122
|
+
<td>=</td>
|
123
|
+
<td class="context-item-value">[ '', '', # statement '<c:out value="${', '}" escapeXml="false"/>', # expression '${', '}'</td>
|
124
|
+
</tr>
|
125
|
+
</table>
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
<!-- if method_list -->
|
135
|
+
<div id="methods">
|
136
|
+
<h3 class="section-bar">Public Class methods</h3>
|
137
|
+
|
138
|
+
<div id="method-M000172" class="method-detail">
|
139
|
+
<a name="M000172"></a>
|
140
|
+
|
141
|
+
<div class="method-heading">
|
142
|
+
<a href="#M000172" class="method-signature">
|
143
|
+
<span class="method-name">new</span><span class="method-args">(properties={})</span>
|
144
|
+
</a>
|
145
|
+
</div>
|
146
|
+
|
147
|
+
<div class="method-description">
|
148
|
+
<p><a class="source-toggle" href="#"
|
149
|
+
onclick="toggleCode('M000172-source');return false;">[Source]</a></p>
|
150
|
+
<div class="method-source-code" id="M000172-source">
|
151
|
+
<pre>
|
152
|
+
<span class="ruby-comment cmt"># File kwartz/binding/jstl.rb, line 291</span>
|
153
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">properties</span>={})
|
154
|
+
<span class="ruby-identifier">jstl_ver</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:jstl</span>] <span class="ruby-operator">||</span> <span class="ruby-value">1.2</span>
|
155
|
+
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">jstl_ver</span> <span class="ruby-operator"><</span> <span class="ruby-value">1.2</span> <span class="ruby-operator">?</span> <span class="ruby-constant">JSTL11_EMBED_PATTERNS</span> <span class="ruby-operator">:</span> <span class="ruby-constant">JSTL12_EMBED_PATTERNS</span>, <span class="ruby-identifier">properties</span>)
|
156
|
+
<span class="ruby-ivar">@jstl_ver</span> = <span class="ruby-identifier">jstl_ver</span>
|
157
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">header</span>
|
158
|
+
<span class="ruby-identifier">sb</span> = <span class="ruby-value str">''</span>
|
159
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">charset</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:charset</span>]
|
160
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"<%@ page contentType=\"text/html; charset=#{charset}\" %>"</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@nl</span>
|
161
|
+
<span class="ruby-keyword kw">else</span>
|
162
|
+
<span class="ruby-comment cmt">#sb << "<%@ page contentType=\"text/html\" %>" << @nl</span>
|
163
|
+
<span class="ruby-keyword kw">end</span>
|
164
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@jstl_ver</span> <span class="ruby-operator"><</span> <span class="ruby-value">1.2</span>
|
165
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>'</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@nl</span>
|
166
|
+
<span class="ruby-keyword kw">else</span>
|
167
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>'</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@nl</span>
|
168
|
+
<span class="ruby-identifier">sb</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>'</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@nl</span>
|
169
|
+
<span class="ruby-keyword kw">end</span>
|
170
|
+
<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">header</span> = <span class="ruby-identifier">sb</span>
|
171
|
+
<span class="ruby-keyword kw">end</span>
|
172
|
+
<span class="ruby-keyword kw">end</span>
|
173
|
+
</pre>
|
174
|
+
</div>
|
175
|
+
</div>
|
176
|
+
</div>
|
177
|
+
|
178
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
179
|
+
|
180
|
+
<div id="method-M000173" class="method-detail">
|
181
|
+
<a name="M000173"></a>
|
182
|
+
|
183
|
+
<div class="method-heading">
|
184
|
+
<a href="#M000173" class="method-signature">
|
185
|
+
<span class="method-name">translate_native_expr</span><span class="method-args">(expr)</span>
|
186
|
+
</a>
|
187
|
+
</div>
|
188
|
+
|
189
|
+
<div class="method-description">
|
190
|
+
<p><a class="source-toggle" href="#"
|
191
|
+
onclick="toggleCode('M000173-source');return false;">[Source]</a></p>
|
192
|
+
<div class="method-source-code" id="M000173-source">
|
193
|
+
<pre>
|
194
|
+
<span class="ruby-comment cmt"># File kwartz/binding/jstl.rb, line 313</span>
|
195
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">translate_native_expr</span>(<span class="ruby-identifier">expr</span>)
|
196
|
+
<span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">expr</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">NativeExpression</span>)
|
197
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">expr</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A"(.*)"\z/</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">expr</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\A'(.*)'\z/</span>
|
198
|
+
<span class="ruby-ivar">@sb</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">$1</span>
|
199
|
+
<span class="ruby-keyword kw">else</span>
|
200
|
+
<span class="ruby-identifier">flag_escape</span> = <span class="ruby-identifier">expr</span>.<span class="ruby-identifier">escape?</span>
|
201
|
+
<span class="ruby-identifier">flag_escape</span> = <span class="ruby-ivar">@escape</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">flag_escape</span>.<span class="ruby-identifier">nil?</span>
|
202
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">flag_escape</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span>
|
203
|
+
<span class="ruby-ivar">@sb</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@expr_l</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">expr</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@expr_r</span> <span class="ruby-comment cmt"># ex. <c:out value="${expr}" escapeXml="false"/></span>
|
204
|
+
<span class="ruby-keyword kw">else</span>
|
205
|
+
<span class="ruby-ivar">@sb</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@escape_l</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">expr</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@escape_r</span> <span class="ruby-comment cmt"># ex. <c:out value="${expr}"/></span>
|
206
|
+
<span class="ruby-keyword kw">end</span>
|
207
|
+
<span class="ruby-keyword kw">end</span>
|
208
|
+
<span class="ruby-keyword kw">end</span>
|
209
|
+
</pre>
|
210
|
+
</div>
|
211
|
+
</div>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
|
215
|
+
</div>
|
216
|
+
|
217
|
+
|
218
|
+
</div>
|
219
|
+
|
220
|
+
|
221
|
+
<div id="validator-badges">
|
222
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
223
|
+
</div>
|
224
|
+
|
225
|
+
</body>
|
226
|
+
</html>
|
@@ -0,0 +1,146 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Kwartz::KwartzError</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Kwartz::KwartzError</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/kwartz/error_rb.html">
|
59
|
+
kwartz/error.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
StandardError
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000154">new</a>
|
90
|
+
</div>
|
91
|
+
</div>
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
<!-- if includes -->
|
97
|
+
|
98
|
+
<div id="section">
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<!-- if method_list -->
|
108
|
+
<div id="methods">
|
109
|
+
<h3 class="section-bar">Public Class methods</h3>
|
110
|
+
|
111
|
+
<div id="method-M000154" class="method-detail">
|
112
|
+
<a name="M000154"></a>
|
113
|
+
|
114
|
+
<div class="method-heading">
|
115
|
+
<a href="#M000154" class="method-signature">
|
116
|
+
<span class="method-name">new</span><span class="method-args">(message)</span>
|
117
|
+
</a>
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<div class="method-description">
|
121
|
+
<p><a class="source-toggle" href="#"
|
122
|
+
onclick="toggleCode('M000154-source');return false;">[Source]</a></p>
|
123
|
+
<div class="method-source-code" id="M000154-source">
|
124
|
+
<pre>
|
125
|
+
<span class="ruby-comment cmt"># File kwartz/error.rb, line 11</span>
|
126
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">message</span>)
|
127
|
+
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">message</span>)
|
128
|
+
<span class="ruby-keyword kw">end</span>
|
129
|
+
</pre>
|
130
|
+
</div>
|
131
|
+
</div>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
|
135
|
+
</div>
|
136
|
+
|
137
|
+
|
138
|
+
</div>
|
139
|
+
|
140
|
+
|
141
|
+
<div id="validator-badges">
|
142
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
143
|
+
</div>
|
144
|
+
|
145
|
+
</body>
|
146
|
+
</html>
|
@@ -0,0 +1,384 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Kwartz::Main</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Kwartz::Main</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/kwartz/main_rb.html">
|
59
|
+
kwartz/main.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
main command
|
84
|
+
</p>
|
85
|
+
<p>
|
86
|
+
ex.
|
87
|
+
</p>
|
88
|
+
<pre>
|
89
|
+
Kwartz::Main.add_handler('mylang', MyLangDirectiveHandler, MyLangTranslator)
|
90
|
+
Kwartz::Main.main(ARGV)
|
91
|
+
</pre>
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
95
|
+
|
96
|
+
</div>
|
97
|
+
|
98
|
+
<div id="method-list">
|
99
|
+
<h3 class="section-bar">Methods</h3>
|
100
|
+
|
101
|
+
<div class="name-list">
|
102
|
+
<a href="#M000081">execute</a>
|
103
|
+
<a href="#M000080">main</a>
|
104
|
+
<a href="#M000079">new</a>
|
105
|
+
</div>
|
106
|
+
</div>
|
107
|
+
|
108
|
+
</div>
|
109
|
+
|
110
|
+
|
111
|
+
<!-- if includes -->
|
112
|
+
|
113
|
+
<div id="section">
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
<!-- if method_list -->
|
123
|
+
<div id="methods">
|
124
|
+
<h3 class="section-bar">Public Class methods</h3>
|
125
|
+
|
126
|
+
<div id="method-M000080" class="method-detail">
|
127
|
+
<a name="M000080"></a>
|
128
|
+
|
129
|
+
<div class="method-heading">
|
130
|
+
<a href="#M000080" class="method-signature">
|
131
|
+
<span class="method-name">main</span><span class="method-args">(argv=ARGV)</span>
|
132
|
+
</a>
|
133
|
+
</div>
|
134
|
+
|
135
|
+
<div class="method-description">
|
136
|
+
<p><a class="source-toggle" href="#"
|
137
|
+
onclick="toggleCode('M000080-source');return false;">[Source]</a></p>
|
138
|
+
<div class="method-source-code" id="M000080-source">
|
139
|
+
<pre>
|
140
|
+
<span class="ruby-comment cmt"># File kwartz/main.rb, line 171</span>
|
141
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">main</span>(<span class="ruby-identifier">argv</span>=<span class="ruby-constant">ARGV</span>)
|
142
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-value">0</span>
|
143
|
+
<span class="ruby-keyword kw">begin</span>
|
144
|
+
<span class="ruby-identifier">main</span> = <span class="ruby-constant">Kwartz</span><span class="ruby-operator">::</span><span class="ruby-constant">Main</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">argv</span>)
|
145
|
+
<span class="ruby-identifier">out</span> = <span class="ruby-identifier">main</span>.<span class="ruby-identifier">execute</span>()
|
146
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">out</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">out</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
|
147
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Kwartz</span><span class="ruby-operator">::</span><span class="ruby-constant">KwartzError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
148
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">ex</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
|
149
|
+
<span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">to_s</span>
|
150
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-value">1</span>
|
151
|
+
<span class="ruby-keyword kw">end</span>
|
152
|
+
<span class="ruby-identifier">exit</span> <span class="ruby-identifier">status</span>
|
153
|
+
<span class="ruby-keyword kw">end</span>
|
154
|
+
</pre>
|
155
|
+
</div>
|
156
|
+
</div>
|
157
|
+
</div>
|
158
|
+
|
159
|
+
<div id="method-M000079" class="method-detail">
|
160
|
+
<a name="M000079"></a>
|
161
|
+
|
162
|
+
<div class="method-heading">
|
163
|
+
<a href="#M000079" class="method-signature">
|
164
|
+
<span class="method-name">new</span><span class="method-args">(argv=ARGV)</span>
|
165
|
+
</a>
|
166
|
+
</div>
|
167
|
+
|
168
|
+
<div class="method-description">
|
169
|
+
<p><a class="source-toggle" href="#"
|
170
|
+
onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
|
171
|
+
<div class="method-source-code" id="M000079-source">
|
172
|
+
<pre>
|
173
|
+
<span class="ruby-comment cmt"># File kwartz/main.rb, line 165</span>
|
174
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">argv</span>=<span class="ruby-constant">ARGV</span>)
|
175
|
+
<span class="ruby-ivar">@argv</span> = <span class="ruby-identifier">argv</span>
|
176
|
+
<span class="ruby-ivar">@command</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">$0</span>)
|
177
|
+
<span class="ruby-keyword kw">end</span>
|
178
|
+
</pre>
|
179
|
+
</div>
|
180
|
+
</div>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
184
|
+
|
185
|
+
<div id="method-M000081" class="method-detail">
|
186
|
+
<a name="M000081"></a>
|
187
|
+
|
188
|
+
<div class="method-heading">
|
189
|
+
<a href="#M000081" class="method-signature">
|
190
|
+
<span class="method-name">execute</span><span class="method-args">(argv=@argv)</span>
|
191
|
+
</a>
|
192
|
+
</div>
|
193
|
+
|
194
|
+
<div class="method-description">
|
195
|
+
<p><a class="source-toggle" href="#"
|
196
|
+
onclick="toggleCode('M000081-source');return false;">[Source]</a></p>
|
197
|
+
<div class="method-source-code" id="M000081-source">
|
198
|
+
<pre>
|
199
|
+
<span class="ruby-comment cmt"># File kwartz/main.rb, line 206</span>
|
200
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">argv</span>=<span class="ruby-ivar">@argv</span>)
|
201
|
+
|
202
|
+
<span class="ruby-comment cmt">## parse command-line options</span>
|
203
|
+
<span class="ruby-identifier">options</span> = <span class="ruby-constant">CommandOptions</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@@option_table</span>, <span class="ruby-identifier">properties</span> = {})
|
204
|
+
<span class="ruby-identifier">pdata_filenames</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">parse_argv</span>(<span class="ruby-identifier">argv</span>)
|
205
|
+
<span class="ruby-identifier">options</span>.<span class="ruby-identifier">help</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:help</span>]
|
206
|
+
|
207
|
+
<span class="ruby-comment cmt">## help</span>
|
208
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">help</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">version</span>
|
209
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">version</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">version</span>
|
210
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">help</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">help</span>
|
211
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
212
|
+
<span class="ruby-keyword kw">end</span>
|
213
|
+
|
214
|
+
<span class="ruby-comment cmt">## check filenames</span>
|
215
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pdata_filenames</span>.<span class="ruby-identifier">empty?</span>
|
216
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-value str">"filename of presentation data is required."</span>)
|
217
|
+
<span class="ruby-keyword kw">end</span>
|
218
|
+
<span class="ruby-identifier">pdata_filenames</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span>
|
219
|
+
<span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">filename</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{filename}: file not found."</span>)
|
220
|
+
<span class="ruby-keyword kw">end</span>
|
221
|
+
|
222
|
+
<span class="ruby-comment cmt">## options</span>
|
223
|
+
<span class="ruby-identifier">$KCODE</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">kanji</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">kanji</span>
|
224
|
+
<span class="ruby-identifier">$DEBUG</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">debug</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">debug</span>
|
225
|
+
|
226
|
+
<span class="ruby-comment cmt">## parse class, hander class, translator class</span>
|
227
|
+
<span class="ruby-identifier">style</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">pstyle</span> <span class="ruby-operator">||</span> <span class="ruby-value str">'css'</span>
|
228
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">parser_class</span> = <span class="ruby-constant">PresentationLogicParser</span>.<span class="ruby-identifier">get_class</span>(<span class="ruby-identifier">style</span>)
|
229
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-node">"-#{options.chr(:pstyle)} #{style}"</span>
|
230
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{s}: unknown style name (parser class not registered)."</span>)
|
231
|
+
<span class="ruby-keyword kw">end</span>
|
232
|
+
<span class="ruby-identifier">lang</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">lang</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Config</span><span class="ruby-operator">::</span><span class="ruby-constant">PROPERTY_LANG</span> <span class="ruby-comment cmt"># 'eruby'</span>
|
233
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">handler_class</span> = <span class="ruby-constant">Handler</span>.<span class="ruby-identifier">get_class</span>(<span class="ruby-identifier">lang</span>)
|
234
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-node">"-#{options.chr(:lang)} #{lang}"</span>
|
235
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{s}: unknown lang name (handler class not registered)."</span>)
|
236
|
+
<span class="ruby-keyword kw">end</span>
|
237
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">translator_class</span> = <span class="ruby-constant">Translator</span>.<span class="ruby-identifier">get_class</span>(<span class="ruby-identifier">lang</span>)
|
238
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-node">"-#{options.chr(:lang)} #{lang}"</span>
|
239
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{s}: unknown lang name (translator class not registered)."</span>)
|
240
|
+
<span class="ruby-keyword kw">end</span>
|
241
|
+
|
242
|
+
<span class="ruby-comment cmt">## require libraries</span>
|
243
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">requires</span>
|
244
|
+
<span class="ruby-identifier">libraries</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">requires</span>
|
245
|
+
<span class="ruby-identifier">libraries</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/,/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">library</span><span class="ruby-operator">|</span>
|
246
|
+
<span class="ruby-identifier">library</span>.<span class="ruby-identifier">strip!</span>
|
247
|
+
<span class="ruby-identifier">require</span> <span class="ruby-identifier">library</span>
|
248
|
+
<span class="ruby-keyword kw">end</span>
|
249
|
+
<span class="ruby-keyword kw">end</span>
|
250
|
+
|
251
|
+
<span class="ruby-comment cmt">## parse presentation logic file</span>
|
252
|
+
<span class="ruby-identifier">ruleset_list</span> = []
|
253
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">plogics</span>
|
254
|
+
<span class="ruby-identifier">parser</span> = <span class="ruby-identifier">parser_class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">properties</span>)
|
255
|
+
<span class="ruby-identifier">options</span>.<span class="ruby-identifier">plogics</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/,/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span>
|
256
|
+
<span class="ruby-identifier">filename</span>.<span class="ruby-identifier">strip!</span>
|
257
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">filename</span>)
|
258
|
+
<span class="ruby-comment cmt"># ok</span>
|
259
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">filename</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'.plogic'</span>)
|
260
|
+
<span class="ruby-identifier">filename</span> <span class="ruby-operator">+=</span> <span class="ruby-value str">'.plogic'</span>
|
261
|
+
<span class="ruby-keyword kw">else</span>
|
262
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-node">"-#{options.chr(:plogics)} #{filename}[.plogic]"</span>
|
263
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{s}: file not found."</span>)
|
264
|
+
<span class="ruby-keyword kw">end</span>
|
265
|
+
<span class="ruby-identifier">plogic</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>)
|
266
|
+
<span class="ruby-identifier">ruleset_list</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">plogic</span>, <span class="ruby-identifier">filename</span>)
|
267
|
+
<span class="ruby-keyword kw">end</span>
|
268
|
+
<span class="ruby-keyword kw">end</span>
|
269
|
+
|
270
|
+
<span class="ruby-comment cmt">## properties</span>
|
271
|
+
<span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:escape</span>] = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">escape</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">properties</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">:escape</span>)
|
272
|
+
|
273
|
+
<span class="ruby-comment cmt">## create converter</span>
|
274
|
+
<span class="ruby-identifier">handler</span> = <span class="ruby-identifier">handler_class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ruleset_list</span>, <span class="ruby-identifier">properties</span>)
|
275
|
+
<span class="ruby-identifier">converter</span> = <span class="ruby-constant">TextConverter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">handler</span>, <span class="ruby-identifier">properties</span>)
|
276
|
+
|
277
|
+
<span class="ruby-comment cmt">## import-files and layout-file</span>
|
278
|
+
<span class="ruby-identifier">import_filenames</span> = []
|
279
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">?i</span>]
|
280
|
+
(<span class="ruby-identifier">import_filenames</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">imports</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/,/</span>)).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span>
|
281
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">filename</span>)
|
282
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-node">"-#{options.chr(:imports)}"</span>
|
283
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{s} #{filename}: file not found."</span>)
|
284
|
+
<span class="ruby-keyword kw">end</span>
|
285
|
+
<span class="ruby-keyword kw">end</span>
|
286
|
+
<span class="ruby-keyword kw">end</span>
|
287
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">layout</span>
|
288
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">layout</span>)
|
289
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-node">"-#{options.chr(:layout)}"</span>
|
290
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{s} #{options.layout}: file not found."</span>)
|
291
|
+
<span class="ruby-keyword kw">end</span>
|
292
|
+
<span class="ruby-identifier">import_filenames</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">pdata_filenames</span>
|
293
|
+
<span class="ruby-identifier">pdata_filenames</span> = [<span class="ruby-identifier">options</span>.<span class="ruby-identifier">layout</span>]
|
294
|
+
<span class="ruby-keyword kw">end</span>
|
295
|
+
<span class="ruby-identifier">import_filenames</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span>
|
296
|
+
<span class="ruby-identifier">pdata</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>)
|
297
|
+
<span class="ruby-identifier">converter</span>.<span class="ruby-identifier">convert</span>(<span class="ruby-identifier">pdata</span>, <span class="ruby-identifier">filename</span>)
|
298
|
+
<span class="ruby-keyword kw">end</span>
|
299
|
+
|
300
|
+
<span class="ruby-comment cmt">## convert presentation data file</span>
|
301
|
+
<span class="ruby-identifier">stmt_list</span> = []
|
302
|
+
<span class="ruby-identifier">pdata</span> = <span class="ruby-keyword kw">nil</span>
|
303
|
+
<span class="ruby-identifier">pdata_filenames</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span>
|
304
|
+
<span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">filename</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{filename}: file not found."</span>)
|
305
|
+
<span class="ruby-identifier">pdata</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>)
|
306
|
+
<span class="ruby-comment cmt">#handler = handler_class.new(ruleset_list)</span>
|
307
|
+
<span class="ruby-comment cmt">#converter = TextConverter.new(handler, properties)</span>
|
308
|
+
<span class="ruby-identifier">list</span> = <span class="ruby-identifier">converter</span>.<span class="ruby-identifier">convert</span>(<span class="ruby-identifier">pdata</span>, <span class="ruby-identifier">filename</span>)
|
309
|
+
<span class="ruby-identifier">stmt_list</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">list</span>)
|
310
|
+
<span class="ruby-keyword kw">end</span>
|
311
|
+
|
312
|
+
<span class="ruby-comment cmt">## extract element or content</span>
|
313
|
+
<span class="ruby-identifier">elem_id</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">extract_cont</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">extract_elem</span>
|
314
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">elem_id</span>
|
315
|
+
<span class="ruby-identifier">content_only</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">extract_cont</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
|
316
|
+
<span class="ruby-identifier">stmt_list</span> = <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">extract</span>(<span class="ruby-identifier">elem_id</span>, <span class="ruby-identifier">content_only</span>)
|
317
|
+
<span class="ruby-keyword kw">end</span>
|
318
|
+
|
319
|
+
<span class="ruby-comment cmt">## translate statements into target code(eRuby, PHP, JSP)</span>
|
320
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">pdata</span>[<span class="ruby-identifier">pdata</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value">?\n</span>) <span class="ruby-operator">-</span> <span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?\r</span>
|
321
|
+
<span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:nl</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">"\r\n"</span>
|
322
|
+
<span class="ruby-keyword kw">end</span>
|
323
|
+
<span class="ruby-identifier">translator</span> = <span class="ruby-identifier">translator_class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">properties</span>)
|
324
|
+
<span class="ruby-identifier">output</span> = <span class="ruby-identifier">translator</span>.<span class="ruby-identifier">translate</span>(<span class="ruby-identifier">stmt_list</span>)
|
325
|
+
|
326
|
+
<span class="ruby-comment cmt">## load YAML file and evaluate eRuby script</span>
|
327
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">yamlfile</span>
|
328
|
+
<span class="ruby-identifier">eruby_script</span> = <span class="ruby-identifier">output</span>
|
329
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lang</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'eruby'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">lang</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'rails'</span>
|
330
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'erb'</span>
|
331
|
+
<span class="ruby-identifier">trim_mode</span> = <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">:trim</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:trim</span>] <span class="ruby-operator">:</span> <span class="ruby-value">1</span>
|
332
|
+
<span class="ruby-identifier">src</span> = <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">eruby_script</span>, <span class="ruby-identifier">$SAFE</span>, <span class="ruby-identifier">trim_mode</span>).<span class="ruby-identifier">src</span>
|
333
|
+
<span class="ruby-identifier">mod</span> = <span class="ruby-constant">ERB</span><span class="ruby-operator">::</span><span class="ruby-constant">Util</span>
|
334
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">lang</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'erubis'</span>
|
335
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'erubis'</span>
|
336
|
+
<span class="ruby-identifier">src</span> = <span class="ruby-constant">Erubis</span><span class="ruby-operator">::</span><span class="ruby-constant">Eruby</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">eruby_script</span>).<span class="ruby-identifier">src</span>
|
337
|
+
<span class="ruby-identifier">mod</span> = <span class="ruby-constant">Erubis</span><span class="ruby-operator">::</span><span class="ruby-constant">XmlHelper</span>
|
338
|
+
<span class="ruby-keyword kw">else</span>
|
339
|
+
<span class="ruby-identifier">s1</span> = <span class="ruby-node">"-#{options.chr(:yamlfile)}"</span>
|
340
|
+
<span class="ruby-identifier">s2</span> = <span class="ruby-node">"-#{options.chr(:lang)} #{lang}"</span>
|
341
|
+
<span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{s1}: not available with '#{s2}'."</span>)
|
342
|
+
<span class="ruby-keyword kw">end</span>
|
343
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">yamlfile</span>)
|
344
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-node">"-#{options.chr(:yamlfile)} #{options.yamlfile}"</span>
|
345
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{s}: file not found."</span>)
|
346
|
+
<span class="ruby-keyword kw">end</span>
|
347
|
+
<span class="ruby-identifier">str</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">options</span>.<span class="ruby-identifier">yamlfile</span>)
|
348
|
+
<span class="ruby-identifier">str</span> = <span class="ruby-identifier">untabify</span>(<span class="ruby-identifier">str</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">untabify</span>
|
349
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'yaml'</span>
|
350
|
+
<span class="ruby-identifier">ydoc</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">str</span>)
|
351
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">ydoc</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
352
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-node">"-#{options.chr(:yamlfile)} #{options.yamlfile}"</span>
|
353
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">option_error</span>(<span class="ruby-node">"#{s}: not a mapping."</span>)
|
354
|
+
<span class="ruby-keyword kw">end</span>
|
355
|
+
<span class="ruby-identifier">intern_hash_keys</span>(<span class="ruby-identifier">ydoc</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">intern</span>
|
356
|
+
<span class="ruby-identifier">context</span> = <span class="ruby-constant">Object</span>.<span class="ruby-identifier">new</span>
|
357
|
+
<span class="ruby-identifier">ydoc</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
|
358
|
+
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">"@#{key}"</span>, <span class="ruby-identifier">val</span>)
|
359
|
+
<span class="ruby-keyword kw">end</span>
|
360
|
+
<span class="ruby-identifier">context</span>.<span class="ruby-identifier">extend</span>(<span class="ruby-identifier">mod</span>) <span class="ruby-comment cmt"># ERB::Util or Erubis::XmlHelper</span>
|
361
|
+
<span class="ruby-identifier">output</span> = <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-identifier">src</span>)
|
362
|
+
<span class="ruby-keyword kw">end</span>
|
363
|
+
|
364
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">output</span>
|
365
|
+
|
366
|
+
<span class="ruby-keyword kw">end</span>
|
367
|
+
</pre>
|
368
|
+
</div>
|
369
|
+
</div>
|
370
|
+
</div>
|
371
|
+
|
372
|
+
|
373
|
+
</div>
|
374
|
+
|
375
|
+
|
376
|
+
</div>
|
377
|
+
|
378
|
+
|
379
|
+
<div id="validator-badges">
|
380
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
381
|
+
</div>
|
382
|
+
|
383
|
+
</body>
|
384
|
+
</html>
|