Capcode 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -0
- data/doc/rdoc/classes/Capcode.html +468 -440
- data/doc/rdoc/classes/Capcode/Configuration.html +29 -28
- data/doc/rdoc/classes/Capcode/Helpers.html +139 -139
- data/doc/rdoc/classes/Capcode/StaticFiles.html +199 -0
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README_rdoc.html +12 -1
- data/doc/rdoc/files/lib/capcode/configuration_rb.html +1 -1
- data/doc/rdoc/files/lib/capcode_rb.html +3 -2
- data/doc/rdoc/fr_class_index.html +1 -0
- data/doc/rdoc/fr_method_index.html +6 -4
- data/examples/static.rb +26 -0
- data/examples/static/bye.html +6 -0
- data/examples/static/static-index.html +6 -0
- data/lib/capcode.rb +103 -48
- data/lib/capcode.rbSAVE +881 -0
- data/lib/capcode/configuration.rb +1 -1
- data/lib/capcode/core_ext.rb +8 -0
- data/lib/capcode/version.rb +1 -1
- metadata +11 -7
- data/examples/rest.log +0 -70
@@ -86,10 +86,10 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
90
|
-
<a href="#
|
91
|
-
<a href="#
|
92
|
-
<a href="#
|
89
|
+
<a href="#M000029">get</a>
|
90
|
+
<a href="#M000030">options</a>
|
91
|
+
<a href="#M000027">print_debug</a>
|
92
|
+
<a href="#M000028">set</a>
|
93
93
|
</div>
|
94
94
|
</div>
|
95
95
|
|
@@ -111,19 +111,19 @@
|
|
111
111
|
<div id="methods">
|
112
112
|
<h3 class="section-bar">Public Class methods</h3>
|
113
113
|
|
114
|
-
<div id="method-
|
115
|
-
<a name="
|
114
|
+
<div id="method-M000029" class="method-detail">
|
115
|
+
<a name="M000029"></a>
|
116
116
|
|
117
117
|
<div class="method-heading">
|
118
|
-
<a href="#
|
118
|
+
<a href="#M000029" class="method-signature">
|
119
119
|
<span class="method-name">get</span><span class="method-args">( key = nil )</span>
|
120
120
|
</a>
|
121
121
|
</div>
|
122
122
|
|
123
123
|
<div class="method-description">
|
124
124
|
<p><a class="source-toggle" href="#"
|
125
|
-
onclick="toggleCode('
|
126
|
-
<div class="method-source-code" id="
|
125
|
+
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
126
|
+
<div class="method-source-code" id="M000029-source">
|
127
127
|
<pre>
|
128
128
|
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 67</span>
|
129
129
|
67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>( <span class="ruby-identifier">key</span> = <span class="ruby-keyword kw">nil</span> )
|
@@ -138,19 +138,19 @@
|
|
138
138
|
</div>
|
139
139
|
</div>
|
140
140
|
|
141
|
-
<div id="method-
|
142
|
-
<a name="
|
141
|
+
<div id="method-M000030" class="method-detail">
|
142
|
+
<a name="M000030"></a>
|
143
143
|
|
144
144
|
<div class="method-heading">
|
145
|
-
<a href="#
|
145
|
+
<a href="#M000030" class="method-signature">
|
146
146
|
<span class="method-name">options</span><span class="method-args">()</span>
|
147
147
|
</a>
|
148
148
|
</div>
|
149
149
|
|
150
150
|
<div class="method-description">
|
151
151
|
<p><a class="source-toggle" href="#"
|
152
|
-
onclick="toggleCode('
|
153
|
-
<div class="method-source-code" id="
|
152
|
+
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
153
|
+
<div class="method-source-code" id="M000030-source">
|
154
154
|
<pre>
|
155
155
|
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 75</span>
|
156
156
|
75: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options</span>
|
@@ -161,19 +161,19 @@
|
|
161
161
|
</div>
|
162
162
|
</div>
|
163
163
|
|
164
|
-
<div id="method-
|
165
|
-
<a name="
|
164
|
+
<div id="method-M000027" class="method-detail">
|
165
|
+
<a name="M000027"></a>
|
166
166
|
|
167
167
|
<div class="method-heading">
|
168
|
-
<a href="#
|
168
|
+
<a href="#M000027" class="method-signature">
|
169
169
|
<span class="method-name">print_debug</span><span class="method-args">()</span>
|
170
170
|
</a>
|
171
171
|
</div>
|
172
172
|
|
173
173
|
<div class="method-description">
|
174
174
|
<p><a class="source-toggle" href="#"
|
175
|
-
onclick="toggleCode('
|
176
|
-
<div class="method-source-code" id="
|
175
|
+
onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
|
176
|
+
<div class="method-source-code" id="M000027-source">
|
177
177
|
<pre>
|
178
178
|
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 28</span>
|
179
179
|
28: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_debug</span>
|
@@ -186,18 +186,18 @@
|
|
186
186
|
</div>
|
187
187
|
</div>
|
188
188
|
|
189
|
-
<div id="method-
|
190
|
-
<a name="
|
189
|
+
<div id="method-M000028" class="method-detail">
|
190
|
+
<a name="M000028"></a>
|
191
191
|
|
192
192
|
<div class="method-heading">
|
193
|
-
<a href="#
|
193
|
+
<a href="#M000028" class="method-signature">
|
194
194
|
<span class="method-name">set</span><span class="method-args">( key, value, opts = {} )</span>
|
195
195
|
</a>
|
196
196
|
</div>
|
197
197
|
|
198
198
|
<div class="method-description">
|
199
199
|
<p>
|
200
|
-
Set global configuration <a href="Configuration.html#
|
200
|
+
Set global configuration <a href="Configuration.html#M000030">options</a>
|
201
201
|
</p>
|
202
202
|
<p>
|
203
203
|
Options :
|
@@ -209,7 +209,8 @@ Options :
|
|
209
209
|
<li><tt>:host</tt> = Listen host (default: 0.0.0.0)
|
210
210
|
|
211
211
|
</li>
|
212
|
-
<li><tt>:server</tt> = Server type (webrick, mongrel, thin, unicorn or
|
212
|
+
<li><tt>:server</tt> = Server type (webrick, mongrel, thin, unicorn, rainbow or
|
213
|
+
control_tower)
|
213
214
|
|
214
215
|
</li>
|
215
216
|
<li><tt>:log</tt> = Output logfile (default: STDOUT)
|
@@ -239,12 +240,12 @@ This is also the working directory !
|
|
239
240
|
|
240
241
|
</li>
|
241
242
|
<li><tt>:auth</tt> = HTTP Basic Authentication <a
|
242
|
-
href="Configuration.html#
|
243
|
+
href="Configuration.html#M000030">options</a>
|
243
244
|
|
244
245
|
</li>
|
245
246
|
</ul>
|
246
247
|
<p>
|
247
|
-
It can exist specifics <a href="Configuration.html#
|
248
|
+
It can exist specifics <a href="Configuration.html#M000030">options</a>
|
248
249
|
depending on a renderer, a helper, …
|
249
250
|
</p>
|
250
251
|
<p>
|
@@ -257,8 +258,8 @@ Example :
|
|
257
258
|
end
|
258
259
|
</pre>
|
259
260
|
<p><a class="source-toggle" href="#"
|
260
|
-
onclick="toggleCode('
|
261
|
-
<div class="method-source-code" id="
|
261
|
+
onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
|
262
|
+
<div class="method-source-code" id="M000028-source">
|
262
263
|
<pre>
|
263
264
|
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 58</span>
|
264
265
|
58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set</span>( <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">opts</span> = {} )
|
@@ -152,10 +152,10 @@ controllers
|
|
152
152
|
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
153
153
|
<div class="method-source-code" id="M000015-source">
|
154
154
|
<pre>
|
155
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
156
|
-
|
157
|
-
|
158
|
-
|
155
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 36</span>
|
156
|
+
36: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">args</span>
|
157
|
+
37: <span class="ruby-ivar">@args</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword kw">nil</span>
|
158
|
+
38: <span class="ruby-keyword kw">end</span>
|
159
159
|
</pre>
|
160
160
|
</div>
|
161
161
|
</div>
|
@@ -175,10 +175,10 @@ controllers
|
|
175
175
|
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
176
176
|
<div class="method-source-code" id="M000016-source">
|
177
177
|
<pre>
|
178
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
179
|
-
|
180
|
-
|
181
|
-
|
178
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 39</span>
|
179
|
+
39: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">args=</span>(<span class="ruby-identifier">x</span>)
|
180
|
+
40: <span class="ruby-ivar">@args</span> = <span class="ruby-identifier">x</span>
|
181
|
+
41: <span class="ruby-keyword kw">end</span>
|
182
182
|
</pre>
|
183
183
|
</div>
|
184
184
|
</div>
|
@@ -220,41 +220,41 @@ then
|
|
220
220
|
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
221
221
|
<div class="method-source-code" id="M000020-source">
|
222
222
|
<pre>
|
223
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
223
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 203</span>
|
224
|
+
203: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">URL</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
|
225
|
+
204: <span class="ruby-identifier">path</span> = <span class="ruby-keyword kw">nil</span>
|
226
|
+
205: <span class="ruby-identifier">result</span> = {}
|
227
|
+
206:
|
228
|
+
207: <span class="ruby-identifier">a</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">delete_if</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> }
|
229
|
+
208:
|
230
|
+
209: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span>
|
231
|
+
210: <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cpath</span>, <span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
|
232
|
+
211: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">clone</span>
|
233
|
+
212:
|
234
|
+
213: <span class="ruby-identifier">n</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:regexp</span>] ).<span class="ruby-identifier">number_of_captures</span>
|
235
|
+
214: <span class="ruby-identifier">equart</span> = (<span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">n</span>).<span class="ruby-identifier">abs</span>
|
236
|
+
215:
|
237
|
+
216: <span class="ruby-identifier">rtable</span> = <span class="ruby-identifier">data</span>[<span class="ruby-identifier">:regexp</span>].<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/\\\(/</span>, <span class="ruby-value str">""</span> ).<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/\\\)/</span>, <span class="ruby-value str">""</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-regexp re">/\([^\)]*\)/</span> )
|
238
|
+
217: <span class="ruby-identifier">rtable</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
239
|
+
218: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span> <span class="ruby-operator">==</span> <span class="ruby-value str">""</span>
|
240
|
+
219: <span class="ruby-identifier">cpath</span> = <span class="ruby-identifier">cpath</span> <span class="ruby-operator">+</span> <span class="ruby-node">"/#{args.shift}"</span>
|
241
|
+
220: <span class="ruby-keyword kw">else</span>
|
242
|
+
221: <span class="ruby-identifier">cpath</span> = <span class="ruby-identifier">cpath</span> <span class="ruby-operator">+</span> <span class="ruby-node">"/#{r}"</span>
|
243
|
+
222: <span class="ruby-keyword kw">end</span>
|
244
|
+
223: <span class="ruby-keyword kw">end</span>
|
245
|
+
224:
|
246
|
+
225: <span class="ruby-identifier">cpath</span> = (<span class="ruby-identifier">cpath</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"/"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">join</span>( <span class="ruby-value str">"/"</span> )) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
247
|
+
226: <span class="ruby-identifier">cpath</span> = <span class="ruby-identifier">cpath</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/(\/){2,}/</span>, <span class="ruby-value str">"/"</span> )
|
248
|
+
227: <span class="ruby-identifier">result</span>[<span class="ruby-identifier">equart</span>] = <span class="ruby-identifier">cpath</span>
|
249
|
+
228: <span class="ruby-keyword kw">end</span>
|
250
|
+
229:
|
251
|
+
230: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">result</span>[<span class="ruby-identifier">result</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">min</span>]
|
252
|
+
231: <span class="ruby-keyword kw">else</span>
|
253
|
+
232: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">klass</span>
|
254
|
+
233: <span class="ruby-keyword kw">end</span>
|
255
|
+
234:
|
256
|
+
235: (<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'RACK_BASE_URI'</span>]<span class="ruby-operator">||</span><span class="ruby-value str">''</span>)<span class="ruby-operator">+</span><span class="ruby-identifier">path</span>
|
257
|
+
236: <span class="ruby-keyword kw">end</span>
|
258
258
|
</pre>
|
259
259
|
</div>
|
260
260
|
</div>
|
@@ -310,12 +310,12 @@ markup in an identifier.
|
|
310
310
|
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
311
311
|
<div class="method-source-code" id="M000021-source">
|
312
312
|
<pre>
|
313
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
313
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 270</span>
|
314
|
+
270: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_for</span>( <span class="ruby-identifier">x</span> )
|
315
|
+
271: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">_</span>.<span class="ruby-identifier">to_s</span> }.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">x</span>.<span class="ruby-identifier">to_s</span>)
|
316
|
+
272: <span class="ruby-keyword kw">yield</span>
|
317
|
+
273: <span class="ruby-keyword kw">end</span>
|
318
|
+
274: <span class="ruby-keyword kw">end</span>
|
319
319
|
</pre>
|
320
320
|
</div>
|
321
321
|
</div>
|
@@ -352,11 +352,11 @@ href="Helpers.html#M000018">json</a> => o )</tt>
|
|
352
352
|
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
353
353
|
<div class="method-source-code" id="M000018-source">
|
354
354
|
<pre>
|
355
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
355
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 147</span>
|
356
|
+
147: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">json</span>( <span class="ruby-identifier">d</span> ) <span class="ruby-comment cmt">## DELETE THIS IN 1.0.0</span>
|
357
|
+
148: <span class="ruby-identifier">warn</span>( <span class="ruby-value str">"json is deprecated and will be removed in version 1.0, please use `render( :json => ... )'"</span> )
|
358
|
+
149: <span class="ruby-identifier">render</span> <span class="ruby-identifier">:json</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">d</span>
|
359
|
+
150: <span class="ruby-keyword kw">end</span>
|
360
360
|
</pre>
|
361
361
|
</div>
|
362
362
|
</div>
|
@@ -382,10 +382,10 @@ Use the Rack logger
|
|
382
382
|
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
383
383
|
<div class="method-source-code" id="M000023-source">
|
384
384
|
<pre>
|
385
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
386
|
-
|
387
|
-
|
388
|
-
|
385
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 290</span>
|
386
|
+
290: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">log</span>
|
387
|
+
291: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">logger</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">'rack.errors'</span>]
|
388
|
+
292: <span class="ruby-keyword kw">end</span>
|
389
389
|
</pre>
|
390
390
|
</div>
|
391
391
|
</div>
|
@@ -444,17 +444,17 @@ href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection">en
|
|
444
444
|
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
445
445
|
<div class="method-source-code" id="M000019-source">
|
446
446
|
<pre>
|
447
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
447
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 179</span>
|
448
|
+
179: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">redirect</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
|
449
|
+
180: <span class="ruby-identifier">httpCode</span> = <span class="ruby-value">302</span>
|
450
|
+
181:
|
451
|
+
182: <span class="ruby-keyword kw">if</span>( <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Fixnum</span> )
|
452
|
+
183: <span class="ruby-identifier">httpCode</span> = <span class="ruby-identifier">klass</span>
|
453
|
+
184: <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">shift</span>
|
454
|
+
185: <span class="ruby-keyword kw">end</span>
|
455
|
+
186:
|
456
|
+
187: [<span class="ruby-identifier">httpCode</span>, {<span class="ruby-value str">'Location'</span> =<span class="ruby-operator">></span> <span class="ruby-constant">URL</span>(<span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span>)}, <span class="ruby-value str">''</span>]
|
457
|
+
188: <span class="ruby-keyword kw">end</span>
|
458
458
|
</pre>
|
459
459
|
</div>
|
460
460
|
</div>
|
@@ -551,69 +551,69 @@ If you use the WebDav renderer, you can use the option
|
|
551
551
|
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
552
552
|
<div class="method-source-code" id="M000017-source">
|
553
553
|
<pre>
|
554
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
554
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 73</span>
|
555
|
+
73: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>( <span class="ruby-identifier">hash</span> )
|
556
|
+
74: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Hash</span>
|
557
|
+
75: <span class="ruby-identifier">render_type</span> = <span class="ruby-keyword kw">nil</span>
|
558
|
+
76: <span class="ruby-identifier">possible_code_renderer</span> = <span class="ruby-keyword kw">nil</span>
|
559
|
+
77:
|
560
|
+
78: <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
561
|
+
79: <span class="ruby-keyword kw">begin</span>
|
562
|
+
80: <span class="ruby-identifier">gem</span> <span class="ruby-node">"capcode-render-#{key.to_s}"</span>
|
563
|
+
81: <span class="ruby-identifier">require</span> <span class="ruby-node">"capcode/render/#{key.to_s}"</span>
|
564
|
+
82: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">LoadError</span>
|
565
|
+
83: <span class="ruby-keyword kw">nil</span>
|
566
|
+
84: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
|
567
|
+
85: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">"Hum... The #{key} renderer is malformated! Please try to install a new version or use an other renderer!"</span>, <span class="ruby-identifier">caller</span>
|
568
|
+
86: <span class="ruby-keyword kw">end</span>
|
569
|
+
87:
|
570
|
+
88: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">"render_#{key.to_s}"</span>)
|
571
|
+
89: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span>
|
572
|
+
90: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">"Can't use multiple renderer (`#{render_type}' and `#{key}') !"</span>, <span class="ruby-identifier">caller</span>
|
573
|
+
91: <span class="ruby-keyword kw">end</span>
|
574
|
+
92: <span class="ruby-identifier">render_type</span> = <span class="ruby-identifier">key</span>
|
575
|
+
93: <span class="ruby-keyword kw">end</span>
|
576
|
+
94:
|
577
|
+
95: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Fixnum</span>
|
578
|
+
96: <span class="ruby-identifier">possible_code_renderer</span> = <span class="ruby-identifier">key</span>
|
579
|
+
97: <span class="ruby-keyword kw">end</span>
|
580
|
+
98: <span class="ruby-keyword kw">end</span>
|
581
|
+
99:
|
582
|
+
100: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">possible_code_renderer</span>.<span class="ruby-identifier">nil?</span>
|
583
|
+
101: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-value str">"Renderer type not specified!"</span>, <span class="ruby-identifier">caller</span>
|
584
|
+
102: <span class="ruby-keyword kw">end</span>
|
585
|
+
103:
|
586
|
+
104: <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">"render_#{render_type.to_s}"</span>)
|
587
|
+
105: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">possible_code_renderer</span>.<span class="ruby-identifier">nil?</span>
|
588
|
+
106: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">"#{render_type} renderer not present ! please require 'capcode/render/#{render_type}'"</span>, <span class="ruby-identifier">caller</span>
|
589
|
+
107: <span class="ruby-keyword kw">else</span>
|
590
|
+
108: <span class="ruby-identifier">code</span> = <span class="ruby-identifier">possible_code_renderer</span>
|
591
|
+
109: <span class="ruby-identifier">body</span> = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">possible_code_renderer</span>)
|
592
|
+
110: <span class="ruby-identifier">header</span> = {}
|
593
|
+
111: <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
594
|
+
112: <span class="ruby-identifier">k</span> = <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/_/</span>).<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">capitalize</span>}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"-"</span>)
|
595
|
+
113: <span class="ruby-identifier">header</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
|
596
|
+
114: <span class="ruby-keyword kw">end</span>
|
597
|
+
115:
|
598
|
+
116: [<span class="ruby-identifier">code</span>, <span class="ruby-identifier">header</span>, <span class="ruby-identifier">body</span>]
|
599
|
+
117: <span class="ruby-keyword kw">end</span>
|
600
|
+
118: <span class="ruby-keyword kw">else</span>
|
601
|
+
119: <span class="ruby-identifier">render_name</span> = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">render_type</span>)
|
602
|
+
120: <span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:content_type</span>)
|
603
|
+
121: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">content_type</span>.<span class="ruby-identifier">nil?</span>
|
604
|
+
122: <span class="ruby-ivar">@response</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">content_type</span>
|
605
|
+
123: <span class="ruby-keyword kw">end</span>
|
606
|
+
124:
|
607
|
+
125: <span class="ruby-keyword kw">begin</span>
|
608
|
+
126: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>( <span class="ruby-node">"render_#{render_type.to_s}"</span>, <span class="ruby-identifier">render_name</span>, <span class="ruby-identifier">hash</span> )
|
609
|
+
127: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
610
|
+
128: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">"Error rendering `#{render_type.to_s}' : #{e.message}"</span><span class="ruby-comment cmt">#, caller</span>
|
611
|
+
129: <span class="ruby-keyword kw">end</span>
|
612
|
+
130: <span class="ruby-keyword kw">end</span>
|
613
|
+
131: <span class="ruby-keyword kw">else</span>
|
614
|
+
132: <span class="ruby-identifier">render</span>( <span class="ruby-identifier">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">hash</span> )
|
615
|
+
133: <span class="ruby-keyword kw">end</span>
|
616
|
+
134: <span class="ruby-keyword kw">end</span>
|
617
617
|
</pre>
|
618
618
|
</div>
|
619
619
|
</div>
|
@@ -647,13 +647,13 @@ the <a href="Helpers.html#M000022">static</a> directory on the server
|
|
647
647
|
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
648
648
|
<div class="method-source-code" id="M000022-source">
|
649
649
|
<pre>
|
650
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
650
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 280</span>
|
651
|
+
280: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">static</span>
|
652
|
+
281: {
|
653
|
+
282: <span class="ruby-identifier">:uri</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>,
|
654
|
+
283: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">></span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:root</span>), <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>) ) )
|
655
|
+
284: }
|
656
|
+
285: <span class="ruby-keyword kw">end</span>
|
657
657
|
</pre>
|
658
658
|
</div>
|
659
659
|
</div>
|