Capcode 0.8.9 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +13 -1
- data/doc/rdoc/classes/Capcode.html +410 -545
- data/doc/rdoc/classes/Capcode/Configuration.html +263 -0
- data/doc/rdoc/classes/Capcode/Helpers.html +154 -345
- data/doc/rdoc/classes/Capcode/Helpers/Authorization.html +6 -6
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README_rdoc.html +42 -2
- data/doc/rdoc/files/lib/capcode/configuration_rb.html +1 -1
- data/doc/rdoc/files/lib/capcode/render/text_rb.html +1 -1
- data/doc/rdoc/files/lib/capcode_rb.html +14 -1
- data/doc/rdoc/fr_class_index.html +1 -1
- data/doc/rdoc/fr_file_index.html +0 -13
- data/doc/rdoc/fr_method_index.html +12 -14
- data/examples/render-image.rb +1 -1
- data/examples/render-text.rb +4 -1
- data/examples/rest.rb +1 -0
- data/examples/sample.rb +5 -3
- data/examples/upload.rb +1 -0
- data/lib/capcode.rb +45 -61
- data/lib/capcode/configuration.rb +69 -34
- data/lib/capcode/render/text.rb +1 -1
- data/lib/capcode/version.rb +1 -1
- metadata +31 -106
- data/doc/rdoc/classes/Capcode/Mab.html +0 -118
- data/doc/rdoc/files/lib/capcode/render/binary_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/render/email_rb.html +0 -108
- data/doc/rdoc/files/lib/capcode/render/erb_rb.html +0 -108
- data/doc/rdoc/files/lib/capcode/render/haml_rb.html +0 -108
- data/doc/rdoc/files/lib/capcode/render/json_rb.html +0 -108
- data/doc/rdoc/files/lib/capcode/render/markaby_rb.html +0 -108
- data/doc/rdoc/files/lib/capcode/render/mustache_rb.html +0 -108
- data/doc/rdoc/files/lib/capcode/render/none_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/render/redirect_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/render/sass_rb.html +0 -108
- data/doc/rdoc/files/lib/capcode/render/static_rb.html +0 -101
- data/doc/rdoc/files/lib/capcode/render/webdav_rb.html +0 -124
- data/doc/rdoc/files/lib/capcode/render/xml_rb.html +0 -101
- data/examples/auth-webdav.rb +0 -29
- data/examples/blog-ar.rb +0 -81
- data/examples/blog-ar.yml +0 -3
- data/examples/blog-couchdb-run.rb +0 -10
- data/examples/blog-couchdb.rb +0 -314
- data/examples/blog-couchdb.ru +0 -12
- data/examples/blog-couchdb.yml +0 -2
- data/examples/blog-dm.rb +0 -63
- data/examples/blog-dm.yml +0 -2
- data/examples/blog-mongodb-run.rb +0 -10
- data/examples/blog-mongodb.rb +0 -304
- data/examples/blog-mongodb.yml +0 -3
- data/examples/blog-sq.rb +0 -82
- data/examples/blog-sq.yml +0 -3
- data/examples/mail/mail_html.rhtml +0 -1
- data/examples/mail/mail_text.rhtml +0 -1
- data/examples/mail/ok.rhtml +0 -1
- data/examples/mail/rubyfr.png +0 -0
- data/examples/mustache/with_class.mustache +0 -8
- data/examples/mustache/without_class.mustache +0 -1
- data/examples/render-binary.rb +0 -46
- data/examples/render-email.rb +0 -68
- data/examples/render-erb.rb +0 -19
- data/examples/render-haml_sass.rb +0 -26
- data/examples/render-json.rb +0 -13
- data/examples/render-markaby.rb +0 -29
- data/examples/render-mustache.rb +0 -30
- data/examples/render-redirect.rb +0 -19
- data/examples/render-static.rb +0 -21
- data/examples/render-static.ru +0 -19
- data/examples/render-use.rb +0 -32
- data/examples/render-webdav.rb +0 -26
- data/examples/render-xml.rb +0 -24
- data/examples/rss.rb +0 -48
- data/examples/static/coderay.css +0 -131
- data/examples/static/index.html +0 -24
- data/examples/test/index.html +0 -1
- data/lib/capcode/base/ar.rb +0 -54
- data/lib/capcode/base/couchdb.rb +0 -23
- data/lib/capcode/base/dm.rb +0 -33
- data/lib/capcode/base/mongodb.rb +0 -27
- data/lib/capcode/base/sq.rb +0 -58
- data/lib/capcode/render/binary.rb +0 -8
- data/lib/capcode/render/email.rb +0 -73
- data/lib/capcode/render/erb.rb +0 -59
- data/lib/capcode/render/haml.rb +0 -60
- data/lib/capcode/render/json.rb +0 -14
- data/lib/capcode/render/markaby.rb +0 -38
- data/lib/capcode/render/mustache.rb +0 -37
- data/lib/capcode/render/none.rb +0 -7
- data/lib/capcode/render/redirect.rb +0 -7
- data/lib/capcode/render/sass.rb +0 -48
- data/lib/capcode/render/static.rb +0 -14
- data/lib/capcode/render/webdav.rb +0 -49
- data/lib/capcode/render/xml.rb +0 -119
data/README.rdoc
CHANGED
@@ -12,6 +12,18 @@ Capcode is a web microframework
|
|
12
12
|
|
13
13
|
== FEATURES/PROBLEMS:
|
14
14
|
|
15
|
+
=== 0.9.0
|
16
|
+
|
17
|
+
* <b>IMPORTANT</b>
|
18
|
+
* THIS VERSION IS A MAJOR ENHANCEMENT : YOU MUST UNINSTALL ALL PREVIOUS VERSIONS !!!
|
19
|
+
gem uninstall Capode --version '< 0.9.0'
|
20
|
+
* Renderers and database accessors have been extracted and are now in the {plugins repository}[http://github.com/glejeune/Capcode.more]. Each plugin is a gem that's can be installed separately.
|
21
|
+
* <b>Important, but less!</b>
|
22
|
+
* Add {Coffee-Script}[http://jashkenas.github.com/coffee-script/] renderer
|
23
|
+
* Update renderers options
|
24
|
+
* Rewrite configuration
|
25
|
+
* Bug corrections in all DB modules
|
26
|
+
|
15
27
|
=== 0.8.9
|
16
28
|
* Add Thin support
|
17
29
|
* Add MongoDB support
|
@@ -295,7 +307,7 @@ See <tt>examples/blog-dm.rb</tt> and/or <tt>examples/blog-couchdb.rb</tt> for co
|
|
295
307
|
# !!! Render file from /Users/greg/temp !!!
|
296
308
|
class WebDav < Route '/temp'
|
297
309
|
def get
|
298
|
-
render :webdav => "/Users/greg"
|
310
|
+
render :webdav => "/Users/greg/temp"
|
299
311
|
end
|
300
312
|
|
301
313
|
def method_missing(id, *a, &b)
|
@@ -66,62 +66,10 @@
|
|
66
66
|
<a href="../files/lib/capcode/configuration_rb.html">
|
67
67
|
lib/capcode/configuration.rb
|
68
68
|
</a>
|
69
|
-
<br />
|
70
|
-
<a href="../files/lib/capcode/render/binary_rb.html">
|
71
|
-
lib/capcode/render/binary.rb
|
72
|
-
</a>
|
73
|
-
<br />
|
74
|
-
<a href="../files/lib/capcode/render/email_rb.html">
|
75
|
-
lib/capcode/render/email.rb
|
76
|
-
</a>
|
77
|
-
<br />
|
78
|
-
<a href="../files/lib/capcode/render/erb_rb.html">
|
79
|
-
lib/capcode/render/erb.rb
|
80
|
-
</a>
|
81
|
-
<br />
|
82
|
-
<a href="../files/lib/capcode/render/haml_rb.html">
|
83
|
-
lib/capcode/render/haml.rb
|
84
|
-
</a>
|
85
|
-
<br />
|
86
|
-
<a href="../files/lib/capcode/render/json_rb.html">
|
87
|
-
lib/capcode/render/json.rb
|
88
|
-
</a>
|
89
|
-
<br />
|
90
|
-
<a href="../files/lib/capcode/render/markaby_rb.html">
|
91
|
-
lib/capcode/render/markaby.rb
|
92
|
-
</a>
|
93
|
-
<br />
|
94
|
-
<a href="../files/lib/capcode/render/mustache_rb.html">
|
95
|
-
lib/capcode/render/mustache.rb
|
96
|
-
</a>
|
97
|
-
<br />
|
98
|
-
<a href="../files/lib/capcode/render/none_rb.html">
|
99
|
-
lib/capcode/render/none.rb
|
100
|
-
</a>
|
101
|
-
<br />
|
102
|
-
<a href="../files/lib/capcode/render/redirect_rb.html">
|
103
|
-
lib/capcode/render/redirect.rb
|
104
|
-
</a>
|
105
|
-
<br />
|
106
|
-
<a href="../files/lib/capcode/render/sass_rb.html">
|
107
|
-
lib/capcode/render/sass.rb
|
108
|
-
</a>
|
109
|
-
<br />
|
110
|
-
<a href="../files/lib/capcode/render/static_rb.html">
|
111
|
-
lib/capcode/render/static.rb
|
112
|
-
</a>
|
113
69
|
<br />
|
114
70
|
<a href="../files/lib/capcode/render/text_rb.html">
|
115
71
|
lib/capcode/render/text.rb
|
116
72
|
</a>
|
117
|
-
<br />
|
118
|
-
<a href="../files/lib/capcode/render/webdav_rb.html">
|
119
|
-
lib/capcode/render/webdav.rb
|
120
|
-
</a>
|
121
|
-
<br />
|
122
|
-
<a href="../files/lib/capcode/render/xml_rb.html">
|
123
|
-
lib/capcode/render/xml.rb
|
124
|
-
</a>
|
125
73
|
<br />
|
126
74
|
<a href="../files/lib/capcode/helpers/auth_rb.html">
|
127
75
|
lib/capcode/helpers/auth.rb
|
@@ -150,7 +98,6 @@
|
|
150
98
|
<div class="name-list">
|
151
99
|
<a href="#M000001">Route</a>
|
152
100
|
<a href="#M000010">application</a>
|
153
|
-
<a href="#M000013">config</a>
|
154
101
|
<a href="#M000003">env</a>
|
155
102
|
<a href="#M000009">http_authentication</a>
|
156
103
|
<a href="#M000007">map</a>
|
@@ -187,8 +134,8 @@
|
|
187
134
|
Module <a href="Capcode/Resource.html" class="link">Capcode::Resource</a><br />
|
188
135
|
Module <a href="Capcode/Views.html" class="link">Capcode::Views</a><br />
|
189
136
|
Class <a href="Capcode/Base.html" class="link">Capcode::Base</a><br />
|
137
|
+
Class <a href="Capcode/Configuration.html" class="link">Capcode::Configuration</a><br />
|
190
138
|
Class <a href="Capcode/HTTPError.html" class="link">Capcode::HTTPError</a><br />
|
191
|
-
Class <a href="Capcode/Mab.html" class="link">Capcode::Mab</a><br />
|
192
139
|
|
193
140
|
</div>
|
194
141
|
|
@@ -255,169 +202,169 @@ If the regexp in the route does not match, all arguments will be
|
|
255
202
|
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
256
203
|
<div class="method-source-code" id="M000001-source">
|
257
204
|
<pre>
|
258
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
205
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 306</span>
|
206
|
+
306: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Route</span> <span class="ruby-operator">*</span><span class="ruby-identifier">routes_paths</span>
|
207
|
+
307: <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> {
|
208
|
+
308: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:__urls__</span>) {
|
209
|
+
309: <span class="ruby-comment cmt"># < Route '/hello/world/([^\/]*)/id(\d*)', '/hello/(.*)', :agent => /Songbird (\d\.\d)[\d\/]*?/</span>
|
210
|
+
310: <span class="ruby-comment cmt"># # => [ {'/hello/world' => '([^\/]*)/id(\d*)', '/hello' => '(.*)'}, </span>
|
211
|
+
311: <span class="ruby-comment cmt"># 2, </span>
|
212
|
+
312: <span class="ruby-comment cmt"># <Capcode::Klass>, </span>
|
213
|
+
313: <span class="ruby-comment cmt"># {:agent => /Songbird (\d\.\d)[\d\/]*?/} ]</span>
|
214
|
+
314: <span class="ruby-identifier">hash_of_routes</span> = {}
|
215
|
+
315: <span class="ruby-identifier">max_captures_for_routes</span> = <span class="ruby-value">0</span>
|
216
|
+
316: <span class="ruby-identifier">routes_paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">current_route_path</span><span class="ruby-operator">|</span>
|
217
|
+
317: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">current_route_path</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">String</span>
|
218
|
+
318: <span class="ruby-identifier">m</span> = <span class="ruby-regexp re">/\/([^\/]*\(.*)/</span>.<span class="ruby-identifier">match</span>( <span class="ruby-identifier">current_route_path</span> )
|
219
|
+
319: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span>
|
220
|
+
320: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">"Route `#{current_route_path}' already defined with regexp `#{hash_of_routes[current_route_path]}' !"</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash_of_routes</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">current_route_path</span>)
|
221
|
+
321: <span class="ruby-identifier">hash_of_routes</span>[<span class="ruby-identifier">current_route_path</span>] = <span class="ruby-value str">''</span>
|
222
|
+
322: <span class="ruby-keyword kw">else</span>
|
223
|
+
323: <span class="ruby-identifier">_pre</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">pre_match</span>
|
224
|
+
324: <span class="ruby-identifier">_pre</span> = <span class="ruby-value str">"/"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">_pre</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
225
|
+
325: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">"Route `#{_pre}' already defined with regexp `#{hash_of_routes[_pre]}' !"</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash_of_routes</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">_pre</span>)
|
226
|
+
326: <span class="ruby-identifier">hash_of_routes</span>[<span class="ruby-identifier">_pre</span>] = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]
|
227
|
+
327: <span class="ruby-identifier">max_captures_for_routes</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">number_of_captures</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max_captures_for_routes</span> <span class="ruby-operator"><</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">number_of_captures</span>
|
228
|
+
328: <span class="ruby-keyword kw">end</span>
|
229
|
+
329: <span class="ruby-keyword kw">else</span>
|
230
|
+
330: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">ParameterError</span>, <span class="ruby-value str">"Bad route declaration !"</span>, <span class="ruby-identifier">caller</span>
|
231
|
+
331: <span class="ruby-keyword kw">end</span>
|
232
|
+
332: <span class="ruby-keyword kw">end</span>
|
233
|
+
333: [<span class="ruby-identifier">hash_of_routes</span>, <span class="ruby-identifier">max_captures_for_routes</span>, <span class="ruby-keyword kw">self</span>]
|
234
|
+
334: }
|
235
|
+
335:
|
236
|
+
336: <span class="ruby-comment cmt"># Hash containing all the request parameters (GET or POST)</span>
|
237
|
+
337: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
|
238
|
+
338: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
|
239
|
+
339: <span class="ruby-keyword kw">end</span>
|
240
|
+
340:
|
241
|
+
341: <span class="ruby-comment cmt"># Hash containing all the environment variables</span>
|
242
|
+
342: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
|
243
|
+
343: <span class="ruby-ivar">@env</span>
|
244
|
+
344: <span class="ruby-keyword kw">end</span>
|
245
|
+
345:
|
246
|
+
346: <span class="ruby-comment cmt"># Session hash</span>
|
247
|
+
347: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
|
248
|
+
348: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
|
249
|
+
349: <span class="ruby-keyword kw">end</span>
|
250
|
+
350:
|
251
|
+
351: <span class="ruby-comment cmt"># Return the Rack::Request object</span>
|
252
|
+
352: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
|
253
|
+
353: <span class="ruby-ivar">@request</span>
|
254
|
+
354: <span class="ruby-keyword kw">end</span>
|
255
|
+
355:
|
256
|
+
356: <span class="ruby-comment cmt"># Return the Rack::Response object</span>
|
257
|
+
357: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
|
258
|
+
358: <span class="ruby-ivar">@response</span>
|
259
|
+
359: <span class="ruby-keyword kw">end</span>
|
260
|
+
360:
|
261
|
+
361: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>( <span class="ruby-identifier">e</span> ) <span class="ruby-comment cmt">#:nodoc:</span>
|
262
|
+
362: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">e</span>
|
263
|
+
363: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>
|
264
|
+
364: <span class="ruby-ivar">@request</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@env</span>)
|
265
|
+
365:
|
266
|
+
366: <span class="ruby-comment cmt"># __k = self.class.to_s.split( /::/ )[-1].downcase.to_sym</span>
|
267
|
+
367: <span class="ruby-comment cmt"># @@__FILTERS.each do |f|</span>
|
268
|
+
368: <span class="ruby-comment cmt"># proc = f.delete(:action)</span>
|
269
|
+
369: <span class="ruby-comment cmt"># __run = true</span>
|
270
|
+
370: <span class="ruby-comment cmt"># if f[:only]</span>
|
271
|
+
371: <span class="ruby-comment cmt"># __run = f[:only].include?(__k)</span>
|
272
|
+
372: <span class="ruby-comment cmt"># end</span>
|
273
|
+
373: <span class="ruby-comment cmt"># if f[:except]</span>
|
274
|
+
374: <span class="ruby-comment cmt"># __run = !f[:except].include?(__k)</span>
|
275
|
+
375: <span class="ruby-comment cmt"># end</span>
|
276
|
+
376: <span class="ruby-comment cmt"># </span>
|
277
|
+
377: <span class="ruby-comment cmt"># # proc.call(self) if __run</span>
|
278
|
+
378: <span class="ruby-comment cmt"># puts "call #{proc} for #{__k}"</span>
|
279
|
+
379: <span class="ruby-comment cmt"># end</span>
|
280
|
+
380:
|
281
|
+
381: <span class="ruby-comment cmt"># Check authz</span>
|
282
|
+
382: <span class="ruby-identifier">authz_options</span> = <span class="ruby-keyword kw">nil</span>
|
283
|
+
383: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">__auth__</span> <span class="ruby-keyword kw">and</span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">__auth__</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
284
|
+
384: <span class="ruby-identifier">authz_options</span> = <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">__auth__</span>[<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">nil</span>
|
285
|
+
385: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">authz_options</span>.<span class="ruby-identifier">nil?</span>
|
286
|
+
386: <span class="ruby-identifier">route</span> = <span class="ruby-keyword kw">nil</span>
|
287
|
+
387:
|
288
|
+
388: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">__auth__</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-identifier">o</span><span class="ruby-operator">|</span>
|
289
|
+
389: <span class="ruby-identifier">regexp</span> = <span class="ruby-node">"^#{r.gsub(/\/$/, "")}([/]{1}.*)?$"</span>
|
290
|
+
390: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">regexp</span>).<span class="ruby-identifier">match</span>( <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span> )
|
291
|
+
391: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">route</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">></span> <span class="ruby-identifier">route</span>.<span class="ruby-identifier">size</span>
|
292
|
+
392: <span class="ruby-identifier">route</span> = <span class="ruby-identifier">r</span>
|
293
|
+
393: <span class="ruby-identifier">authz_options</span> = <span class="ruby-identifier">o</span>
|
294
|
+
394: <span class="ruby-keyword kw">end</span>
|
295
|
+
395: <span class="ruby-keyword kw">end</span>
|
296
|
+
396: <span class="ruby-keyword kw">end</span>
|
297
|
+
397: <span class="ruby-keyword kw">end</span>
|
298
|
+
398: <span class="ruby-keyword kw">end</span>
|
299
|
+
399:
|
300
|
+
400: <span class="ruby-identifier">r</span> = <span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:halt</span>) {
|
301
|
+
401: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">authz_options</span>.<span class="ruby-identifier">nil?</span>
|
302
|
+
402: <span class="ruby-identifier">http_authentication</span>( <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:type</span>], <span class="ruby-identifier">:realm</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:realm</span>], <span class="ruby-identifier">:opaque</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:realm</span>] ) {
|
303
|
+
403: <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:autz</span>]
|
304
|
+
404: }
|
305
|
+
405: <span class="ruby-keyword kw">end</span>
|
306
|
+
406:
|
307
|
+
407: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
|
308
|
+
408: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
|
309
|
+
409: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
|
310
|
+
410:
|
311
|
+
411: <span class="ruby-identifier">aPath</span> = <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</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-value str">"/"</span> )
|
312
|
+
412: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</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">p</span>, <span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
313
|
+
413: <span class="ruby-identifier">xPath</span> = <span class="ruby-identifier">p</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-value str">"/"</span> )
|
314
|
+
414: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">xPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">aPath</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
315
|
+
415: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
|
316
|
+
416: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
|
317
|
+
417: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">finalNArgs</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">finalNArgs</span> <span class="ruby-operator">></span> <span class="ruby-identifier">diffNArgs</span>
|
318
|
+
418: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
|
319
|
+
419: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
|
320
|
+
420: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
|
321
|
+
421: <span class="ruby-keyword kw">end</span>
|
322
|
+
422: <span class="ruby-keyword kw">end</span>
|
323
|
+
423:
|
324
|
+
424: <span class="ruby-keyword kw">end</span>
|
325
|
+
425:
|
326
|
+
426: <span class="ruby-identifier">nargs</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">1</span>]
|
327
|
+
427: <span class="ruby-identifier">regexp</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">0</span>][<span class="ruby-identifier">finalPath</span>] )
|
328
|
+
428: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">regexp</span>.<span class="ruby-identifier">match</span>( <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span>).<span class="ruby-identifier">gsub</span>( <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-node">"^#{finalPath}"</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> ) )
|
329
|
+
429: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
|
330
|
+
430: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">ParameterError</span>, <span class="ruby-node">"Path info `#{@request.path_info}' does not match route regexp `#{regexp.source}'"</span>
|
331
|
+
431: <span class="ruby-keyword kw">else</span>
|
332
|
+
432: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">captures</span>.<span class="ruby-identifier">map</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">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>)<span class="ruby-operator">?</span><span class="ruby-keyword kw">nil</span><span class="ruby-operator">:</span><span class="ruby-identifier">x</span> }
|
333
|
+
433: <span class="ruby-keyword kw">end</span>
|
334
|
+
434:
|
335
|
+
435: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">nargs</span>
|
336
|
+
436: <span class="ruby-identifier">args</span> <span class="ruby-operator"><<</span> <span class="ruby-keyword kw">nil</span>
|
337
|
+
437: <span class="ruby-keyword kw">end</span>
|
338
|
+
438:
|
339
|
+
439: <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@env</span>[<span class="ruby-value str">"REQUEST_METHOD"</span>]
|
340
|
+
440: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"GET"</span>
|
341
|
+
441: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
|
342
|
+
442: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"POST"</span>
|
343
|
+
443: <span class="ruby-identifier">_method</span> = <span class="ruby-identifier">params</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-value str">"_method"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-value str">"post"</span> }
|
344
|
+
444: <span class="ruby-identifier">send</span>( <span class="ruby-identifier">_method</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
|
345
|
+
445: <span class="ruby-keyword kw">else</span>
|
346
|
+
446: <span class="ruby-identifier">_method</span> = <span class="ruby-ivar">@env</span>[<span class="ruby-value str">"REQUEST_METHOD"</span>]
|
347
|
+
447: <span class="ruby-identifier">send</span>( <span class="ruby-identifier">_method</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
|
348
|
+
448: <span class="ruby-keyword kw">end</span>
|
349
|
+
449: }
|
350
|
+
450: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_ary</span>)
|
351
|
+
451: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">shift</span> <span class="ruby-comment cmt">#r[0]</span>
|
352
|
+
452: <span class="ruby-comment cmt">#r[1].each do |k,v|</span>
|
353
|
+
453: <span class="ruby-identifier">r</span>.<span class="ruby-identifier">shift</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>
|
354
|
+
454: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
|
355
|
+
455: <span class="ruby-keyword kw">end</span>
|
356
|
+
456: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">shift</span> <span class="ruby-comment cmt">#r[2]</span>
|
357
|
+
457: <span class="ruby-keyword kw">else</span>
|
358
|
+
458: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
|
359
|
+
459: <span class="ruby-keyword kw">end</span>
|
360
|
+
460:
|
361
|
+
461: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
|
362
|
+
462: <span class="ruby-keyword kw">end</span>
|
363
|
+
463:
|
364
|
+
464: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
|
365
|
+
465: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>
|
366
|
+
466: }
|
367
|
+
467: <span class="ruby-keyword kw">end</span>
|
421
368
|
</pre>
|
422
369
|
</div>
|
423
370
|
</div>
|
@@ -437,7 +384,8 @@ If the regexp in the route does not match, all arguments will be
|
|
437
384
|
Return the Rack App.
|
438
385
|
</p>
|
439
386
|
<p>
|
440
|
-
Options : see <a
|
387
|
+
Options : see <a
|
388
|
+
href="Capcode/Configuration.html#M000022">Capcode::Configuration.set</a>
|
441
389
|
</p>
|
442
390
|
<p>
|
443
391
|
Options <a href="Capcode.html#M000012">set</a> here replace the ones <a
|
@@ -447,94 +395,71 @@ href="Capcode.html#M000012">set</a> globally
|
|
447
395
|
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
448
396
|
<div class="method-source-code" id="M000010-source">
|
449
397
|
<pre>
|
450
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
451
|
-
|
452
|
-
|
398
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 536</span>
|
399
|
+
536: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">application</span>( <span class="ruby-identifier">args</span> = {} )
|
400
|
+
537: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
|
401
|
+
538:
|
402
|
+
539: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">constants</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-operator">|</span>
|
403
|
+
540: <span class="ruby-keyword kw">begin</span>
|
404
|
+
541: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">eval</span> <span class="ruby-node">"Capcode::#{k}.public_methods(true).include?( '__urls__' )"</span>
|
405
|
+
542: <span class="ruby-identifier">hash_of_routes</span>, <span class="ruby-identifier">max_captures_for_routes</span>, <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">eval</span> <span class="ruby-node">"Capcode::#{k}.__urls__"</span>
|
406
|
+
543: <span class="ruby-identifier">hash_of_routes</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">current_route_path</span><span class="ruby-operator">|</span>
|
407
|
+
544: <span class="ruby-comment cmt">#raise Capcode::RouteError, "Route `#{current_route_path}' already define !", caller if @@__ROUTES.keys.include?(current_route_path)</span>
|
408
|
+
545: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">"Route `#{current_route_path}' already define !"</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">current_route_path</span>)
|
409
|
+
546: <span class="ruby-comment cmt">#@@__ROUTES[current_route_path] = klass.new</span>
|
410
|
+
547: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>[<span class="ruby-identifier">current_route_path</span>] = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>
|
411
|
+
548: <span class="ruby-keyword kw">end</span>
|
412
|
+
549: <span class="ruby-keyword kw">end</span>
|
413
|
+
550: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
414
|
+
551: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
|
415
|
+
552: <span class="ruby-keyword kw">end</span>
|
416
|
+
553: <span class="ruby-keyword kw">end</span>
|
453
417
|
554:
|
454
|
-
555: <span class="ruby-
|
455
|
-
556:
|
456
|
-
557:
|
457
|
-
558:
|
458
|
-
559:
|
459
|
-
560:
|
460
|
-
561:
|
461
|
-
562:
|
462
|
-
563:
|
463
|
-
564:
|
464
|
-
565:
|
465
|
-
566: <span class="ruby-
|
466
|
-
567:
|
467
|
-
568: <span class="ruby-
|
468
|
-
569: <span class="ruby-keyword kw">
|
469
|
-
570:
|
470
|
-
571: <span class="ruby-
|
471
|
-
572: <span class="ruby-
|
472
|
-
573: <span class="ruby-
|
473
|
-
574:
|
474
|
-
575: <span class="ruby-
|
475
|
-
576: <span class="ruby-
|
476
|
-
577: <span class="ruby-comment cmt">#app = Rack::
|
477
|
-
578:
|
478
|
-
579: <span class="ruby-identifier">
|
479
|
-
580:
|
480
|
-
581: <span class="ruby-identifier">
|
481
|
-
582: <span class="ruby-
|
482
|
-
583:
|
483
|
-
584: <span class="ruby-
|
484
|
-
585:
|
485
|
-
586:
|
486
|
-
587: <span class="ruby-
|
487
|
-
588:
|
488
|
-
589: <span class="ruby-
|
489
|
-
590: <span class="ruby-
|
490
|
-
591:
|
491
|
-
592: <span class="ruby-
|
492
|
-
593:
|
493
|
-
594:
|
494
|
-
595:
|
495
|
-
596:
|
496
|
-
597:
|
497
|
-
598:
|
498
|
-
599:
|
499
|
-
600: <span class="ruby-keyword kw">else</span>
|
500
|
-
601: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">middleware</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
|
501
|
-
602: <span class="ruby-keyword kw">end</span>
|
502
|
-
603: <span class="ruby-keyword kw">end</span>
|
503
|
-
604:
|
504
|
-
605: <span class="ruby-comment cmt"># Start database</span>
|
505
|
-
606: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">"db_connect"</span>
|
506
|
-
607: <span class="ruby-identifier">db_connect</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:db_config</span>], <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>] )
|
507
|
-
608: <span class="ruby-keyword kw">end</span>
|
508
|
-
609:
|
509
|
-
610: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
510
|
-
611: <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> )
|
511
|
-
612: <span class="ruby-keyword kw">end</span>
|
512
|
-
613:
|
513
|
-
614: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">app</span>
|
514
|
-
615: <span class="ruby-keyword kw">end</span>
|
515
|
-
</pre>
|
516
|
-
</div>
|
517
|
-
</div>
|
518
|
-
</div>
|
519
|
-
|
520
|
-
<div id="method-M000013" class="method-detail">
|
521
|
-
<a name="M000013"></a>
|
522
|
-
|
523
|
-
<div class="method-heading">
|
524
|
-
<a href="#M000013" class="method-signature">
|
525
|
-
<span class="method-name">config</span><span class="method-args">()</span>
|
526
|
-
</a>
|
527
|
-
</div>
|
528
|
-
|
529
|
-
<div class="method-description">
|
530
|
-
<p><a class="source-toggle" href="#"
|
531
|
-
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
532
|
-
<div class="method-source-code" id="M000013-source">
|
533
|
-
<pre>
|
534
|
-
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 35</span>
|
535
|
-
35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">config</span>
|
536
|
-
36: <span class="ruby-ivar">@configuration</span> <span class="ruby-operator">||=</span> {}
|
537
|
-
37: <span class="ruby-keyword kw">end</span>
|
418
|
+
555: <span class="ruby-comment cmt"># Set Static directory</span>
|
419
|
+
556: <span class="ruby-comment cmt">#@@__STATIC_DIR = (conf[:static][0].chr == "/")?conf[:static]:"/"+conf[:static] unless conf[:static].nil?</span>
|
420
|
+
557: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</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>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">chr</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"/"</span>)<span class="ruby-operator">?</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>)<span class="ruby-operator">:</span><span class="ruby-value str">"/"</span><span class="ruby-operator">+</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>) <span class="ruby-keyword kw">unless</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>).<span class="ruby-identifier">nil?</span>
|
421
|
+
558:
|
422
|
+
559: <span class="ruby-comment cmt"># Initialize Rack App</span>
|
423
|
+
560: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"** Map routes."</span> <span class="ruby-keyword kw">if</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">:verbose</span>)
|
424
|
+
561: <span class="ruby-comment cmt">#app = Rack::URLMap.new(@@__ROUTES)</span>
|
425
|
+
562: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">URLMap</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>)
|
426
|
+
563: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Initialize static directory (#{Capcode::Configuration.get(:static)})"</span> <span class="ruby-keyword kw">if</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">:verbose</span>)
|
427
|
+
564: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Static</span>.<span class="ruby-identifier">new</span>(
|
428
|
+
565: <span class="ruby-identifier">app</span>,
|
429
|
+
566: <span class="ruby-comment cmt">#:urls => [@@__STATIC_DIR], </span>
|
430
|
+
567: <span class="ruby-identifier">:urls</span> =<span class="ruby-operator">></span> [<span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>],
|
431
|
+
568: <span class="ruby-identifier">:root</span> =<span class="ruby-operator">></span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</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>))
|
432
|
+
569: ) <span class="ruby-keyword kw">unless</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>).<span class="ruby-identifier">nil?</span>
|
433
|
+
570: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"** Initialize session"</span> <span class="ruby-keyword kw">if</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">:verbose</span>)
|
434
|
+
571: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</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">:session</span>) )
|
435
|
+
572: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
|
436
|
+
573: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">ContentLength</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
|
437
|
+
574: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Lint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
|
438
|
+
575: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">ShowExceptions</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
|
439
|
+
576: <span class="ruby-comment cmt">#app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
|
440
|
+
577: <span class="ruby-comment cmt"># app = Rack::CommonLogger.new( app, Logger.new(conf[:log]) )</span>
|
441
|
+
578:
|
442
|
+
579: <span class="ruby-identifier">middlewares</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mw</span><span class="ruby-operator">|</span>
|
443
|
+
580: <span class="ruby-identifier">middleware</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span> = <span class="ruby-identifier">mw</span>
|
444
|
+
581: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Load middleware #{middleware}"</span> <span class="ruby-keyword kw">if</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">:verbose</span>)
|
445
|
+
582: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
|
446
|
+
583: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">middleware</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
447
|
+
584: <span class="ruby-keyword kw">else</span>
|
448
|
+
585: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">middleware</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
|
449
|
+
586: <span class="ruby-keyword kw">end</span>
|
450
|
+
587: <span class="ruby-keyword kw">end</span>
|
451
|
+
588:
|
452
|
+
589: <span class="ruby-comment cmt"># Start database</span>
|
453
|
+
590: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">"db_connect"</span>
|
454
|
+
591: <span class="ruby-identifier">db_connect</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">:db_config</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">:log</span>) )
|
455
|
+
592: <span class="ruby-keyword kw">end</span>
|
456
|
+
593:
|
457
|
+
594: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
458
|
+
595: <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> )
|
459
|
+
596: <span class="ruby-keyword kw">end</span>
|
460
|
+
597:
|
461
|
+
598: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">app</span>
|
462
|
+
599: <span class="ruby-keyword kw">end</span>
|
538
463
|
</pre>
|
539
464
|
</div>
|
540
465
|
</div>
|
@@ -557,10 +482,10 @@ Hash containing all the environment variables
|
|
557
482
|
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
558
483
|
<div class="method-source-code" id="M000003-source">
|
559
484
|
<pre>
|
560
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
561
|
-
|
562
|
-
|
563
|
-
|
485
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 342</span>
|
486
|
+
342: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
|
487
|
+
343: <span class="ruby-ivar">@env</span>
|
488
|
+
344: <span class="ruby-keyword kw">end</span>
|
564
489
|
</pre>
|
565
490
|
</div>
|
566
491
|
</div>
|
@@ -615,27 +540,27 @@ The block must return a Hash of username => password like that :
|
|
615
540
|
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
616
541
|
<div class="method-source-code" id="M000009-source">
|
617
542
|
<pre>
|
618
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
543
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 510</span>
|
544
|
+
510: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">http_authentication</span>( <span class="ruby-identifier">opts</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span> )
|
545
|
+
511: <span class="ruby-identifier">options</span> = {
|
546
|
+
512: <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:basic</span>,
|
547
|
+
513: <span class="ruby-identifier">:realm</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"Capcode.app"</span>,
|
548
|
+
514: <span class="ruby-identifier">:opaque</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"opaque"</span>,
|
549
|
+
515: <span class="ruby-identifier">:routes</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"/"</span>
|
550
|
+
516: }.<span class="ruby-identifier">merge</span>( <span class="ruby-identifier">opts</span> )
|
551
|
+
517:
|
552
|
+
518: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:autz</span>] = <span class="ruby-identifier">b</span>.<span class="ruby-identifier">call</span>()
|
553
|
+
519:
|
554
|
+
520: <span class="ruby-ivar">@__auth__</span> <span class="ruby-operator">||=</span> {}
|
555
|
+
521:
|
556
|
+
522: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:routes</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>
|
557
|
+
523: <span class="ruby-identifier">options</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">r</span><span class="ruby-operator">|</span>
|
558
|
+
524: <span class="ruby-ivar">@__auth__</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-identifier">options</span>
|
559
|
+
525: <span class="ruby-keyword kw">end</span>
|
560
|
+
526: <span class="ruby-keyword kw">else</span>
|
561
|
+
527: <span class="ruby-ivar">@__auth__</span>[<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:routes</span>]] = <span class="ruby-identifier">options</span>
|
562
|
+
528: <span class="ruby-keyword kw">end</span>
|
563
|
+
529: <span class="ruby-keyword kw">end</span>
|
639
564
|
</pre>
|
640
565
|
</div>
|
641
566
|
</div>
|
@@ -664,11 +589,11 @@ Rack or What you want Helper
|
|
664
589
|
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
665
590
|
<div class="method-source-code" id="M000007-source">
|
666
591
|
<pre>
|
667
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
592
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 474</span>
|
593
|
+
474: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map</span>( <span class="ruby-identifier">route</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span> )
|
594
|
+
475: <span class="ruby-comment cmt">#@@__ROUTES[route] = yield</span>
|
595
|
+
476: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>[<span class="ruby-identifier">route</span>] = <span class="ruby-keyword kw">yield</span>
|
596
|
+
477: <span class="ruby-keyword kw">end</span>
|
672
597
|
</pre>
|
673
598
|
</div>
|
674
599
|
</div>
|
@@ -692,10 +617,10 @@ parameters (GET or POST)
|
|
692
617
|
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
693
618
|
<div class="method-source-code" id="M000002-source">
|
694
619
|
<pre>
|
695
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
696
|
-
|
697
|
-
|
698
|
-
|
620
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 337</span>
|
621
|
+
337: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
|
622
|
+
338: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
|
623
|
+
339: <span class="ruby-keyword kw">end</span>
|
699
624
|
</pre>
|
700
625
|
</div>
|
701
626
|
</div>
|
@@ -718,10 +643,10 @@ Return the Rack::Request object
|
|
718
643
|
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
719
644
|
<div class="method-source-code" id="M000005-source">
|
720
645
|
<pre>
|
721
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
722
|
-
|
723
|
-
|
724
|
-
|
646
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 352</span>
|
647
|
+
352: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
|
648
|
+
353: <span class="ruby-ivar">@request</span>
|
649
|
+
354: <span class="ruby-keyword kw">end</span>
|
725
650
|
</pre>
|
726
651
|
</div>
|
727
652
|
</div>
|
@@ -744,10 +669,10 @@ Return the Rack::Response object
|
|
744
669
|
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
745
670
|
<div class="method-source-code" id="M000006-source">
|
746
671
|
<pre>
|
747
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
748
|
-
|
749
|
-
|
750
|
-
|
672
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 357</span>
|
673
|
+
357: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
|
674
|
+
358: <span class="ruby-ivar">@response</span>
|
675
|
+
359: <span class="ruby-keyword kw">end</span>
|
751
676
|
</pre>
|
752
677
|
</div>
|
753
678
|
</div>
|
@@ -767,7 +692,8 @@ Return the Rack::Response object
|
|
767
692
|
Start your <a href="Capcode.html#M000010">application</a>.
|
768
693
|
</p>
|
769
694
|
<p>
|
770
|
-
Options : see <a
|
695
|
+
Options : see <a
|
696
|
+
href="Capcode/Configuration.html#M000022">Capcode::Configuration.set</a>
|
771
697
|
</p>
|
772
698
|
<p>
|
773
699
|
Options <a href="Capcode.html#M000012">set</a> here replace the ones <a
|
@@ -777,131 +703,131 @@ href="Capcode.html#M000012">set</a> globally
|
|
777
703
|
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
778
704
|
<div class="method-source-code" id="M000011-source">
|
779
705
|
<pre>
|
780
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
706
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 606</span>
|
707
|
+
606: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
|
708
|
+
607: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
|
709
|
+
608:
|
710
|
+
609: <span class="ruby-comment cmt"># Parse options</span>
|
711
|
+
610: <span class="ruby-identifier">opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
|
712
|
+
611: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">"Usage: #{File.basename($0)} [options]"</span>
|
713
|
+
612: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">""</span>
|
714
|
+
613: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">"Specific options:"</span>
|
715
|
+
614:
|
716
|
+
615: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-C"</span>, <span class="ruby-value str">"--console"</span>, <span class="ruby-value str">"Run in console mode with IRB (default: false)"</span> ) {
|
717
|
+
616: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:console</span>, <span class="ruby-keyword kw">true</span>
|
718
|
+
617: }
|
719
|
+
618: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-h"</span>, <span class="ruby-value str">"--host HOSTNAME"</span>, <span class="ruby-node">"Host for web server to bind to (default: #{Capcode::Configuration.get(:host)})"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
|
720
|
+
619: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:host</span>, <span class="ruby-identifier">h</span>
|
721
|
+
620: }
|
722
|
+
621: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-p"</span>, <span class="ruby-value str">"--port NUM"</span>, <span class="ruby-node">"Port for web server (default: #{Capcode::Configuration.get(:port)})"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
|
723
|
+
622: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:port</span>, <span class="ruby-identifier">p</span>
|
724
|
+
623: }
|
725
|
+
624: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-d"</span>, <span class="ruby-value str">"--daemonize [true|false]"</span>, <span class="ruby-node">"Daemonize (default: #{Capcode::Configuration.get(:daemonize)})"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
|
726
|
+
625: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:daemonize</span>, <span class="ruby-identifier">d</span>
|
727
|
+
626: }
|
728
|
+
627: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-r"</span>, <span class="ruby-value str">"--root PATH"</span>, <span class="ruby-node">"Working directory (default: #{Capcode::Configuration.get(:root)})"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
|
729
|
+
628: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:root</span>, <span class="ruby-identifier">w</span>
|
730
|
+
629: }
|
731
|
+
630: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-s"</span>, <span class="ruby-value str">"--static PATH"</span>, <span class="ruby-node">"Static directory -- relative to the root directory (default: #{Capcode::Configuration.get(:static)})"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
732
|
+
631: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:static</span>, <span class="ruby-identifier">r</span>
|
733
|
+
632: }
|
734
|
+
633:
|
735
|
+
634: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">""</span>
|
736
|
+
635: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">"Common options:"</span>
|
737
|
+
636:
|
738
|
+
637: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-?"</span>, <span class="ruby-value str">"--help"</span>, <span class="ruby-value str">"Show this message"</span>) <span class="ruby-keyword kw">do</span>
|
739
|
+
638: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>
|
740
|
+
639: <span class="ruby-identifier">exit</span>
|
741
|
+
640: <span class="ruby-keyword kw">end</span>
|
742
|
+
641: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-v"</span>, <span class="ruby-value str">"--version"</span>, <span class="ruby-value str">"Show versions"</span>) <span class="ruby-keyword kw">do</span>
|
743
|
+
642: <span class="ruby-identifier">puts</span> <span class="ruby-node">"Capcode version #{Capcode::CAPCOD_VERION} (ruby v#{RUBY_VERSION})"</span>
|
744
|
+
643: <span class="ruby-identifier">exit</span>
|
745
|
+
644: <span class="ruby-keyword kw">end</span>
|
746
|
+
645: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>( <span class="ruby-value str">"-V"</span>, <span class="ruby-value str">"--verbose"</span>, <span class="ruby-value str">"Run in verbose mode"</span> ) <span class="ruby-keyword kw">do</span>
|
747
|
+
646: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:verbose</span>, <span class="ruby-keyword kw">true</span>
|
748
|
+
647: <span class="ruby-keyword kw">end</span>
|
749
|
+
648: <span class="ruby-keyword kw">end</span>
|
750
|
+
649:
|
751
|
+
650: <span class="ruby-keyword kw">begin</span>
|
752
|
+
651: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span> <span class="ruby-constant">ARGV</span>
|
753
|
+
652: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
754
|
+
653: <span class="ruby-identifier">puts</span> <span class="ruby-node">"!! #{ex.message}"</span>
|
755
|
+
654: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** use `#{File.basename($0)} --help` for more details..."</span>
|
756
|
+
655: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
|
757
|
+
656: <span class="ruby-keyword kw">end</span>
|
758
|
+
657:
|
759
|
+
658: <span class="ruby-comment cmt"># Run in the Working directory</span>
|
760
|
+
659: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Go on root directory (#{File.expand_path(Capcode::Configuration.get(:root))})"</span> <span class="ruby-keyword kw">if</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">:verbose</span>)
|
761
|
+
660: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</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-keyword kw">do</span>
|
762
|
+
661:
|
763
|
+
662: <span class="ruby-comment cmt"># Check that mongrel exists </span>
|
764
|
+
663: <span class="ruby-keyword kw">if</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">:server</span>).<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</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">:server</span>) <span class="ruby-operator">==</span> <span class="ruby-value str">"mongrel"</span>
|
765
|
+
664: <span class="ruby-keyword kw">begin</span>
|
766
|
+
665: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
|
767
|
+
666: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:server</span>, <span class="ruby-identifier">:mongrel</span>
|
768
|
+
667: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
|
769
|
+
668: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"!! could not load mongrel. Falling back to webrick."</span>
|
770
|
+
669: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:server</span>, <span class="ruby-identifier">:webrick</span>
|
771
|
+
670: <span class="ruby-keyword kw">end</span>
|
772
|
+
671: <span class="ruby-keyword kw">end</span>
|
773
|
+
672:
|
774
|
+
673: <span class="ruby-comment cmt"># From rackup !!!</span>
|
775
|
+
674: <span class="ruby-keyword kw">if</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">:daemonize</span>)
|
776
|
+
675: <span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">/java/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-constant">RUBY_PLATFORM</span>).<span class="ruby-identifier">nil?</span>
|
777
|
+
676: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">RUBY_VERSION</span> <span class="ruby-operator"><</span> <span class="ruby-value str">"1.9"</span>
|
778
|
+
677: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
|
779
|
+
678: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
|
780
|
+
679: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
|
781
|
+
680: <span class="ruby-comment cmt"># Dir.chdir "/"</span>
|
782
|
+
681: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
|
783
|
+
682: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">"/dev/null"</span>
|
784
|
+
683: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">"/dev/null"</span>, <span class="ruby-value str">"a"</span>
|
785
|
+
684: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">"/dev/null"</span>, <span class="ruby-value str">"a"</span>
|
786
|
+
685: <span class="ruby-keyword kw">else</span>
|
787
|
+
686: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
|
788
|
+
687: <span class="ruby-keyword kw">end</span>
|
789
|
+
688: <span class="ruby-keyword kw">else</span>
|
790
|
+
689: <span class="ruby-identifier">puts</span> <span class="ruby-node">"!! daemonize option unavailable on #{RUBY_PLATFORM} platform."</span>
|
791
|
+
690: <span class="ruby-keyword kw">end</span>
|
792
|
+
691:
|
793
|
+
692: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</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">:pid</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-node">"#{Process.pid}"</span>) }
|
794
|
+
693: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</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">:pid</span>)) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</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">:pid</span>)) }
|
795
|
+
694: <span class="ruby-keyword kw">end</span>
|
796
|
+
695:
|
797
|
+
696: <span class="ruby-identifier">app</span> = <span class="ruby-keyword kw">nil</span>
|
798
|
+
697: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
799
|
+
698: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</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-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> ) }
|
800
|
+
699: <span class="ruby-keyword kw">else</span>
|
801
|
+
700: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>)
|
802
|
+
701: <span class="ruby-keyword kw">end</span>
|
803
|
+
702: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">CommonLogger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</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">:log</span>)) )
|
804
|
+
703:
|
805
|
+
704: <span class="ruby-keyword kw">if</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">:console</span>)
|
806
|
+
705: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"Run console..."</span>
|
807
|
+
706: <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">start</span>
|
808
|
+
707: <span class="ruby-identifier">exit</span>
|
809
|
+
708: <span class="ruby-keyword kw">end</span>
|
810
|
+
709:
|
811
|
+
710: <span class="ruby-comment cmt"># Start server</span>
|
812
|
+
711: <span class="ruby-keyword kw">case</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">:server</span>).<span class="ruby-identifier">to_s</span>
|
813
|
+
712: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"mongrel"</span>
|
814
|
+
713: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Starting Mongrel on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}"</span>
|
815
|
+
714: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Mongrel</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">></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">:port</span>), <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">></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">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
|
816
|
+
715: <span class="ruby-identifier">trap</span> <span class="ruby-value str">"SIGINT"</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">stop</span> }
|
817
|
+
716: }
|
818
|
+
717: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"webrick"</span>
|
819
|
+
718: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Starting WEBrick on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}"</span>
|
820
|
+
719: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">WEBrick</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">></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">:port</span>), <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">></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">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
|
821
|
+
720: <span class="ruby-identifier">trap</span> <span class="ruby-value str">"SIGINT"</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">shutdown</span> }
|
822
|
+
721: }
|
823
|
+
722: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"thin"</span>
|
824
|
+
723: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Starting Thin on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}"</span>
|
825
|
+
724: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Thin</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">></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">:port</span>), <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">></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">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
|
826
|
+
725: <span class="ruby-identifier">trap</span> <span class="ruby-value str">"SIGINT"</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">stop</span> }
|
827
|
+
726: }
|
828
|
+
727: <span class="ruby-keyword kw">end</span>
|
829
|
+
728: <span class="ruby-keyword kw">end</span>
|
830
|
+
729: <span class="ruby-keyword kw">end</span>
|
905
831
|
</pre>
|
906
832
|
</div>
|
907
833
|
</div>
|
@@ -924,10 +850,10 @@ Session hash
|
|
924
850
|
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
925
851
|
<div class="method-source-code" id="M000004-source">
|
926
852
|
<pre>
|
927
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
928
|
-
|
929
|
-
|
930
|
-
|
853
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 347</span>
|
854
|
+
347: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
|
855
|
+
348: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
|
856
|
+
349: <span class="ruby-keyword kw">end</span>
|
931
857
|
</pre>
|
932
858
|
</div>
|
933
859
|
</div>
|
@@ -938,78 +864,17 @@ Session hash
|
|
938
864
|
|
939
865
|
<div class="method-heading">
|
940
866
|
<a href="#M000012" class="method-signature">
|
941
|
-
<span class="method-name">set</span><span class="method-args">(
|
867
|
+
<span class="method-name">set</span><span class="method-args">(key, value, opts = {})</span>
|
942
868
|
</a>
|
943
869
|
</div>
|
944
870
|
|
945
871
|
<div class="method-description">
|
946
|
-
<p>
|
947
|
-
Set global configuration options
|
948
|
-
</p>
|
949
|
-
<p>
|
950
|
-
Options :
|
951
|
-
</p>
|
952
|
-
<ul>
|
953
|
-
<li><tt>:port</tt> = Listen port (default: 3000)
|
954
|
-
|
955
|
-
</li>
|
956
|
-
<li><tt>:host</tt> = Listen host (default: 0.0.0.0)
|
957
|
-
|
958
|
-
</li>
|
959
|
-
<li><tt>:server</tt> = Server type (webrick, mongrel or thin)
|
960
|
-
|
961
|
-
</li>
|
962
|
-
<li><tt>:log</tt> = Output logfile (default: STDOUT)
|
963
|
-
|
964
|
-
</li>
|
965
|
-
<li><tt>:<a href="Capcode.html#M000004">session</a></tt> = Session parameters.
|
966
|
-
See Rack::Session for more informations
|
967
|
-
|
968
|
-
</li>
|
969
|
-
<li><tt>:pid</tt> = PID file (default: $0.pid)
|
970
|
-
|
971
|
-
</li>
|
972
|
-
<li><tt>:daemonize</tt> = Daemonize <a
|
973
|
-
href="Capcode.html#M000010">application</a> (default: false)
|
974
|
-
|
975
|
-
</li>
|
976
|
-
<li><tt>:db_config</tt> = database configuration file (default: database.yml)
|
977
|
-
|
978
|
-
</li>
|
979
|
-
<li><tt>:static</tt> = Static directory (default: the working directory)
|
980
|
-
|
981
|
-
</li>
|
982
|
-
<li><tt>:root</tt> = Root directory (default: directory of the main.rb) —
|
983
|
-
This is also the working directory !
|
984
|
-
|
985
|
-
</li>
|
986
|
-
<li><tt>:verbose</tt> = <a href="Capcode.html#M000011">run</a> in verbose mode
|
987
|
-
|
988
|
-
</li>
|
989
|
-
<li><tt>:auth</tt> = HTTP Basic Authentication options
|
990
|
-
|
991
|
-
</li>
|
992
|
-
</ul>
|
993
|
-
<p>
|
994
|
-
It can exist specifics options depending on a renderer, a helper, …
|
995
|
-
</p>
|
996
|
-
<p>
|
997
|
-
Example :
|
998
|
-
</p>
|
999
|
-
<pre>
|
1000
|
-
module Capcode
|
1001
|
-
set :erb, "/path/to/erb/files"
|
1002
|
-
...
|
1003
|
-
end
|
1004
|
-
</pre>
|
1005
872
|
<p><a class="source-toggle" href="#"
|
1006
873
|
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
1007
874
|
<div class="method-source-code" id="M000012-source">
|
1008
875
|
<pre>
|
1009
|
-
|
1010
|
-
|
1011
|
-
28: <span class="ruby-identifier">config</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
1012
|
-
29: <span class="ruby-keyword kw">end</span>
|
876
|
+
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 3</span>
|
877
|
+
3: <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> = {}); <span class="ruby-constant">Configuration</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>); <span class="ruby-keyword kw">end</span>
|
1013
878
|
</pre>
|
1014
879
|
</div>
|
1015
880
|
</div>
|
@@ -1044,10 +909,10 @@ Example :
|
|
1044
909
|
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
1045
910
|
<div class="method-source-code" id="M000008-source">
|
1046
911
|
<pre>
|
1047
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
912
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 489</span>
|
913
|
+
489: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use</span>(<span class="ruby-identifier">middleware</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
914
|
+
490: <span class="ruby-identifier">middlewares</span> <span class="ruby-operator"><<</span> [<span class="ruby-identifier">middleware</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>]
|
915
|
+
491: <span class="ruby-keyword kw">end</span>
|
1051
916
|
</pre>
|
1052
917
|
</div>
|
1053
918
|
</div>
|