kwartz 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +36 -1
- data/LGPL +504 -0
- data/README.txt +16 -2
- data/bin/kwartz +1 -1
- data/doc-api/classes/Kwartz.html +47 -1
- data/doc-api/classes/Kwartz/Assertion.html +6 -6
- data/doc-api/classes/Kwartz/AssertionError.html +6 -6
- data/doc-api/classes/Kwartz/AttrInfo.html +42 -42
- data/doc-api/classes/Kwartz/BaseError.html +12 -12
- data/doc-api/classes/Kwartz/BaseTranslator.html +210 -43
- data/doc-api/classes/Kwartz/CharacterType.html +24 -24
- data/doc-api/classes/Kwartz/CommandOptionError.html +7 -7
- data/doc-api/classes/Kwartz/CommandOptions.html +49 -49
- data/doc-api/classes/Kwartz/Config.html +6 -1
- data/doc-api/classes/Kwartz/ConvertError.html +14 -14
- data/doc-api/classes/Kwartz/Converter.html +31 -30
- data/doc-api/classes/Kwartz/CssStyleParser.html +79 -57
- data/doc-api/classes/Kwartz/Defun.html +313 -0
- data/doc-api/classes/Kwartz/DocumentRuleset.html +58 -58
- data/doc-api/classes/Kwartz/ElementExpander.html +32 -32
- data/doc-api/classes/Kwartz/ElementInfo.html +29 -29
- data/doc-api/classes/Kwartz/ElementRuleset.html +126 -96
- data/doc-api/classes/Kwartz/EperlHandler.html +108 -84
- data/doc-api/classes/Kwartz/EperlTranslator.html +7 -7
- data/doc-api/classes/Kwartz/ErubisHandler.html +2 -2
- data/doc-api/classes/Kwartz/ErubisTranslator.html +8 -8
- data/doc-api/classes/Kwartz/ErubyHandler.html +2 -220
- data/doc-api/classes/Kwartz/ErubyTranslator.html +7 -7
- data/doc-api/classes/Kwartz/ExpandStatement.html +20 -20
- data/doc-api/classes/Kwartz/Handler.html +122 -117
- data/doc-api/classes/Kwartz/HandlerArgument.html +215 -0
- data/doc-api/classes/Kwartz/Helper.html +112 -0
- data/doc-api/classes/Kwartz/Helper/ActionViewHelper.html +221 -0
- data/doc-api/classes/Kwartz/Helper/RailsTemplate.html +630 -0
- data/doc-api/classes/Kwartz/JstlHandler.html +208 -193
- data/doc-api/classes/Kwartz/JstlTranslator.html +15 -15
- data/doc-api/classes/Kwartz/KwartzError.html +6 -6
- data/doc-api/classes/Kwartz/Main.html +39 -23
- data/doc-api/classes/Kwartz/NativeExpression.html +18 -18
- data/doc-api/classes/Kwartz/NativeStatement.html +25 -25
- data/doc-api/classes/Kwartz/Node.html +6 -6
- data/doc-api/classes/Kwartz/PIErubisHandler.html +113 -0
- data/doc-api/classes/Kwartz/PIErubisTranslator.html +200 -0
- data/doc-api/classes/Kwartz/ParseError.html +6 -6
- data/doc-api/classes/Kwartz/PhpHandler.html +102 -83
- data/doc-api/classes/Kwartz/PhpTranslator.html +14 -14
- data/doc-api/classes/Kwartz/PresentationLogicParser.html +136 -128
- data/doc-api/classes/Kwartz/PrintStatement.html +19 -19
- data/doc-api/classes/Kwartz/RailsHandler.html +121 -118
- data/doc-api/classes/Kwartz/RailsTranslator.html +7 -7
- data/doc-api/classes/Kwartz/RubyHandler.html +349 -0
- data/doc-api/classes/Kwartz/RubyStyleParser.html +85 -85
- data/doc-api/classes/Kwartz/RubyTranslator.html +218 -0
- data/doc-api/classes/Kwartz/StatementHelper.html +479 -0
- data/doc-api/classes/Kwartz/StrutsTranslator.html +12 -12
- data/doc-api/classes/Kwartz/TagInfo.html +28 -28
- data/doc-api/classes/Kwartz/TextConverter.html +28 -28
- data/doc-api/classes/Kwartz/Translator.html +42 -42
- data/doc-api/classes/Kwartz/Util.html +284 -0
- data/doc-api/created.rid +1 -1
- data/doc-api/files/__/README_txt.html +30 -3
- data/doc-api/files/kwartz/assert_rb.html +1 -1
- data/doc-api/files/kwartz/binding/eperl_rb.html +2 -2
- data/doc-api/files/kwartz/binding/erubis_rb.html +3 -3
- data/doc-api/files/kwartz/binding/eruby_rb.html +3 -2
- data/doc-api/files/kwartz/binding/jstl_rb.html +2 -2
- data/doc-api/files/kwartz/binding/php_rb.html +2 -2
- data/doc-api/files/kwartz/binding/pierubis_rb.html +116 -0
- data/doc-api/files/kwartz/binding/rails_rb.html +2 -2
- data/doc-api/files/kwartz/binding/ruby_rb.html +115 -0
- data/doc-api/files/kwartz/binding/struts_rb.html +1 -1
- data/doc-api/files/kwartz/config_rb.html +2 -2
- data/doc-api/files/kwartz/converter_rb.html +3 -2
- data/doc-api/files/kwartz/defun_rb.html +116 -0
- data/doc-api/files/kwartz/error_rb.html +1 -1
- data/doc-api/files/kwartz/helper/rails_rb.html +123 -0
- data/doc-api/files/kwartz/main_rb.html +5 -2
- data/doc-api/files/kwartz/node_rb.html +2 -2
- data/doc-api/files/kwartz/parser_rb.html +2 -2
- data/doc-api/files/kwartz/translator_rb.html +2 -2
- 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 +107 -0
- data/doc-api/files/kwartz_rb.html +3 -2
- data/doc-api/fr_class_index.html +11 -0
- data/doc-api/fr_file_index.html +5 -0
- data/doc-api/fr_method_index.html +242 -190
- data/doc/p-pattern.html +94 -94
- data/doc/reference.html +847 -612
- data/doc/users-guide.html +744 -241
- data/examples/rails1/README +2 -2
- data/examples/rails1/application_helper.rb +2 -27
- data/examples/rails1/link_to.plogic +5 -5
- data/examples/rails1/list.plogic +2 -2
- data/examples/rails2/app/controllers/application.rb +14 -0
- data/examples/rails2/app/controllers/groups_controller.rb +47 -0
- data/examples/rails2/app/controllers/members_controller.rb +56 -0
- data/examples/rails2/app/helpers/application_helper.rb +6 -0
- data/examples/rails2/app/helpers/groups_helper.rb +2 -0
- data/examples/rails2/app/helpers/members_helper.rb +2 -0
- data/examples/rails2/app/models/group.rb +2 -0
- data/examples/rails2/app/models/member.rb +3 -0
- data/examples/rails2/app/views/groups/_form.html +30 -0
- data/examples/rails2/app/views/groups/_form.plogic +11 -0
- data/examples/rails2/app/views/groups/_link.plogic +19 -0
- data/examples/rails2/app/views/groups/_read.plogic +7 -0
- data/examples/rails2/app/views/groups/edit.cfg.yaml +2 -0
- data/examples/rails2/app/views/groups/edit.html +26 -0
- data/examples/rails2/app/views/groups/edit.plogic +9 -0
- data/examples/rails2/app/views/groups/list.html +48 -0
- data/examples/rails2/app/views/groups/list.plogic +32 -0
- data/examples/rails2/app/views/groups/new.cfg.yaml +2 -0
- data/examples/rails2/app/views/groups/new.html +27 -0
- data/examples/rails2/app/views/groups/new.plogic +9 -0
- data/examples/rails2/app/views/groups/show.html +27 -0
- data/examples/rails2/app/views/groups/show.plogic +2 -0
- data/examples/rails2/app/views/layouts/groups.html +23 -0
- data/examples/rails2/app/views/layouts/groups.plogic +11 -0
- data/examples/rails2/app/views/layouts/members.html +23 -0
- data/examples/rails2/app/views/layouts/members.plogic +11 -0
- data/examples/rails2/app/views/layouts/members2.html +24 -0
- data/examples/rails2/app/views/layouts/members2.plogic +11 -0
- data/examples/rails2/app/views/members/_form.plogic +27 -0
- data/examples/rails2/app/views/members/_link.plogic +19 -0
- data/examples/rails2/app/views/members/_read.plogic +29 -0
- data/examples/rails2/app/views/members/edit.cfg.yaml +6 -0
- data/examples/rails2/app/views/members/edit.html +27 -0
- data/examples/rails2/app/views/members/edit.plogic +10 -0
- data/examples/rails2/app/views/members/list.html +53 -0
- data/examples/rails2/app/views/members/list.plogic +32 -0
- data/examples/rails2/app/views/members/new.html +61 -0
- data/examples/rails2/app/views/members/new.plogic +17 -0
- data/examples/rails2/app/views/members/show.html +41 -0
- data/examples/rails2/app/views/members/show.plogic +3 -0
- data/examples/rails2/db/create-tables.mysql.sql +27 -0
- data/examples/rails2/db/create-tables.pgsql.sql +27 -0
- data/examples/rails2/db/insert-data.sql +21 -0
- data/examples/rails2/db/tabledef.yaml +51 -0
- data/kwartz.gemspec +4 -4
- data/lib/kwartz.rb +10 -2
- data/lib/kwartz/assert.rb +1 -1
- data/lib/kwartz/binding/eperl.rb +85 -61
- data/lib/kwartz/binding/erubis.rb +6 -8
- data/lib/kwartz/binding/eruby.rb +5 -120
- data/lib/kwartz/binding/jstl.rb +116 -101
- data/lib/kwartz/binding/php.rb +79 -60
- data/lib/kwartz/binding/pierubis.rb +58 -0
- data/lib/kwartz/binding/rails.rb +45 -42
- data/lib/kwartz/binding/ruby.rb +193 -0
- data/lib/kwartz/binding/struts.rb +1 -1
- data/lib/kwartz/config.rb +4 -3
- data/lib/kwartz/converter.rb +231 -68
- data/lib/kwartz/defun.rb +126 -0
- data/lib/kwartz/error.rb +1 -1
- data/lib/kwartz/helper/rails.rb +437 -0
- data/lib/kwartz/main.rb +30 -38
- data/lib/kwartz/node.rb +46 -31
- data/lib/kwartz/parser.rb +43 -15
- data/lib/kwartz/translator.rb +104 -6
- data/lib/kwartz/util.rb +113 -0
- data/lib/kwartz/util/assert-text-equal.rb +1 -1
- data/lib/kwartz/util/testcase-helper.rb +26 -8
- data/test/test-compile.rb +3 -3
- data/test/test-compile.yaml +135 -5
- data/test/test-converter.rb +16 -8
- data/test/test-converter.yaml +307 -76
- data/test/test-directives.rb +1 -1
- data/test/test-directives.yaml +964 -979
- data/test/test-main.rb +61 -146
- data/test/test-main.yaml +235 -0
- data/test/test-parser.rb +10 -12
- data/test/test-parser.yaml +484 -326
- data/test/test-rails.rb +1 -1
- data/test/test-rails.yaml +37 -37
- data/test/test-ruleset.rb +1 -1
- data/test/test-ruleset.yaml +34 -40
- data/test/test.rb +1 -1
- metadata +82 -3
- data/COPYING +0 -340
@@ -112,13 +112,13 @@ example of presentation logic in css style:
|
|
112
112
|
<h3 class="section-bar">Methods</h3>
|
113
113
|
|
114
114
|
<div class="name-list">
|
115
|
-
<a href="#
|
116
|
-
<a href="#
|
117
|
-
<a href="#
|
118
|
-
<a href="#
|
119
|
-
<a href="#
|
120
|
-
<a href="#
|
121
|
-
<a href="#
|
115
|
+
<a href="#M000078">has_colon?</a>
|
116
|
+
<a href="#M000076">keywords</a>
|
117
|
+
<a href="#M000074">parse</a>
|
118
|
+
<a href="#M000077">parse_document_ruleset</a>
|
119
|
+
<a href="#M000079">parse_element_ruleset</a>
|
120
|
+
<a href="#M000080">parse_import_command</a>
|
121
|
+
<a href="#M000075">scan_hook</a>
|
122
122
|
</div>
|
123
123
|
</div>
|
124
124
|
|
@@ -153,21 +153,21 @@ example of presentation logic in css style:
|
|
153
153
|
<div id="methods">
|
154
154
|
<h3 class="section-bar">Public Instance methods</h3>
|
155
155
|
|
156
|
-
<div id="method-
|
157
|
-
<a name="
|
156
|
+
<div id="method-M000074" class="method-detail">
|
157
|
+
<a name="M000074"></a>
|
158
158
|
|
159
159
|
<div class="method-heading">
|
160
|
-
<a href="#
|
160
|
+
<a href="#M000074" class="method-signature">
|
161
161
|
<span class="method-name">parse</span><span class="method-args">(input, filename='')</span>
|
162
162
|
</a>
|
163
163
|
</div>
|
164
164
|
|
165
165
|
<div class="method-description">
|
166
166
|
<p><a class="source-toggle" href="#"
|
167
|
-
onclick="toggleCode('
|
168
|
-
<div class="method-source-code" id="
|
167
|
+
onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
|
168
|
+
<div class="method-source-code" id="M000074-source">
|
169
169
|
<pre>
|
170
|
-
<span class="ruby-comment cmt"># File kwartz/parser.rb, line
|
170
|
+
<span class="ruby-comment cmt"># File kwartz/parser.rb, line 603</span>
|
171
171
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">filename</span>=<span class="ruby-value str">''</span>)
|
172
172
|
<span class="ruby-identifier">reset</span>(<span class="ruby-identifier">input</span>, <span class="ruby-identifier">filename</span>)
|
173
173
|
<span class="ruby-identifier">scan</span>()
|
@@ -187,11 +187,10 @@ example of presentation logic in css style:
|
|
187
187
|
<span class="ruby-identifier">scan_ident</span>()
|
188
188
|
<span class="ruby-identifier">name</span> = <span class="ruby-ivar">@value</span>
|
189
189
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'DOCUMENT'</span>
|
190
|
-
<span class="ruby-identifier">
|
190
|
+
<span class="ruby-identifier">rulesets</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">parse_document_ruleset</span>()
|
191
191
|
<span class="ruby-keyword kw">else</span>
|
192
|
-
<span class="ruby-identifier">
|
192
|
+
<span class="ruby-identifier">rulesets</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">parse_element_ruleset</span>()
|
193
193
|
<span class="ruby-keyword kw">end</span>
|
194
|
-
<span class="ruby-identifier">rulesets</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">ruleset</span>
|
195
194
|
<span class="ruby-keyword kw">end</span>
|
196
195
|
<span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
|
197
196
|
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">"'#{@value}': '#name' is expected."</span>)
|
@@ -205,21 +204,21 @@ example of presentation logic in css style:
|
|
205
204
|
|
206
205
|
<h3 class="section-bar">Protected Instance methods</h3>
|
207
206
|
|
208
|
-
<div id="method-
|
209
|
-
<a name="
|
207
|
+
<div id="method-M000078" class="method-detail">
|
208
|
+
<a name="M000078"></a>
|
210
209
|
|
211
210
|
<div class="method-heading">
|
212
|
-
<a href="#
|
211
|
+
<a href="#M000078" class="method-signature">
|
213
212
|
<span class="method-name">has_colon?</span><span class="method-args">()</span>
|
214
213
|
</a>
|
215
214
|
</div>
|
216
215
|
|
217
216
|
<div class="method-description">
|
218
217
|
<p><a class="source-toggle" href="#"
|
219
|
-
onclick="toggleCode('
|
220
|
-
<div class="method-source-code" id="
|
218
|
+
onclick="toggleCode('M000078-source');return false;">[Source]</a></p>
|
219
|
+
<div class="method-source-code" id="M000078-source">
|
221
220
|
<pre>
|
222
|
-
<span class="ruby-comment cmt"># File kwartz/parser.rb, line
|
221
|
+
<span class="ruby-comment cmt"># File kwartz/parser.rb, line 730</span>
|
223
222
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_colon?</span>
|
224
223
|
<span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@ch</span> <span class="ruby-operator">==</span> <span class="ruby-value">?:</span>
|
225
224
|
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">"'#{@value}': ':' is required."</span>)
|
@@ -231,21 +230,21 @@ example of presentation logic in css style:
|
|
231
230
|
</div>
|
232
231
|
</div>
|
233
232
|
|
234
|
-
<div id="method-
|
235
|
-
<a name="
|
233
|
+
<div id="method-M000076" class="method-detail">
|
234
|
+
<a name="M000076"></a>
|
236
235
|
|
237
236
|
<div class="method-heading">
|
238
|
-
<a href="#
|
237
|
+
<a href="#M000076" class="method-signature">
|
239
238
|
<span class="method-name">keywords</span><span class="method-args">(keyword)</span>
|
240
239
|
</a>
|
241
240
|
</div>
|
242
241
|
|
243
242
|
<div class="method-description">
|
244
243
|
<p><a class="source-toggle" href="#"
|
245
|
-
onclick="toggleCode('
|
246
|
-
<div class="method-source-code" id="
|
244
|
+
onclick="toggleCode('M000076-source');return false;">[Source]</a></p>
|
245
|
+
<div class="method-source-code" id="M000076-source">
|
247
246
|
<pre>
|
248
|
-
<span class="ruby-comment cmt"># File kwartz/parser.rb, line
|
247
|
+
<span class="ruby-comment cmt"># File kwartz/parser.rb, line 691</span>
|
249
248
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">keywords</span>(<span class="ruby-identifier">keyword</span>)
|
250
249
|
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">CSSSTYLE_KEYWORDS</span>[<span class="ruby-identifier">keyword</span>]
|
251
250
|
<span class="ruby-keyword kw">end</span>
|
@@ -254,21 +253,21 @@ example of presentation logic in css style:
|
|
254
253
|
</div>
|
255
254
|
</div>
|
256
255
|
|
257
|
-
<div id="method-
|
258
|
-
<a name="
|
256
|
+
<div id="method-M000077" class="method-detail">
|
257
|
+
<a name="M000077"></a>
|
259
258
|
|
260
259
|
<div class="method-heading">
|
261
|
-
<a href="#
|
260
|
+
<a href="#M000077" class="method-signature">
|
262
261
|
<span class="method-name">parse_document_ruleset</span><span class="method-args">()</span>
|
263
262
|
</a>
|
264
263
|
</div>
|
265
264
|
|
266
265
|
<div class="method-description">
|
267
266
|
<p><a class="source-toggle" href="#"
|
268
|
-
onclick="toggleCode('
|
269
|
-
<div class="method-source-code" id="
|
267
|
+
onclick="toggleCode('M000077-source');return false;">[Source]</a></p>
|
268
|
+
<div class="method-source-code" id="M000077-source">
|
270
269
|
<pre>
|
271
|
-
<span class="ruby-comment cmt"># File kwartz/parser.rb, line
|
270
|
+
<span class="ruby-comment cmt"># File kwartz/parser.rb, line 697</span>
|
272
271
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_document_ruleset</span>
|
273
272
|
<span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@value</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'DOCUMENT'</span>
|
274
273
|
<span class="ruby-identifier">start_linenum</span> = <span class="ruby-ivar">@linenum</span>
|
@@ -284,8 +283,8 @@ example of presentation logic in css style:
|
|
284
283
|
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:global</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_global</span> <span class="ruby-identifier">_parse_words</span>()
|
285
284
|
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:local</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_local</span> <span class="ruby-identifier">_parse_words</span>()
|
286
285
|
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:fixture</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_fixture</span> <span class="ruby-identifier">_parse_block</span>()
|
287
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:begin</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_begin</span>
|
288
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:end</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_end</span>
|
286
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:begin</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_begin</span> <span class="ruby-identifier">_parse_block</span>()
|
287
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:end</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_end</span> <span class="ruby-identifier">_parse_block</span>()
|
289
288
|
<span class="ruby-comment cmt">#when :before ; has_colon?(); ruleset.set_before _parse_block()</span>
|
290
289
|
<span class="ruby-comment cmt">#when :after ; has_colon?(); ruleset.set_after _parse_block()</span>
|
291
290
|
<span class="ruby-keyword kw">else</span>
|
@@ -305,29 +304,41 @@ example of presentation logic in css style:
|
|
305
304
|
</div>
|
306
305
|
</div>
|
307
306
|
|
308
|
-
<div id="method-
|
309
|
-
<a name="
|
307
|
+
<div id="method-M000079" class="method-detail">
|
308
|
+
<a name="M000079"></a>
|
310
309
|
|
311
310
|
<div class="method-heading">
|
312
|
-
<a href="#
|
311
|
+
<a href="#M000079" class="method-signature">
|
313
312
|
<span class="method-name">parse_element_ruleset</span><span class="method-args">()</span>
|
314
313
|
</a>
|
315
314
|
</div>
|
316
315
|
|
317
316
|
<div class="method-description">
|
318
317
|
<p><a class="source-toggle" href="#"
|
319
|
-
onclick="toggleCode('
|
320
|
-
<div class="method-source-code" id="
|
318
|
+
onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
|
319
|
+
<div class="method-source-code" id="M000079-source">
|
321
320
|
<pre>
|
322
|
-
<span class="ruby-comment cmt"># File kwartz/parser.rb, line
|
321
|
+
<span class="ruby-comment cmt"># File kwartz/parser.rb, line 738</span>
|
323
322
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_element_ruleset</span>
|
324
323
|
<span class="ruby-identifier">assert</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:ident</span>
|
325
324
|
<span class="ruby-identifier">start_linenum</span> = <span class="ruby-ivar">@linenum</span>
|
326
325
|
<span class="ruby-identifier">name</span> = <span class="ruby-ivar">@value</span>
|
326
|
+
<span class="ruby-comment cmt">#names = [name]</span>
|
327
|
+
<span class="ruby-identifier">names</span> = []
|
327
328
|
<span class="ruby-identifier">scan</span>()
|
329
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-value str">','</span><span class="ruby-value str">','</span>
|
330
|
+
<span class="ruby-identifier">scan</span>()
|
331
|
+
<span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-value">?#</span>
|
332
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">"'#{@value}': '#name' is expected."</span>)
|
333
|
+
<span class="ruby-keyword kw">end</span>
|
334
|
+
<span class="ruby-identifier">scan_ident</span>()
|
335
|
+
<span class="ruby-identifier">names</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@value</span>
|
336
|
+
<span class="ruby-identifier">scan</span>()
|
337
|
+
<span class="ruby-keyword kw">end</span>
|
328
338
|
<span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'{'</span><span class="ruby-value str">'{'</span>
|
329
339
|
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">"'#{@value}': '{' is expected."</span>)
|
330
340
|
<span class="ruby-keyword kw">end</span>
|
341
|
+
|
331
342
|
<span class="ruby-identifier">ruleset</span> = <span class="ruby-constant">ElementRuleset</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">name</span>)
|
332
343
|
<span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
|
333
344
|
<span class="ruby-identifier">scan</span>()
|
@@ -343,45 +354,53 @@ example of presentation logic in css style:
|
|
343
354
|
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:attrs</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_attrs</span> <span class="ruby-identifier">_parse_pairs</span>(), <span class="ruby-identifier">flag_escape</span>
|
344
355
|
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:append</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_append</span> <span class="ruby-identifier">_parse_exprs</span>(), <span class="ruby-identifier">flag_escape</span>
|
345
356
|
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:remove</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_remove</span> <span class="ruby-identifier">_parse_strs</span>()
|
346
|
-
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:tagname</span>; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_tagname</span>
|
357
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:tagname</span>; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_tagname</span> <span class="ruby-identifier">_parse_str</span>()
|
347
358
|
<span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:logic</span> ; <span class="ruby-identifier">has_colon?</span>(); <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">set_logic</span> <span class="ruby-identifier">_parse_block</span>()
|
348
359
|
<span class="ruby-keyword kw">else</span>
|
349
360
|
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">"'#{@value}': unexpected token."</span>)
|
350
361
|
<span class="ruby-keyword kw">end</span>
|
351
362
|
<span class="ruby-keyword kw">end</span>
|
363
|
+
<span class="ruby-comment cmt">## build rulesets</span>
|
364
|
+
<span class="ruby-identifier">rulesets</span> = [<span class="ruby-identifier">ruleset</span>]
|
365
|
+
<span class="ruby-identifier">names</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">rulesets</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">ruleset</span>.<span class="ruby-identifier">duplicate</span>(<span class="ruby-identifier">name</span>) <span class="ruby-keyword kw">end</span>
|
366
|
+
|
352
367
|
<span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span>
|
353
368
|
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-node">"'##{name}': is not closed by '}'."</span>, <span class="ruby-identifier">start_linenum</span>)
|
354
369
|
<span class="ruby-keyword kw">end</span>
|
355
370
|
<span class="ruby-identifier">assert</span> <span class="ruby-node">"@token=#{@token.inspect}"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@token</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'}'</span><span class="ruby-value str">'}'</span>
|
356
371
|
<span class="ruby-identifier">scan</span>()
|
357
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">
|
372
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">rulesets</span>
|
358
373
|
<span class="ruby-keyword kw">end</span>
|
359
374
|
</pre>
|
360
375
|
</div>
|
361
376
|
</div>
|
362
377
|
</div>
|
363
378
|
|
364
|
-
<div id="method-
|
365
|
-
<a name="
|
379
|
+
<div id="method-M000080" class="method-detail">
|
380
|
+
<a name="M000080"></a>
|
366
381
|
|
367
382
|
<div class="method-heading">
|
368
|
-
<a href="#
|
383
|
+
<a href="#M000080" class="method-signature">
|
369
384
|
<span class="method-name">parse_import_command</span><span class="method-args">()</span>
|
370
385
|
</a>
|
371
386
|
</div>
|
372
387
|
|
373
388
|
<div class="method-description">
|
374
389
|
<p><a class="source-toggle" href="#"
|
375
|
-
onclick="toggleCode('
|
376
|
-
<div class="method-source-code" id="
|
390
|
+
onclick="toggleCode('M000080-source');return false;">[Source]</a></p>
|
391
|
+
<div class="method-source-code" id="M000080-source">
|
377
392
|
<pre>
|
378
|
-
<span class="ruby-comment cmt"># File kwartz/parser.rb, line
|
393
|
+
<span class="ruby-comment cmt"># File kwartz/parser.rb, line 792</span>
|
379
394
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_import_command</span>
|
380
395
|
<span class="ruby-identifier">c</span> = <span class="ruby-ivar">@ch</span>
|
381
396
|
<span class="ruby-identifier">c</span> = <span class="ruby-identifier">getch</span>() <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">is_whitespace</span>(<span class="ruby-identifier">c</span>)
|
382
397
|
<span class="ruby-identifier">t</span> = <span class="ruby-identifier">scan_string</span>()
|
383
398
|
<span class="ruby-identifier">t</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:string</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-identifier">parse_error</span>(<span class="ruby-value str">"@import: requires filename."</span>)
|
384
399
|
<span class="ruby-identifier">filename</span> = <span class="ruby-ivar">@value</span>
|
400
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@filename</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@filename</span>.<span class="ruby-identifier">empty?</span>
|
401
|
+
<span class="ruby-identifier">dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-ivar">@filename</span>)
|
402
|
+
<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'/'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">filename</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">'.'</span>
|
403
|
+
<span class="ruby-keyword kw">end</span>
|
385
404
|
<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">parse_error</span>(<span class="ruby-node">"'#{filename}': import file not found."</span>)
|
386
405
|
<span class="ruby-identifier">c</span> = <span class="ruby-ivar">@ch</span>
|
387
406
|
<span class="ruby-identifier">c</span> = <span class="ruby-identifier">getch</span>() <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">is_whitespace</span>(<span class="ruby-identifier">c</span>)
|
@@ -397,21 +416,24 @@ example of presentation logic in css style:
|
|
397
416
|
</div>
|
398
417
|
</div>
|
399
418
|
|
400
|
-
<div id="method-
|
401
|
-
<a name="
|
419
|
+
<div id="method-M000075" class="method-detail">
|
420
|
+
<a name="M000075"></a>
|
402
421
|
|
403
422
|
<div class="method-heading">
|
404
|
-
<a href="#
|
423
|
+
<a href="#M000075" class="method-signature">
|
405
424
|
<span class="method-name">scan_hook</span><span class="method-args">()</span>
|
406
425
|
</a>
|
407
426
|
</div>
|
408
427
|
|
409
428
|
<div class="method-description">
|
429
|
+
<p>
|
430
|
+
return false when not hooked
|
431
|
+
</p>
|
410
432
|
<p><a class="source-toggle" href="#"
|
411
|
-
onclick="toggleCode('
|
412
|
-
<div class="method-source-code" id="
|
433
|
+
onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
|
434
|
+
<div class="method-source-code" id="M000075-source">
|
413
435
|
<pre>
|
414
|
-
<span class="ruby-comment cmt"># File kwartz/parser.rb, line
|
436
|
+
<span class="ruby-comment cmt"># File kwartz/parser.rb, line 638</span>
|
415
437
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scan_hook</span>
|
416
438
|
<span class="ruby-comment cmt">## comment</span>
|
417
439
|
<span class="ruby-identifier">c</span> = <span class="ruby-ivar">@ch</span>
|
@@ -460,7 +482,7 @@ example of presentation logic in css style:
|
|
460
482
|
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@token</span> = <span class="ruby-value">?@</span>
|
461
483
|
<span class="ruby-keyword kw">end</span>
|
462
484
|
|
463
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">
|
485
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
464
486
|
|
465
487
|
<span class="ruby-keyword kw">end</span>
|
466
488
|
</pre>
|
@@ -0,0 +1,313 @@
|
|
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>Module: Kwartz::Defun</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>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">Kwartz::Defun</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/kwartz/defun_rb.html">
|
59
|
+
kwartz/defun.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
<!-- banner header -->
|
68
|
+
|
69
|
+
<div id="bodyContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div id="contextContent">
|
74
|
+
|
75
|
+
<div id="description">
|
76
|
+
<p>
|
77
|
+
generate compiled code. see defun() method for usage.
|
78
|
+
</p>
|
79
|
+
|
80
|
+
</div>
|
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="#M000014">build_defun_code</a>
|
90
|
+
<a href="#M000016">build_php_code</a>
|
91
|
+
<a href="#M000015">build_ruby_code</a>
|
92
|
+
<a href="#M000013">compile_into_lang_code</a>
|
93
|
+
<a href="#M000012">defun</a>
|
94
|
+
</div>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
</div>
|
98
|
+
|
99
|
+
|
100
|
+
<!-- if includes -->
|
101
|
+
|
102
|
+
<div id="section">
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
<!-- if method_list -->
|
112
|
+
<div id="methods">
|
113
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
114
|
+
|
115
|
+
<div id="method-M000014" class="method-detail">
|
116
|
+
<a name="M000014"></a>
|
117
|
+
|
118
|
+
<div class="method-heading">
|
119
|
+
<a href="#M000014" class="method-signature">
|
120
|
+
<span class="method-name">build_defun_code</span><span class="method-args">(basename, code, lang, properties)</span>
|
121
|
+
</a>
|
122
|
+
</div>
|
123
|
+
|
124
|
+
<div class="method-description">
|
125
|
+
<p><a class="source-toggle" href="#"
|
126
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
127
|
+
<div class="method-source-code" id="M000014-source">
|
128
|
+
<pre>
|
129
|
+
<span class="ruby-comment cmt"># File kwartz/defun.rb, line 63</span>
|
130
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_defun_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">lang</span>, <span class="ruby-identifier">properties</span>)
|
131
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">lang</span>
|
132
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value str">'ruby'</span>, <span class="ruby-value str">'eruby'</span>, <span class="ruby-value str">'rails'</span>, <span class="ruby-value str">'erubis'</span>, <span class="ruby-value str">'pierubis'</span>
|
133
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">build_ruby_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">properties</span>)
|
134
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value str">'php'</span>
|
135
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">build_php_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">code</span>, <span class="ruby-identifier">properties</span>)
|
136
|
+
<span class="ruby-keyword kw">else</span>
|
137
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"'#{lang}': not supported language."</span>
|
138
|
+
<span class="ruby-keyword kw">end</span>
|
139
|
+
<span class="ruby-keyword kw">end</span>
|
140
|
+
</pre>
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
</div>
|
144
|
+
|
145
|
+
<div id="method-M000016" class="method-detail">
|
146
|
+
<a name="M000016"></a>
|
147
|
+
|
148
|
+
<div class="method-heading">
|
149
|
+
<a href="#M000016" class="method-signature">
|
150
|
+
<span class="method-name">build_php_code</span><span class="method-args">(basename, php_code, properties)</span>
|
151
|
+
</a>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
<div class="method-description">
|
155
|
+
<p><a class="source-toggle" href="#"
|
156
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
157
|
+
<div class="method-source-code" id="M000016-source">
|
158
|
+
<pre>
|
159
|
+
<span class="ruby-comment cmt"># File kwartz/defun.rb, line 103</span>
|
160
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_php_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">php_code</span>, <span class="ruby-identifier">properties</span>)
|
161
|
+
<span class="ruby-identifier">basename</span> = <span class="ruby-identifier">basename</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[^\w]/</span>, <span class="ruby-value str">'_'</span>)
|
162
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-value str">"<?php\nfunction print_view_\#{basename}($context) {\n explode($context);\n?>\#{php_code}<?php\n}\nfunction expand_view_\#{basename}($context) {\n ob_start();\n print_view_\#{basename}($context);\n $output = ob_get_clean();\n ob_end_clean();\n return $output;\n}\n?>\n"</span>
|
163
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
|
164
|
+
<span class="ruby-keyword kw">end</span>
|
165
|
+
</pre>
|
166
|
+
</div>
|
167
|
+
</div>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
<div id="method-M000015" class="method-detail">
|
171
|
+
<a name="M000015"></a>
|
172
|
+
|
173
|
+
<div class="method-heading">
|
174
|
+
<a href="#M000015" class="method-signature">
|
175
|
+
<span class="method-name">build_ruby_code</span><span class="method-args">(basename, ruby_code, properties)</span>
|
176
|
+
</a>
|
177
|
+
</div>
|
178
|
+
|
179
|
+
<div class="method-description">
|
180
|
+
<p><a class="source-toggle" href="#"
|
181
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
182
|
+
<div class="method-source-code" id="M000015-source">
|
183
|
+
<pre>
|
184
|
+
<span class="ruby-comment cmt"># File kwartz/defun.rb, line 75</span>
|
185
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_ruby_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">ruby_code</span>, <span class="ruby-identifier">properties</span>)
|
186
|
+
<span class="ruby-identifier">basename</span> = <span class="ruby-identifier">basename</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[^\w]/</span>, <span class="ruby-value str">'_'</span>)
|
187
|
+
<span class="ruby-identifier">module_name</span> = <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">:module</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:module</span>] <span class="ruby-operator">:</span> <span class="ruby-value str">'View'</span>
|
188
|
+
<span class="ruby-identifier">method_verb</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:verb</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">'expand'</span>
|
189
|
+
<span class="ruby-identifier">method_name</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:method</span>] <span class="ruby-operator">||</span> <span class="ruby-node">"#{method_verb}_#{basename}"</span>
|
190
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-value str">''</span>
|
191
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"module #{module_name}\n"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">module_name</span>
|
192
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n"</span>
|
193
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" (@@proc_table ||= {})['#{basename}'] = proc do\n"</span>
|
194
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">ruby_code</span> <span class="ruby-operator"><<</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">ruby_code</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">ruby_code</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">?\n</span> <span class="ruby-operator">?</span> <span class="ruby-value str">"\n"</span> <span class="ruby-operator">:</span> <span class="ruby-value str">''</span>)
|
195
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" end#proc\n"</span>
|
196
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n"</span>
|
197
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" module_function\n"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">module_name</span>
|
198
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" def #{method_name}(context={})\n"</span>
|
199
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" if context.is_a?(Hash)\n"</span>
|
200
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" hash = context\n"</span>
|
201
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" context = Object.new\n"</span>
|
202
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" hash.each { |key, val| context.instance_variable_set(\"@\#{key}\", val) }\n"</span>
|
203
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" end\n"</span>
|
204
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" proc_obj = @@proc_table['#{basename}']\n"</span>
|
205
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" context.instance_eval(&proc_obj)\n"</span>
|
206
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">" end\n"</span>
|
207
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"\n"</span>
|
208
|
+
<span class="ruby-identifier">s</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"end\n"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">module_name</span>
|
209
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
|
210
|
+
<span class="ruby-keyword kw">end</span>
|
211
|
+
</pre>
|
212
|
+
</div>
|
213
|
+
</div>
|
214
|
+
</div>
|
215
|
+
|
216
|
+
<div id="method-M000013" class="method-detail">
|
217
|
+
<a name="M000013"></a>
|
218
|
+
|
219
|
+
<div class="method-heading">
|
220
|
+
<a href="#M000013" class="method-signature">
|
221
|
+
<span class="method-name">compile_into_lang_code</span><span class="method-args">(output, lang, properties)</span>
|
222
|
+
</a>
|
223
|
+
</div>
|
224
|
+
|
225
|
+
<div class="method-description">
|
226
|
+
<p><a class="source-toggle" href="#"
|
227
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
228
|
+
<div class="method-source-code" id="M000013-source">
|
229
|
+
<pre>
|
230
|
+
<span class="ruby-comment cmt"># File kwartz/defun.rb, line 41</span>
|
231
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">compile_into_lang_code</span>(<span class="ruby-identifier">output</span>, <span class="ruby-identifier">lang</span>, <span class="ruby-identifier">properties</span>)
|
232
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">lang</span>
|
233
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value str">'ruby'</span>
|
234
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">output</span>
|
235
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value str">'eruby'</span>, <span class="ruby-value str">'rails'</span>
|
236
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'erb'</span>
|
237
|
+
<span class="ruby-identifier">trim_mode</span> = <span class="ruby-identifier">properties</span>[<span class="ruby-identifier">:trim_mode</span>] <span class="ruby-operator">||</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-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'-'</span>)
|
238
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">ERB</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">output</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">trim_mode</span>).<span class="ruby-identifier">src</span>
|
239
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value str">'erubis'</span>
|
240
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'erubis'</span>
|
241
|
+
<span class="ruby-keyword kw">return</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-keyword kw">nil</span>, <span class="ruby-identifier">properties</span>).<span class="ruby-identifier">convert</span>(<span class="ruby-identifier">output</span>)
|
242
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value str">'pierubis'</span>
|
243
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'erubis'</span>
|
244
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">Erubis</span><span class="ruby-operator">::</span><span class="ruby-constant">PI</span><span class="ruby-operator">::</span><span class="ruby-constant">Eruby</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">properties</span>).<span class="ruby-identifier">convert</span>(<span class="ruby-identifier">output</span>)
|
245
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value str">'php'</span>
|
246
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">output</span>
|
247
|
+
<span class="ruby-keyword kw">else</span>
|
248
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"'#{lang}': not supported language."</span>
|
249
|
+
<span class="ruby-keyword kw">end</span>
|
250
|
+
<span class="ruby-keyword kw">end</span>
|
251
|
+
</pre>
|
252
|
+
</div>
|
253
|
+
</div>
|
254
|
+
</div>
|
255
|
+
|
256
|
+
<div id="method-M000012" class="method-detail">
|
257
|
+
<a name="M000012"></a>
|
258
|
+
|
259
|
+
<div class="method-heading">
|
260
|
+
<a href="#M000012" class="method-signature">
|
261
|
+
<span class="method-name">defun</span><span class="method-args">(basename, output, lang, properties={})</span>
|
262
|
+
</a>
|
263
|
+
</div>
|
264
|
+
|
265
|
+
<div class="method-description">
|
266
|
+
<p>
|
267
|
+
generate compiled code
|
268
|
+
</p>
|
269
|
+
<p>
|
270
|
+
ex.
|
271
|
+
</p>
|
272
|
+
<pre>
|
273
|
+
args = %w[-l eruby -p ex.plogic ex.html]
|
274
|
+
eruby_src = Kwartz::Main.new(args).execute()
|
275
|
+
properties = { :trim_mode=>'>' }
|
276
|
+
code = Kwartz::Defun.defun('ex', eruby_src, 'eruby', properties)
|
277
|
+
print code
|
278
|
+
</pre>
|
279
|
+
<p>
|
280
|
+
command-line properties:
|
281
|
+
</p>
|
282
|
+
<pre>
|
283
|
+
--module=name : module name (default 'View')
|
284
|
+
--method=name : method name (default 'expand_xxx')
|
285
|
+
</pre>
|
286
|
+
<p><a class="source-toggle" href="#"
|
287
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
288
|
+
<div class="method-source-code" id="M000012-source">
|
289
|
+
<pre>
|
290
|
+
<span class="ruby-comment cmt"># File kwartz/defun.rb, line 34</span>
|
291
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">defun</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">output</span>, <span class="ruby-identifier">lang</span>, <span class="ruby-identifier">properties</span>={})
|
292
|
+
<span class="ruby-identifier">lang_code</span> = <span class="ruby-identifier">compile_into_lang_code</span>(<span class="ruby-identifier">output</span>, <span class="ruby-identifier">lang</span>, <span class="ruby-identifier">properties</span>)
|
293
|
+
<span class="ruby-identifier">s</span> = <span class="ruby-identifier">build_defun_code</span>(<span class="ruby-identifier">basename</span>, <span class="ruby-identifier">lang_code</span>, <span class="ruby-identifier">lang</span>, <span class="ruby-identifier">properties</span>)
|
294
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
|
295
|
+
<span class="ruby-keyword kw">end</span>
|
296
|
+
</pre>
|
297
|
+
</div>
|
298
|
+
</div>
|
299
|
+
</div>
|
300
|
+
|
301
|
+
|
302
|
+
</div>
|
303
|
+
|
304
|
+
|
305
|
+
</div>
|
306
|
+
|
307
|
+
|
308
|
+
<div id="validator-badges">
|
309
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
310
|
+
</div>
|
311
|
+
|
312
|
+
</body>
|
313
|
+
</html>
|