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
@@ -0,0 +1,630 @@
|
|
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::Helper::RailsTemplate</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::Helper::RailsTemplate</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/kwartz/helper/rails_rb.html">
|
59
|
+
kwartz/helper/rails.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
|
+
helper class to use <a href="../../Kwartz.html">Kwartz</a> in Rails
|
84
|
+
</p>
|
85
|
+
<p>
|
86
|
+
How to use <a href="../../Kwartz.html">Kwartz</a> in Rails:
|
87
|
+
</p>
|
88
|
+
<ol>
|
89
|
+
<li>add the folliwng code in your ‘app/controllers/application.rb’.
|
90
|
+
|
91
|
+
<pre>
|
92
|
+
--------------------
|
93
|
+
require 'kwartz/helper/rails'
|
94
|
+
ActionView::Base.register_template_handler('html', Kwartz::Helper::RailsTemplate)
|
95
|
+
#Kwartz::Helper::RailsTemplate.pdata_suffix = '.html'
|
96
|
+
#Kwartz::Helper::RailsTemplate.plogic_suffix = '.plogic'
|
97
|
+
#Kwartz::Helper::RailsTemplate.default_properties = { :escape=>true }
|
98
|
+
#Kwartz::Helper::RailsTemplate.debug = false
|
99
|
+
--------------------
|
100
|
+
</pre>
|
101
|
+
</li>
|
102
|
+
<li>restart web server.
|
103
|
+
|
104
|
+
</li>
|
105
|
+
<li>put template files ’*.html’ and ’*.plogic’ in
|
106
|
+
‘app/views/xxx’. layout files
|
107
|
+
(‘app/views/layouts/xxx.{html,plogic}’) is also available.
|
108
|
+
|
109
|
+
</li>
|
110
|
+
</ol>
|
111
|
+
|
112
|
+
</div>
|
113
|
+
|
114
|
+
|
115
|
+
</div>
|
116
|
+
|
117
|
+
<div id="method-list">
|
118
|
+
<h3 class="section-bar">Methods</h3>
|
119
|
+
|
120
|
+
<div class="name-list">
|
121
|
+
<a href="#M000040">add_cache</a>
|
122
|
+
<a href="#M000042">debug</a>
|
123
|
+
<a href="#M000043">debug=</a>
|
124
|
+
<a href="#M000030">default_properties</a>
|
125
|
+
<a href="#M000031">default_properties=</a>
|
126
|
+
<a href="#M000041">get_cache</a>
|
127
|
+
<a href="#M000036">lang</a>
|
128
|
+
<a href="#M000037">lang=</a>
|
129
|
+
<a href="#M000044">new</a>
|
130
|
+
<a href="#M000032">pdata_suffix</a>
|
131
|
+
<a href="#M000033">pdata_suffix=</a>
|
132
|
+
<a href="#M000034">plogic_suffix</a>
|
133
|
+
<a href="#M000035">plogic_suffix=</a>
|
134
|
+
<a href="#M000045">render</a>
|
135
|
+
<a href="#M000038">use_cache</a>
|
136
|
+
<a href="#M000039">use_cache=</a>
|
137
|
+
</div>
|
138
|
+
</div>
|
139
|
+
|
140
|
+
</div>
|
141
|
+
|
142
|
+
|
143
|
+
<!-- if includes -->
|
144
|
+
|
145
|
+
<div id="section">
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
<!-- if method_list -->
|
155
|
+
<div id="methods">
|
156
|
+
<h3 class="section-bar">Public Class methods</h3>
|
157
|
+
|
158
|
+
<div id="method-M000040" class="method-detail">
|
159
|
+
<a name="M000040"></a>
|
160
|
+
|
161
|
+
<div class="method-heading">
|
162
|
+
<a href="#M000040" class="method-signature">
|
163
|
+
<span class="method-name">add_cache</span><span class="method-args">(_ruby_code, _filename)</span>
|
164
|
+
</a>
|
165
|
+
</div>
|
166
|
+
|
167
|
+
<div class="method-description">
|
168
|
+
<p><a class="source-toggle" href="#"
|
169
|
+
onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
|
170
|
+
<div class="method-source-code" id="M000040-source">
|
171
|
+
<pre>
|
172
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 104</span>
|
173
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">add_cache</span>(<span class="ruby-identifier">_ruby_code</span>, <span class="ruby-identifier">_filename</span>)
|
174
|
+
<span class="ruby-identifier">_proc_obj</span> = <span class="ruby-identifier">eval</span> <span class="ruby-node">"proc do #{_ruby_code} end"</span>, <span class="ruby-identifier">binding</span>(), <span class="ruby-identifier">_filename</span>
|
175
|
+
<span class="ruby-ivar">@@cache_table</span>[<span class="ruby-identifier">_filename</span>] = <span class="ruby-identifier">_proc_obj</span>
|
176
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">_proc_obj</span>
|
177
|
+
<span class="ruby-keyword kw">end</span>
|
178
|
+
</pre>
|
179
|
+
</div>
|
180
|
+
</div>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<div id="method-M000042" class="method-detail">
|
184
|
+
<a name="M000042"></a>
|
185
|
+
|
186
|
+
<div class="method-heading">
|
187
|
+
<a href="#M000042" class="method-signature">
|
188
|
+
<span class="method-name">debug</span><span class="method-args">()</span>
|
189
|
+
</a>
|
190
|
+
</div>
|
191
|
+
|
192
|
+
<div class="method-description">
|
193
|
+
<p><a class="source-toggle" href="#"
|
194
|
+
onclick="toggleCode('M000042-source');return false;">[Source]</a></p>
|
195
|
+
<div class="method-source-code" id="M000042-source">
|
196
|
+
<pre>
|
197
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 117</span>
|
198
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">debug</span>
|
199
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@@debug</span>
|
200
|
+
<span class="ruby-keyword kw">end</span>
|
201
|
+
</pre>
|
202
|
+
</div>
|
203
|
+
</div>
|
204
|
+
</div>
|
205
|
+
|
206
|
+
<div id="method-M000043" class="method-detail">
|
207
|
+
<a name="M000043"></a>
|
208
|
+
|
209
|
+
<div class="method-heading">
|
210
|
+
<a href="#M000043" class="method-signature">
|
211
|
+
<span class="method-name">debug=</span><span class="method-args">(flag)</span>
|
212
|
+
</a>
|
213
|
+
</div>
|
214
|
+
|
215
|
+
<div class="method-description">
|
216
|
+
<p><a class="source-toggle" href="#"
|
217
|
+
onclick="toggleCode('M000043-source');return false;">[Source]</a></p>
|
218
|
+
<div class="method-source-code" id="M000043-source">
|
219
|
+
<pre>
|
220
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 121</span>
|
221
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">debug=</span>(<span class="ruby-identifier">flag</span>)
|
222
|
+
<span class="ruby-ivar">@@debug</span> = <span class="ruby-identifier">flag</span>
|
223
|
+
<span class="ruby-keyword kw">end</span>
|
224
|
+
</pre>
|
225
|
+
</div>
|
226
|
+
</div>
|
227
|
+
</div>
|
228
|
+
|
229
|
+
<div id="method-M000030" class="method-detail">
|
230
|
+
<a name="M000030"></a>
|
231
|
+
|
232
|
+
<div class="method-heading">
|
233
|
+
<a href="#M000030" class="method-signature">
|
234
|
+
<span class="method-name">default_properties</span><span class="method-args">()</span>
|
235
|
+
</a>
|
236
|
+
</div>
|
237
|
+
|
238
|
+
<div class="method-description">
|
239
|
+
<p><a class="source-toggle" href="#"
|
240
|
+
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
241
|
+
<div class="method-source-code" id="M000030-source">
|
242
|
+
<pre>
|
243
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 44</span>
|
244
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">default_properties</span>
|
245
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@@default_properties</span>
|
246
|
+
<span class="ruby-keyword kw">end</span>
|
247
|
+
</pre>
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
</div>
|
251
|
+
|
252
|
+
<div id="method-M000031" class="method-detail">
|
253
|
+
<a name="M000031"></a>
|
254
|
+
|
255
|
+
<div class="method-heading">
|
256
|
+
<a href="#M000031" class="method-signature">
|
257
|
+
<span class="method-name">default_properties=</span><span class="method-args">(hash)</span>
|
258
|
+
</a>
|
259
|
+
</div>
|
260
|
+
|
261
|
+
<div class="method-description">
|
262
|
+
<p><a class="source-toggle" href="#"
|
263
|
+
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
|
264
|
+
<div class="method-source-code" id="M000031-source">
|
265
|
+
<pre>
|
266
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 48</span>
|
267
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">default_properties=</span>(<span class="ruby-identifier">hash</span>)
|
268
|
+
<span class="ruby-ivar">@@default_properties</span> = <span class="ruby-identifier">hash</span>
|
269
|
+
<span class="ruby-keyword kw">end</span>
|
270
|
+
</pre>
|
271
|
+
</div>
|
272
|
+
</div>
|
273
|
+
</div>
|
274
|
+
|
275
|
+
<div id="method-M000041" class="method-detail">
|
276
|
+
<a name="M000041"></a>
|
277
|
+
|
278
|
+
<div class="method-heading">
|
279
|
+
<a href="#M000041" class="method-signature">
|
280
|
+
<span class="method-name">get_cache</span><span class="method-args">(filename)</span>
|
281
|
+
</a>
|
282
|
+
</div>
|
283
|
+
|
284
|
+
<div class="method-description">
|
285
|
+
<p><a class="source-toggle" href="#"
|
286
|
+
onclick="toggleCode('M000041-source');return false;">[Source]</a></p>
|
287
|
+
<div class="method-source-code" id="M000041-source">
|
288
|
+
<pre>
|
289
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 110</span>
|
290
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">get_cache</span>(<span class="ruby-identifier">filename</span>)
|
291
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@@cache_table</span>[<span class="ruby-identifier">filename</span>]
|
292
|
+
<span class="ruby-keyword kw">end</span>
|
293
|
+
</pre>
|
294
|
+
</div>
|
295
|
+
</div>
|
296
|
+
</div>
|
297
|
+
|
298
|
+
<div id="method-M000036" class="method-detail">
|
299
|
+
<a name="M000036"></a>
|
300
|
+
|
301
|
+
<div class="method-heading">
|
302
|
+
<a href="#M000036" class="method-signature">
|
303
|
+
<span class="method-name">lang</span><span class="method-args">()</span>
|
304
|
+
</a>
|
305
|
+
</div>
|
306
|
+
|
307
|
+
<div class="method-description">
|
308
|
+
<p><a class="source-toggle" href="#"
|
309
|
+
onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
|
310
|
+
<div class="method-source-code" id="M000036-source">
|
311
|
+
<pre>
|
312
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 77</span>
|
313
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">lang</span>
|
314
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@@lang</span>
|
315
|
+
<span class="ruby-keyword kw">end</span>
|
316
|
+
</pre>
|
317
|
+
</div>
|
318
|
+
</div>
|
319
|
+
</div>
|
320
|
+
|
321
|
+
<div id="method-M000037" class="method-detail">
|
322
|
+
<a name="M000037"></a>
|
323
|
+
|
324
|
+
<div class="method-heading">
|
325
|
+
<a href="#M000037" class="method-signature">
|
326
|
+
<span class="method-name">lang=</span><span class="method-args">(lang)</span>
|
327
|
+
</a>
|
328
|
+
</div>
|
329
|
+
|
330
|
+
<div class="method-description">
|
331
|
+
<p><a class="source-toggle" href="#"
|
332
|
+
onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
|
333
|
+
<div class="method-source-code" id="M000037-source">
|
334
|
+
<pre>
|
335
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 81</span>
|
336
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">lang=</span>(<span class="ruby-identifier">lang</span>)
|
337
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">lang</span>
|
338
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value str">'rails'</span>, <span class="ruby-value str">'ruby'</span>, <span class="ruby-value str">'eruby'</span>, <span class="ruby-value str">'erubis'</span>, <span class="ruby-value str">'pierubis'</span>
|
339
|
+
<span class="ruby-ivar">@@lang</span> = <span class="ruby-identifier">lang</span>
|
340
|
+
<span class="ruby-keyword kw">else</span>
|
341
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-node">"'#{lang}': invalid language name."</span>
|
342
|
+
<span class="ruby-keyword kw">end</span>
|
343
|
+
<span class="ruby-keyword kw">end</span>
|
344
|
+
</pre>
|
345
|
+
</div>
|
346
|
+
</div>
|
347
|
+
</div>
|
348
|
+
|
349
|
+
<div id="method-M000044" class="method-detail">
|
350
|
+
<a name="M000044"></a>
|
351
|
+
|
352
|
+
<div class="method-heading">
|
353
|
+
<a href="#M000044" class="method-signature">
|
354
|
+
<span class="method-name">new</span><span class="method-args">(view)</span>
|
355
|
+
</a>
|
356
|
+
</div>
|
357
|
+
|
358
|
+
<div class="method-description">
|
359
|
+
<p><a class="source-toggle" href="#"
|
360
|
+
onclick="toggleCode('M000044-source');return false;">[Source]</a></p>
|
361
|
+
<div class="method-source-code" id="M000044-source">
|
362
|
+
<pre>
|
363
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 126</span>
|
364
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">view</span>)
|
365
|
+
<span class="ruby-ivar">@view</span> = <span class="ruby-identifier">view</span>
|
366
|
+
<span class="ruby-keyword kw">end</span>
|
367
|
+
</pre>
|
368
|
+
</div>
|
369
|
+
</div>
|
370
|
+
</div>
|
371
|
+
|
372
|
+
<div id="method-M000032" class="method-detail">
|
373
|
+
<a name="M000032"></a>
|
374
|
+
|
375
|
+
<div class="method-heading">
|
376
|
+
<a href="#M000032" class="method-signature">
|
377
|
+
<span class="method-name">pdata_suffix</span><span class="method-args">()</span>
|
378
|
+
</a>
|
379
|
+
</div>
|
380
|
+
|
381
|
+
<div class="method-description">
|
382
|
+
<p><a class="source-toggle" href="#"
|
383
|
+
onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
|
384
|
+
<div class="method-source-code" id="M000032-source">
|
385
|
+
<pre>
|
386
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 55</span>
|
387
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">pdata_suffix</span>
|
388
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@@pdata_suffix</span>
|
389
|
+
<span class="ruby-keyword kw">end</span>
|
390
|
+
</pre>
|
391
|
+
</div>
|
392
|
+
</div>
|
393
|
+
</div>
|
394
|
+
|
395
|
+
<div id="method-M000033" class="method-detail">
|
396
|
+
<a name="M000033"></a>
|
397
|
+
|
398
|
+
<div class="method-heading">
|
399
|
+
<a href="#M000033" class="method-signature">
|
400
|
+
<span class="method-name">pdata_suffix=</span><span class="method-args">(suffix)</span>
|
401
|
+
</a>
|
402
|
+
</div>
|
403
|
+
|
404
|
+
<div class="method-description">
|
405
|
+
<p><a class="source-toggle" href="#"
|
406
|
+
onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
|
407
|
+
<div class="method-source-code" id="M000033-source">
|
408
|
+
<pre>
|
409
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 59</span>
|
410
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">pdata_suffix=</span>(<span class="ruby-identifier">suffix</span>)
|
411
|
+
<span class="ruby-ivar">@@pdata_suffix</span> = <span class="ruby-identifier">suffix</span>
|
412
|
+
<span class="ruby-keyword kw">end</span>
|
413
|
+
</pre>
|
414
|
+
</div>
|
415
|
+
</div>
|
416
|
+
</div>
|
417
|
+
|
418
|
+
<div id="method-M000034" class="method-detail">
|
419
|
+
<a name="M000034"></a>
|
420
|
+
|
421
|
+
<div class="method-heading">
|
422
|
+
<a href="#M000034" class="method-signature">
|
423
|
+
<span class="method-name">plogic_suffix</span><span class="method-args">()</span>
|
424
|
+
</a>
|
425
|
+
</div>
|
426
|
+
|
427
|
+
<div class="method-description">
|
428
|
+
<p><a class="source-toggle" href="#"
|
429
|
+
onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
|
430
|
+
<div class="method-source-code" id="M000034-source">
|
431
|
+
<pre>
|
432
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 66</span>
|
433
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">plogic_suffix</span>
|
434
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@@plogic_suffix</span>
|
435
|
+
<span class="ruby-keyword kw">end</span>
|
436
|
+
</pre>
|
437
|
+
</div>
|
438
|
+
</div>
|
439
|
+
</div>
|
440
|
+
|
441
|
+
<div id="method-M000035" class="method-detail">
|
442
|
+
<a name="M000035"></a>
|
443
|
+
|
444
|
+
<div class="method-heading">
|
445
|
+
<a href="#M000035" class="method-signature">
|
446
|
+
<span class="method-name">plogic_suffix=</span><span class="method-args">(suffix)</span>
|
447
|
+
</a>
|
448
|
+
</div>
|
449
|
+
|
450
|
+
<div class="method-description">
|
451
|
+
<p><a class="source-toggle" href="#"
|
452
|
+
onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
|
453
|
+
<div class="method-source-code" id="M000035-source">
|
454
|
+
<pre>
|
455
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 70</span>
|
456
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">plogic_suffix=</span>(<span class="ruby-identifier">suffix</span>)
|
457
|
+
<span class="ruby-ivar">@@plogic_suffix</span> = <span class="ruby-identifier">suffix</span>
|
458
|
+
<span class="ruby-keyword kw">end</span>
|
459
|
+
</pre>
|
460
|
+
</div>
|
461
|
+
</div>
|
462
|
+
</div>
|
463
|
+
|
464
|
+
<div id="method-M000038" class="method-detail">
|
465
|
+
<a name="M000038"></a>
|
466
|
+
|
467
|
+
<div class="method-heading">
|
468
|
+
<a href="#M000038" class="method-signature">
|
469
|
+
<span class="method-name">use_cache</span><span class="method-args">()</span>
|
470
|
+
</a>
|
471
|
+
</div>
|
472
|
+
|
473
|
+
<div class="method-description">
|
474
|
+
<p><a class="source-toggle" href="#"
|
475
|
+
onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
|
476
|
+
<div class="method-source-code" id="M000038-source">
|
477
|
+
<pre>
|
478
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 93</span>
|
479
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">use_cache</span>
|
480
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@@use_cache</span>
|
481
|
+
<span class="ruby-keyword kw">end</span>
|
482
|
+
</pre>
|
483
|
+
</div>
|
484
|
+
</div>
|
485
|
+
</div>
|
486
|
+
|
487
|
+
<div id="method-M000039" class="method-detail">
|
488
|
+
<a name="M000039"></a>
|
489
|
+
|
490
|
+
<div class="method-heading">
|
491
|
+
<a href="#M000039" class="method-signature">
|
492
|
+
<span class="method-name">use_cache=</span><span class="method-args">(flag)</span>
|
493
|
+
</a>
|
494
|
+
</div>
|
495
|
+
|
496
|
+
<div class="method-description">
|
497
|
+
<p><a class="source-toggle" href="#"
|
498
|
+
onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
|
499
|
+
<div class="method-source-code" id="M000039-source">
|
500
|
+
<pre>
|
501
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 97</span>
|
502
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">use_cache=</span>(<span class="ruby-identifier">flag</span>)
|
503
|
+
<span class="ruby-ivar">@@use_cache</span> = <span class="ruby-identifier">flag</span>
|
504
|
+
<span class="ruby-keyword kw">end</span>
|
505
|
+
</pre>
|
506
|
+
</div>
|
507
|
+
</div>
|
508
|
+
</div>
|
509
|
+
|
510
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
511
|
+
|
512
|
+
<div id="method-M000045" class="method-detail">
|
513
|
+
<a name="M000045"></a>
|
514
|
+
|
515
|
+
<div class="method-heading">
|
516
|
+
<a href="#M000045" class="method-signature">
|
517
|
+
<span class="method-name">render</span><span class="method-args">(template, assigns)</span>
|
518
|
+
</a>
|
519
|
+
</div>
|
520
|
+
|
521
|
+
<div class="method-description">
|
522
|
+
<p><a class="source-toggle" href="#"
|
523
|
+
onclick="toggleCode('M000045-source');return false;">[Source]</a></p>
|
524
|
+
<div class="method-source-code" id="M000045-source">
|
525
|
+
<pre>
|
526
|
+
<span class="ruby-comment cmt"># File kwartz/helper/rails.rb, line 131</span>
|
527
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>(<span class="ruby-identifier">template</span>, <span class="ruby-identifier">assigns</span>)
|
528
|
+
|
529
|
+
<span class="ruby-comment cmt">## reverse engineering</span>
|
530
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: render() called."</span>
|
531
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: RAILS_ENV=#{RAILS_ENV.inspect}"</span>
|
532
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: self.class=#{self.class}"</span>
|
533
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: @view.class=#{@view.class}"</span>
|
534
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: self.__id__=#{self.__id__.inspect}"</span>
|
535
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: @view.class.methods=#{(@view.class.methods - Class.methods).sort.inspect}"</span>
|
536
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: @view.controller.class.methods=#{(@view.controller.class.methods - Class.methods).sort.inspect}"</span>
|
537
|
+
<span class="ruby-comment cmt">#</span>
|
538
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: instance_variables=#{instance_variables.inspect}" #=> [@views]</span>
|
539
|
+
<span class="ruby-comment cmt">#c = @view.controller</span>
|
540
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: @view.controller.instance_variables=#{c.instance_variables.inspect}"</span>
|
541
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: @view.controller.action_name=#{c.action_name.inspect}"</span>
|
542
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: @view.controller.render_layout_basename=#{c.render_layout_basename.inspect}"</span>
|
543
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: @view.controller.render_template_basename=#{c.render_template_basename.inspect}"</span>
|
544
|
+
<span class="ruby-comment cmt">#require 'pp'</span>
|
545
|
+
<span class="ruby-comment cmt">#c = @view.controller</span>
|
546
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: @view.controller.instance_variable_get('@template')="</span>
|
547
|
+
<span class="ruby-comment cmt">#PP.pp(c.instance_variable_get('@template'), $stderr)</span>
|
548
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: @view.controller.methods="</span>
|
549
|
+
<span class="ruby-comment cmt">#PP.pp((c.methods - Object.new.methods).sort, $stderr)</span>
|
550
|
+
<span class="ruby-comment cmt">#$stderr.puts "*** debug: @view.controller.class.methods="</span>
|
551
|
+
<span class="ruby-comment cmt">#PP.pp((c.class.methods - Class.methods).sort, $stderr)</span>
|
552
|
+
|
553
|
+
<span class="ruby-comment cmt">## return if @content_for_layout is set</span>
|
554
|
+
<span class="ruby-identifier">template_</span> = <span class="ruby-ivar">@view</span>.<span class="ruby-identifier">controller</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-value str">"@template"</span>)
|
555
|
+
<span class="ruby-identifier">content_for_layout_</span> = <span class="ruby-identifier">template_</span>.<span class="ruby-identifier">instance_variable_get</span>(<span class="ruby-value str">"@content_for_layout"</span>)
|
556
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">content_for_layout_</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">content_for_layout_</span>
|
557
|
+
|
558
|
+
<span class="ruby-comment cmt">## template basename and layout basename</span>
|
559
|
+
<span class="ruby-identifier">c</span> = <span class="ruby-ivar">@view</span>.<span class="ruby-identifier">controller</span>
|
560
|
+
<span class="ruby-identifier">template_root</span> = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">template_root</span> <span class="ruby-comment cmt"># or c.class.template_root</span>
|
561
|
+
<span class="ruby-comment cmt">#template_basename = "#{template_root}/#{c.controller_name}/#{c.action_name}"</span>
|
562
|
+
<span class="ruby-comment cmt">#layout_basename = "#{template_root}/layouts/#{c.controller_name}"</span>
|
563
|
+
<span class="ruby-identifier">template_basename</span> = <span class="ruby-node">"#{template_root}/#{c.render_template_basename}"</span>
|
564
|
+
<span class="ruby-identifier">layout_basename</span> = <span class="ruby-node">"#{template_root}/#{c.render_layout_basename}"</span>
|
565
|
+
|
566
|
+
<span class="ruby-comment cmt">## check timestamps</span>
|
567
|
+
<span class="ruby-identifier">convert_flag</span> = <span class="ruby-keyword kw">true</span>
|
568
|
+
<span class="ruby-identifier">cache_filename</span> = <span class="ruby-identifier">template_basename</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'.cache'</span>
|
569
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">use_cache?</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">cache_filename</span>)
|
570
|
+
<span class="ruby-identifier">filenames</span> = [
|
571
|
+
<span class="ruby-identifier">template_basename</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@@pdata_suffix</span>,
|
572
|
+
<span class="ruby-identifier">template_basename</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@@plogic_suffix</span>,
|
573
|
+
<span class="ruby-identifier">layout_basename</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@@pdata_suffix</span>,
|
574
|
+
<span class="ruby-identifier">layout_basename</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@@plogic_suffix</span>,
|
575
|
+
]
|
576
|
+
<span class="ruby-identifier">mtime</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">cache_filename</span>)
|
577
|
+
<span class="ruby-identifier">convert_flag</span> = <span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">any?</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span>
|
578
|
+
<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-constant">File</span>.<span class="ruby-identifier">mtime</span>(<span class="ruby-identifier">filename</span>) <span class="ruby-operator">></span> <span class="ruby-identifier">mtime</span>
|
579
|
+
}
|
580
|
+
<span class="ruby-keyword kw">end</span>
|
581
|
+
|
582
|
+
<span class="ruby-comment cmt">## convert templates into ruby code, or get cached object</span>
|
583
|
+
<span class="ruby-identifier">logger</span> = <span class="ruby-ivar">@view</span>.<span class="ruby-identifier">controller</span>.<span class="ruby-identifier">logger</span>
|
584
|
+
<span class="ruby-identifier">msgstr</span> = <span class="ruby-node">"template='#{template_basename}#{@@pdata_suffix}'"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">logger</span>
|
585
|
+
<span class="ruby-identifier">logname</span> = <span class="ruby-node">"*** #{self.class.name}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">logger</span>
|
586
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">convert_flag</span>
|
587
|
+
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">"#{logname}: convert template file: #{msgstr}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">logger</span>
|
588
|
+
<span class="ruby-identifier">ruby_code</span> = <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">template</span>, <span class="ruby-identifier">template_basename</span>, <span class="ruby-identifier">layout_basename</span>)
|
589
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">cache_filename</span>, <span class="ruby-value str">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">ruby_code</span>) } <span class="ruby-comment cmt"># write cache</span>
|
590
|
+
<span class="ruby-identifier">proc_obj</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">add_cache</span>(<span class="ruby-identifier">ruby_code</span>, <span class="ruby-identifier">cache_filename</span>)
|
591
|
+
<span class="ruby-keyword kw">elsif</span> (<span class="ruby-identifier">proc_obj</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">get_cache</span>(<span class="ruby-identifier">cache_filename</span>)).<span class="ruby-identifier">nil?</span>
|
592
|
+
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">"#{logname}: read cache file: #{msgstr}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">logger</span>
|
593
|
+
<span class="ruby-identifier">ruby_code</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">cache_filename</span>)
|
594
|
+
<span class="ruby-identifier">proc_obj</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">add_cache</span>(<span class="ruby-identifier">ruby_code</span>, <span class="ruby-identifier">cache_filename</span>)
|
595
|
+
<span class="ruby-keyword kw">else</span>
|
596
|
+
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">"#{logname}: reuse cached proc object: #{msgstr}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">logger</span>
|
597
|
+
<span class="ruby-keyword kw">end</span>
|
598
|
+
|
599
|
+
<span class="ruby-comment cmt">## use @view as context object</span>
|
600
|
+
<span class="ruby-ivar">@view</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">:evaluate_assigns</span>)
|
601
|
+
<span class="ruby-comment cmt">#or @view.instance_eval("evaluate_assigns()")</span>
|
602
|
+
<span class="ruby-identifier">context</span> = <span class="ruby-ivar">@view</span>
|
603
|
+
|
604
|
+
<span class="ruby-comment cmt">## evaluate ruby code with context object</span>
|
605
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">assigns</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">assigns</span>.<span class="ruby-identifier">empty?</span>
|
606
|
+
<span class="ruby-comment cmt">#return _evaluate_string(ruby_code, context, assigns)</span>
|
607
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">evaluate_proc</span>(<span class="ruby-identifier">proc_obj</span>, <span class="ruby-identifier">context</span>, <span class="ruby-identifier">assigns</span>)
|
608
|
+
<span class="ruby-keyword kw">else</span>
|
609
|
+
<span class="ruby-comment cmt">#return context.instance_eval(ruby_code)</span>
|
610
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">instance_eval</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">proc_obj</span>)
|
611
|
+
<span class="ruby-keyword kw">end</span>
|
612
|
+
<span class="ruby-keyword kw">end</span>
|
613
|
+
</pre>
|
614
|
+
</div>
|
615
|
+
</div>
|
616
|
+
</div>
|
617
|
+
|
618
|
+
|
619
|
+
</div>
|
620
|
+
|
621
|
+
|
622
|
+
</div>
|
623
|
+
|
624
|
+
|
625
|
+
<div id="validator-badges">
|
626
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
627
|
+
</div>
|
628
|
+
|
629
|
+
</body>
|
630
|
+
</html>
|