Capcode 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -2
- data/doc/rdoc/classes/Capcode.html +454 -402
- data/doc/rdoc/classes/Capcode/Configuration.html +21 -21
- data/doc/rdoc/classes/Capcode/Helpers.html +185 -164
- data/doc/rdoc/classes/Capcode/Helpers/Authorization.html +6 -6
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README_rdoc.html +21 -7
- data/doc/rdoc/files/lib/capcode/filters_rb.html +101 -0
- data/doc/rdoc/files/lib/capcode_rb.html +2 -2
- data/doc/rdoc/fr_file_index.html +1 -0
- data/doc/rdoc/fr_method_index.html +13 -12
- data/examples/filter.rb +105 -0
- data/lib/capcode.rb +51 -27
- data/lib/capcode/filters.rb +50 -0
- data/lib/capcode/version.rb +1 -1
- metadata +5 -4
@@ -86,9 +86,9 @@
|
|
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="#
|
89
|
+
<a href="#M000024">get</a>
|
90
|
+
<a href="#M000025">options</a>
|
91
|
+
<a href="#M000023">set</a>
|
92
92
|
</div>
|
93
93
|
</div>
|
94
94
|
|
@@ -110,19 +110,19 @@
|
|
110
110
|
<div id="methods">
|
111
111
|
<h3 class="section-bar">Public Class methods</h3>
|
112
112
|
|
113
|
-
<div id="method-
|
114
|
-
<a name="
|
113
|
+
<div id="method-M000024" class="method-detail">
|
114
|
+
<a name="M000024"></a>
|
115
115
|
|
116
116
|
<div class="method-heading">
|
117
|
-
<a href="#
|
117
|
+
<a href="#M000024" class="method-signature">
|
118
118
|
<span class="method-name">get</span><span class="method-args">( key = nil )</span>
|
119
119
|
</a>
|
120
120
|
</div>
|
121
121
|
|
122
122
|
<div class="method-description">
|
123
123
|
<p><a class="source-toggle" href="#"
|
124
|
-
onclick="toggleCode('
|
125
|
-
<div class="method-source-code" id="
|
124
|
+
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
125
|
+
<div class="method-source-code" id="M000024-source">
|
126
126
|
<pre>
|
127
127
|
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 61</span>
|
128
128
|
61: <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> )
|
@@ -137,19 +137,19 @@
|
|
137
137
|
</div>
|
138
138
|
</div>
|
139
139
|
|
140
|
-
<div id="method-
|
141
|
-
<a name="
|
140
|
+
<div id="method-M000025" class="method-detail">
|
141
|
+
<a name="M000025"></a>
|
142
142
|
|
143
143
|
<div class="method-heading">
|
144
|
-
<a href="#
|
144
|
+
<a href="#M000025" class="method-signature">
|
145
145
|
<span class="method-name">options</span><span class="method-args">()</span>
|
146
146
|
</a>
|
147
147
|
</div>
|
148
148
|
|
149
149
|
<div class="method-description">
|
150
150
|
<p><a class="source-toggle" href="#"
|
151
|
-
onclick="toggleCode('
|
152
|
-
<div class="method-source-code" id="
|
151
|
+
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
152
|
+
<div class="method-source-code" id="M000025-source">
|
153
153
|
<pre>
|
154
154
|
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 69</span>
|
155
155
|
69: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options</span>
|
@@ -160,18 +160,18 @@
|
|
160
160
|
</div>
|
161
161
|
</div>
|
162
162
|
|
163
|
-
<div id="method-
|
164
|
-
<a name="
|
163
|
+
<div id="method-M000023" class="method-detail">
|
164
|
+
<a name="M000023"></a>
|
165
165
|
|
166
166
|
<div class="method-heading">
|
167
|
-
<a href="#
|
167
|
+
<a href="#M000023" class="method-signature">
|
168
168
|
<span class="method-name">set</span><span class="method-args">( key, value, opts = {} )</span>
|
169
169
|
</a>
|
170
170
|
</div>
|
171
171
|
|
172
172
|
<div class="method-description">
|
173
173
|
<p>
|
174
|
-
Set global configuration <a href="Configuration.html#
|
174
|
+
Set global configuration <a href="Configuration.html#M000025">options</a>
|
175
175
|
</p>
|
176
176
|
<p>
|
177
177
|
Options :
|
@@ -213,12 +213,12 @@ This is also the working directory !
|
|
213
213
|
|
214
214
|
</li>
|
215
215
|
<li><tt>:auth</tt> = HTTP Basic Authentication <a
|
216
|
-
href="Configuration.html#
|
216
|
+
href="Configuration.html#M000025">options</a>
|
217
217
|
|
218
218
|
</li>
|
219
219
|
</ul>
|
220
220
|
<p>
|
221
|
-
It can exist specifics <a href="Configuration.html#
|
221
|
+
It can exist specifics <a href="Configuration.html#M000025">options</a>
|
222
222
|
depending on a renderer, a helper, …
|
223
223
|
</p>
|
224
224
|
<p>
|
@@ -231,8 +231,8 @@ Example :
|
|
231
231
|
end
|
232
232
|
</pre>
|
233
233
|
<p><a class="source-toggle" href="#"
|
234
|
-
onclick="toggleCode('
|
235
|
-
<div class="method-source-code" id="
|
234
|
+
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
235
|
+
<div class="method-source-code" id="M000023-source">
|
236
236
|
<pre>
|
237
237
|
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 52</span>
|
238
238
|
52: <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> = {} )
|
@@ -95,14 +95,14 @@ controllers
|
|
95
95
|
<h3 class="section-bar">Methods</h3>
|
96
96
|
|
97
97
|
<div class="name-list">
|
98
|
-
<a href="#
|
99
|
-
<a href="#
|
100
|
-
<a href="#
|
101
|
-
<a href="#
|
102
|
-
<a href="#
|
103
|
-
<a href="#
|
104
|
-
<a href="#
|
105
|
-
<a href="#
|
98
|
+
<a href="#M000019">URL</a>
|
99
|
+
<a href="#M000014">args</a>
|
100
|
+
<a href="#M000015">args=</a>
|
101
|
+
<a href="#M000020">content_for</a>
|
102
|
+
<a href="#M000017">json</a>
|
103
|
+
<a href="#M000018">redirect</a>
|
104
|
+
<a href="#M000016">render</a>
|
105
|
+
<a href="#M000021">static</a>
|
106
106
|
</div>
|
107
107
|
</div>
|
108
108
|
|
@@ -137,11 +137,11 @@ controllers
|
|
137
137
|
<div id="methods">
|
138
138
|
<h3 class="section-bar">Public Class methods</h3>
|
139
139
|
|
140
|
-
<div id="method-
|
141
|
-
<a name="
|
140
|
+
<div id="method-M000014" class="method-detail">
|
141
|
+
<a name="M000014"></a>
|
142
142
|
|
143
143
|
<div class="method-heading">
|
144
|
-
<a href="#
|
144
|
+
<a href="#M000014" class="method-signature">
|
145
145
|
<span class="method-name">args</span><span class="method-args">()</span>
|
146
146
|
</a>
|
147
147
|
</div>
|
@@ -151,36 +151,36 @@ controllers
|
|
151
151
|
@@<em>ARGS</em> = nil
|
152
152
|
</p>
|
153
153
|
<p><a class="source-toggle" href="#"
|
154
|
-
onclick="toggleCode('
|
155
|
-
<div class="method-source-code" id="
|
154
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
155
|
+
<div class="method-source-code" id="M000014-source">
|
156
156
|
<pre>
|
157
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
158
|
-
|
159
|
-
|
160
|
-
|
157
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 46</span>
|
158
|
+
46: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">args</span>
|
159
|
+
47: <span class="ruby-ivar">@args</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword kw">nil</span>
|
160
|
+
48: <span class="ruby-keyword kw">end</span>
|
161
161
|
</pre>
|
162
162
|
</div>
|
163
163
|
</div>
|
164
164
|
</div>
|
165
165
|
|
166
|
-
<div id="method-
|
167
|
-
<a name="
|
166
|
+
<div id="method-M000015" class="method-detail">
|
167
|
+
<a name="M000015"></a>
|
168
168
|
|
169
169
|
<div class="method-heading">
|
170
|
-
<a href="#
|
170
|
+
<a href="#M000015" class="method-signature">
|
171
171
|
<span class="method-name">args=</span><span class="method-args">(x)</span>
|
172
172
|
</a>
|
173
173
|
</div>
|
174
174
|
|
175
175
|
<div class="method-description">
|
176
176
|
<p><a class="source-toggle" href="#"
|
177
|
-
onclick="toggleCode('
|
178
|
-
<div class="method-source-code" id="
|
177
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
178
|
+
<div class="method-source-code" id="M000015-source">
|
179
179
|
<pre>
|
180
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
181
|
-
|
182
|
-
|
183
|
-
|
180
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 49</span>
|
181
|
+
49: <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>)
|
182
|
+
50: <span class="ruby-ivar">@args</span> = <span class="ruby-identifier">x</span>
|
183
|
+
51: <span class="ruby-keyword kw">end</span>
|
184
184
|
</pre>
|
185
185
|
</div>
|
186
186
|
</div>
|
@@ -188,18 +188,18 @@ controllers
|
|
188
188
|
|
189
189
|
<h3 class="section-bar">Public Instance methods</h3>
|
190
190
|
|
191
|
-
<div id="method-
|
192
|
-
<a name="
|
191
|
+
<div id="method-M000019" class="method-detail">
|
192
|
+
<a name="M000019"></a>
|
193
193
|
|
194
194
|
<div class="method-heading">
|
195
|
-
<a href="#
|
195
|
+
<a href="#M000019" class="method-signature">
|
196
196
|
<span class="method-name">URL</span><span class="method-args">( klass, *a )</span>
|
197
197
|
</a>
|
198
198
|
</div>
|
199
199
|
|
200
200
|
<div class="method-description">
|
201
201
|
<p>
|
202
|
-
Builds an <a href="Helpers.html#
|
202
|
+
Builds an <a href="Helpers.html#M000019">URL</a> route to a controller or a
|
203
203
|
path
|
204
204
|
</p>
|
205
205
|
<p>
|
@@ -219,41 +219,41 @@ then
|
|
219
219
|
URL( Capcode::Hello, "you" ) # => /hello/you
|
220
220
|
</pre>
|
221
221
|
<p><a class="source-toggle" href="#"
|
222
|
-
onclick="toggleCode('
|
223
|
-
<div class="method-source-code" id="
|
222
|
+
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
223
|
+
<div class="method-source-code" id="M000019-source">
|
224
224
|
<pre>
|
225
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
225
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 213</span>
|
226
|
+
213: <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> )
|
227
|
+
214: <span class="ruby-identifier">path</span> = <span class="ruby-keyword kw">nil</span>
|
228
|
+
215: <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
|
+
216:
|
230
|
+
217: <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
|
+
218: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
232
|
+
219: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">p</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">klass</span>
|
233
|
+
220: <span class="ruby-keyword kw">end</span>
|
234
|
+
221: <span class="ruby-keyword kw">else</span>
|
235
|
+
222: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">klass</span>
|
236
|
+
223: <span class="ruby-keyword kw">end</span>
|
237
|
+
224:
|
238
|
+
225: (<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><span class="ruby-operator">+</span>((<span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">></span><span class="ruby-value">0</span>)<span class="ruby-operator">?</span>(<span class="ruby-value str">"/"</span><span class="ruby-operator">+</span><span class="ruby-identifier">a</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"/"</span>))<span class="ruby-operator">:</span>(<span class="ruby-value str">""</span>))
|
239
|
+
226: <span class="ruby-keyword kw">end</span>
|
240
240
|
</pre>
|
241
241
|
</div>
|
242
242
|
</div>
|
243
243
|
</div>
|
244
244
|
|
245
|
-
<div id="method-
|
246
|
-
<a name="
|
245
|
+
<div id="method-M000020" class="method-detail">
|
246
|
+
<a name="M000020"></a>
|
247
247
|
|
248
248
|
<div class="method-heading">
|
249
|
-
<a href="#
|
249
|
+
<a href="#M000020" class="method-signature">
|
250
250
|
<span class="method-name">content_for</span><span class="method-args">( x ) {|| ...}</span>
|
251
251
|
</a>
|
252
252
|
</div>
|
253
253
|
|
254
254
|
<div class="method-description">
|
255
255
|
<p>
|
256
|
-
Calling <a href="Helpers.html#
|
256
|
+
Calling <a href="Helpers.html#M000020">content_for</a> stores a block of
|
257
257
|
markup in an identifier.
|
258
258
|
</p>
|
259
259
|
<pre>
|
@@ -289,26 +289,26 @@ markup in an identifier.
|
|
289
289
|
end
|
290
290
|
</pre>
|
291
291
|
<p><a class="source-toggle" href="#"
|
292
|
-
onclick="toggleCode('
|
293
|
-
<div class="method-source-code" id="
|
292
|
+
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
293
|
+
<div class="method-source-code" id="M000020-source">
|
294
294
|
<pre>
|
295
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
295
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 260</span>
|
296
|
+
260: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_for</span>( <span class="ruby-identifier">x</span> )
|
297
|
+
261: <span class="ruby-comment cmt">#if @@__ARGS__.map{|_| _.to_s }.include?(x.to_s)</span>
|
298
|
+
262: <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>)
|
299
|
+
263: <span class="ruby-keyword kw">yield</span>
|
300
|
+
264: <span class="ruby-keyword kw">end</span>
|
301
|
+
265: <span class="ruby-keyword kw">end</span>
|
302
302
|
</pre>
|
303
303
|
</div>
|
304
304
|
</div>
|
305
305
|
</div>
|
306
306
|
|
307
|
-
<div id="method-
|
308
|
-
<a name="
|
307
|
+
<div id="method-M000017" class="method-detail">
|
308
|
+
<a name="M000017"></a>
|
309
309
|
|
310
310
|
<div class="method-heading">
|
311
|
-
<a href="#
|
311
|
+
<a href="#M000017" class="method-signature">
|
312
312
|
<span class="method-name">json</span><span class="method-args">( d )</span>
|
313
313
|
</a>
|
314
314
|
</div>
|
@@ -328,36 +328,35 @@ Help you to return a JSON response
|
|
328
328
|
</pre>
|
329
329
|
<p>
|
330
330
|
<b>DEPRECATED</b>, please use <tt><a
|
331
|
-
href="Helpers.html#
|
332
|
-
href="Helpers.html#
|
331
|
+
href="Helpers.html#M000016">render</a>( :<a
|
332
|
+
href="Helpers.html#M000017">json</a> => o )</tt>
|
333
333
|
</p>
|
334
334
|
<p><a class="source-toggle" href="#"
|
335
|
-
onclick="toggleCode('
|
336
|
-
<div class="method-source-code" id="
|
335
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
336
|
+
<div class="method-source-code" id="M000017-source">
|
337
337
|
<pre>
|
338
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
142: <span class="ruby-keyword kw">end</span>
|
338
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 157</span>
|
339
|
+
157: <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>
|
340
|
+
158: <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> )
|
341
|
+
159: <span class="ruby-identifier">render</span> <span class="ruby-identifier">:json</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">d</span>
|
342
|
+
160: <span class="ruby-keyword kw">end</span>
|
344
343
|
</pre>
|
345
344
|
</div>
|
346
345
|
</div>
|
347
346
|
</div>
|
348
347
|
|
349
|
-
<div id="method-
|
350
|
-
<a name="
|
348
|
+
<div id="method-M000018" class="method-detail">
|
349
|
+
<a name="M000018"></a>
|
351
350
|
|
352
351
|
<div class="method-heading">
|
353
|
-
<a href="#
|
352
|
+
<a href="#M000018" class="method-signature">
|
354
353
|
<span class="method-name">redirect</span><span class="method-args">( klass, *a )</span>
|
355
354
|
</a>
|
356
355
|
</div>
|
357
356
|
|
358
357
|
<div class="method-description">
|
359
358
|
<p>
|
360
|
-
Send a <a href="Helpers.html#
|
359
|
+
Send a <a href="Helpers.html#M000018">redirect</a> response
|
361
360
|
</p>
|
362
361
|
<pre>
|
363
362
|
module Capcode
|
@@ -386,7 +385,7 @@ it can be a string path
|
|
386
385
|
</pre>
|
387
386
|
<p>
|
388
387
|
it can be an http status code (by default <tt><a
|
389
|
-
href="Helpers.html#
|
388
|
+
href="Helpers.html#M000018">redirect</a></tt> use the http status code 302)
|
390
389
|
</p>
|
391
390
|
<pre>
|
392
391
|
redirect( 304, MyController )
|
@@ -396,30 +395,30 @@ For more informations about HTTP status, see <a
|
|
396
395
|
href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection">en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection</a>
|
397
396
|
</p>
|
398
397
|
<p><a class="source-toggle" href="#"
|
399
|
-
onclick="toggleCode('
|
400
|
-
<div class="method-source-code" id="
|
398
|
+
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
399
|
+
<div class="method-source-code" id="M000018-source">
|
401
400
|
<pre>
|
402
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
401
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 189</span>
|
402
|
+
189: <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> )
|
403
|
+
190: <span class="ruby-identifier">httpCode</span> = <span class="ruby-value">302</span>
|
404
|
+
191:
|
405
|
+
192: <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> )
|
406
|
+
193: <span class="ruby-identifier">httpCode</span> = <span class="ruby-identifier">klass</span>
|
407
|
+
194: <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">shift</span>
|
408
|
+
195: <span class="ruby-keyword kw">end</span>
|
409
|
+
196:
|
410
|
+
197: [<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>]
|
411
|
+
198: <span class="ruby-keyword kw">end</span>
|
413
412
|
</pre>
|
414
413
|
</div>
|
415
414
|
</div>
|
416
415
|
</div>
|
417
416
|
|
418
|
-
<div id="method-
|
419
|
-
<a name="
|
417
|
+
<div id="method-M000016" class="method-detail">
|
418
|
+
<a name="M000016"></a>
|
420
419
|
|
421
420
|
<div class="method-heading">
|
422
|
-
<a href="#
|
421
|
+
<a href="#M000016" class="method-signature">
|
423
422
|
<span class="method-name">render</span><span class="method-args">( hash )</span>
|
424
423
|
</a>
|
425
424
|
</div>
|
@@ -429,7 +428,7 @@ href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection">en
|
|
429
428
|
Render a view
|
430
429
|
</p>
|
431
430
|
<p>
|
432
|
-
<a href="Helpers.html#
|
431
|
+
<a href="Helpers.html#M000016">render</a>‘s parameter can be a Hash
|
433
432
|
or a string. Passing a string is equivalent to do
|
434
433
|
</p>
|
435
434
|
<pre>
|
@@ -458,13 +457,13 @@ exist in sass_path
|
|
458
457
|
<li>:text => "my text"
|
459
458
|
|
460
459
|
</li>
|
461
|
-
<li>:<a href="Helpers.html#
|
460
|
+
<li>:<a href="Helpers.html#M000017">json</a> => MyObject : this suppose
|
462
461
|
that‘s MyObject respond to .to_json
|
463
462
|
|
464
463
|
</li>
|
465
|
-
<li>:<a href="Helpers.html#
|
464
|
+
<li>:<a href="Helpers.html#M000021">static</a> => "my_file.xxx" :
|
466
465
|
this suppose that‘s my_file.xxx exist in the <a
|
467
|
-
href="Helpers.html#
|
466
|
+
href="Helpers.html#M000021">static</a> directory
|
468
467
|
|
469
468
|
</li>
|
470
469
|
<li>:xml => :my_func : :my_func must be defined in <a
|
@@ -476,6 +475,12 @@ href="Views.html">Capcode::Views</a>
|
|
476
475
|
</li>
|
477
476
|
</ul>
|
478
477
|
<p>
|
478
|
+
Or you can use a "HTTP code" renderer :
|
479
|
+
</p>
|
480
|
+
<pre>
|
481
|
+
render 200 => "Ok", :server => "Capcode #{Capcode::CAPCOD_VERION}", ...
|
482
|
+
</pre>
|
483
|
+
<p>
|
479
484
|
If you want to use a specific layout, you can specify it with option
|
480
485
|
</p>
|
481
486
|
<pre>
|
@@ -497,96 +502,112 @@ If you use the WebDav renderer, you can use the option
|
|
497
502
|
:resource_class (see http://github.com/georgi/rack_dav for more informations)
|
498
503
|
</pre>
|
499
504
|
<p><a class="source-toggle" href="#"
|
500
|
-
onclick="toggleCode('
|
501
|
-
<div class="method-source-code" id="
|
505
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
506
|
+
<div class="method-source-code" id="M000016-source">
|
502
507
|
<pre>
|
503
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
508
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 83</span>
|
509
|
+
83: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>( <span class="ruby-identifier">hash</span> )
|
510
|
+
84: <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>
|
511
|
+
85: <span class="ruby-identifier">render_type</span> = <span class="ruby-keyword kw">nil</span>
|
512
|
+
86: <span class="ruby-identifier">possible_code_renderer</span> = <span class="ruby-keyword kw">nil</span>
|
513
|
+
87:
|
514
|
+
88: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span>
|
515
|
+
89: <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>
|
516
|
+
90: <span class="ruby-keyword kw">begin</span>
|
517
|
+
91: <span class="ruby-identifier">gem</span> <span class="ruby-node">"capcode-render-#{key.to_s}"</span>
|
518
|
+
92: <span class="ruby-identifier">require</span> <span class="ruby-node">"capcode/render/#{key.to_s}"</span>
|
519
|
+
93: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">LoadError</span>
|
520
|
+
94: <span class="ruby-keyword kw">nil</span>
|
521
|
+
95: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
|
522
|
+
96: <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>
|
523
|
+
97: <span class="ruby-keyword kw">end</span>
|
524
|
+
98:
|
525
|
+
99: <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>)
|
526
|
+
100: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span>
|
527
|
+
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-node">"Can't use multiple renderer (`#{render_type}' and `#{key}') !"</span>, <span class="ruby-identifier">caller</span>
|
528
|
+
102: <span class="ruby-keyword kw">end</span>
|
529
|
+
103: <span class="ruby-identifier">render_type</span> = <span class="ruby-identifier">key</span>
|
530
|
+
104: <span class="ruby-keyword kw">end</span>
|
531
|
+
105:
|
532
|
+
106: <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>
|
533
|
+
107: <span class="ruby-identifier">possible_code_renderer</span> = <span class="ruby-identifier">key</span>
|
534
|
+
108: <span class="ruby-keyword kw">end</span>
|
535
|
+
109: <span class="ruby-keyword kw">end</span>
|
536
|
+
110:
|
537
|
+
111: <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>
|
538
|
+
112: <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>
|
539
|
+
113: <span class="ruby-keyword kw">end</span>
|
540
|
+
114: <span class="ruby-keyword kw">end</span>
|
541
|
+
115: <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>)
|
542
|
+
116: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">possible_code_renderer</span>.<span class="ruby-identifier">nil?</span>
|
543
|
+
117: <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>
|
544
|
+
118: <span class="ruby-keyword kw">else</span>
|
545
|
+
119: <span class="ruby-identifier">code</span> = <span class="ruby-identifier">possible_code_renderer</span>
|
546
|
+
120: <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>)
|
547
|
+
121: <span class="ruby-identifier">header</span> = {}
|
548
|
+
122: <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>
|
549
|
+
123: <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>)
|
550
|
+
124: <span class="ruby-identifier">header</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
|
551
|
+
125: <span class="ruby-keyword kw">end</span>
|
552
|
+
126: [<span class="ruby-identifier">code</span>, <span class="ruby-identifier">hash</span>, <span class="ruby-identifier">body</span>]
|
553
|
+
127: <span class="ruby-keyword kw">end</span>
|
554
|
+
128: <span class="ruby-keyword kw">else</span>
|
555
|
+
129: <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>)
|
556
|
+
130: <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>)
|
557
|
+
131: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">content_type</span>.<span class="ruby-identifier">nil?</span>
|
558
|
+
132: <span class="ruby-ivar">@response</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">content_type</span>
|
559
|
+
133: <span class="ruby-keyword kw">end</span>
|
560
|
+
134:
|
561
|
+
135: <span class="ruby-keyword kw">begin</span>
|
562
|
+
136: <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> )
|
563
|
+
137: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
564
|
+
138: <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-identifier">caller</span>
|
565
|
+
139: <span class="ruby-keyword kw">end</span>
|
566
|
+
140: <span class="ruby-keyword kw">end</span>
|
567
|
+
141: <span class="ruby-keyword kw">else</span>
|
568
|
+
142: <span class="ruby-identifier">render</span>( <span class="ruby-identifier">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">hash</span> )
|
569
|
+
143: <span class="ruby-keyword kw">end</span>
|
570
|
+
144: <span class="ruby-keyword kw">end</span>
|
550
571
|
</pre>
|
551
572
|
</div>
|
552
573
|
</div>
|
553
574
|
</div>
|
554
575
|
|
555
|
-
<div id="method-
|
556
|
-
<a name="
|
576
|
+
<div id="method-M000021" class="method-detail">
|
577
|
+
<a name="M000021"></a>
|
557
578
|
|
558
579
|
<div class="method-heading">
|
559
|
-
<a href="#
|
580
|
+
<a href="#M000021" class="method-signature">
|
560
581
|
<span class="method-name">static</span><span class="method-args">()</span>
|
561
582
|
</a>
|
562
583
|
</div>
|
563
584
|
|
564
585
|
<div class="method-description">
|
565
586
|
<p>
|
566
|
-
Return information about the <a href="Helpers.html#
|
587
|
+
Return information about the <a href="Helpers.html#M000021">static</a>
|
567
588
|
directory
|
568
589
|
</p>
|
569
590
|
<ul>
|
570
|
-
<li><tt><a href="Helpers.html#
|
571
|
-
href="Helpers.html#
|
591
|
+
<li><tt><a href="Helpers.html#M000021">static</a>[:uri]</tt> give the <a
|
592
|
+
href="Helpers.html#M000021">static</a> URI
|
572
593
|
|
573
594
|
</li>
|
574
|
-
<li><tt><a href="Helpers.html#
|
575
|
-
the <a href="Helpers.html#
|
595
|
+
<li><tt><a href="Helpers.html#M000021">static</a>[:path]</tt> give the path to
|
596
|
+
the <a href="Helpers.html#M000021">static</a> directory on the server
|
576
597
|
|
577
598
|
</li>
|
578
599
|
</ul>
|
579
600
|
<p><a class="source-toggle" href="#"
|
580
|
-
onclick="toggleCode('
|
581
|
-
<div class="method-source-code" id="
|
601
|
+
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
602
|
+
<div class="method-source-code" id="M000021-source">
|
582
603
|
<pre>
|
583
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
604
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 271</span>
|
605
|
+
271: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">static</span>
|
606
|
+
272: {
|
607
|
+
273: <span class="ruby-identifier">:uri</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>,
|
608
|
+
274: <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-value str">"."</span>, <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span> ) )
|
609
|
+
275: }
|
610
|
+
276: <span class="ruby-keyword kw">end</span>
|
590
611
|
</pre>
|
591
612
|
</div>
|
592
613
|
</div>
|