Capcode 0.8.7 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/README.rdoc +10 -1
  2. data/doc/rdoc/classes/Capcode.html +410 -390
  3. data/doc/rdoc/classes/Capcode/Helpers.html +146 -126
  4. data/doc/rdoc/created.rid +1 -1
  5. data/doc/rdoc/files/README_rdoc.html +26 -2
  6. data/doc/rdoc/files/lib/capcode/render/haml_rb.html +1 -1
  7. data/doc/rdoc/files/lib/capcode/render/json_rb.html +1 -1
  8. data/doc/rdoc/files/lib/capcode/render/markaby_rb.html +1 -1
  9. data/doc/rdoc/files/lib/capcode/render/sass_rb.html +1 -1
  10. data/doc/rdoc/files/lib/capcode/render/webdav_rb.html +1 -1
  11. data/doc/rdoc/files/lib/capcode_rb.html +1 -1
  12. data/doc/rdoc/fr_file_index.html +5 -0
  13. data/examples/blog-ar.rb +81 -0
  14. data/examples/blog-ar.yml +3 -0
  15. data/examples/blog-sq.rb +82 -0
  16. data/examples/blog-sq.yml +3 -0
  17. data/examples/mail/mail_html.rhtml +1 -0
  18. data/examples/mail/mail_text.rhtml +1 -0
  19. data/examples/mail/ok.rhtml +1 -0
  20. data/examples/mail/rubyfr.png +0 -0
  21. data/examples/mustache/with_class.mustache +8 -0
  22. data/examples/mustache/without_class.mustache +1 -0
  23. data/examples/render-binary.rb +46 -0
  24. data/examples/render-email.rb +68 -0
  25. data/examples/render-erb.rb +2 -0
  26. data/examples/render-mustache.rb +30 -0
  27. data/examples/render-redirect.rb +19 -0
  28. data/lib/capcode.rb +3 -0
  29. data/lib/capcode/base/ar.rb +54 -0
  30. data/lib/capcode/base/couchdb.rb +5 -1
  31. data/lib/capcode/base/dm.rb +5 -1
  32. data/lib/capcode/base/sq.rb +58 -0
  33. data/lib/capcode/core_ext.rb +1 -1
  34. data/lib/capcode/render/binary.rb +8 -0
  35. data/lib/capcode/render/email.rb +73 -0
  36. data/lib/capcode/render/haml.rb +5 -1
  37. data/lib/capcode/render/json.rb +5 -1
  38. data/lib/capcode/render/markaby.rb +5 -1
  39. data/lib/capcode/render/mustache.rb +37 -0
  40. data/lib/capcode/render/none.rb +7 -0
  41. data/lib/capcode/render/redirect.rb +7 -0
  42. data/lib/capcode/render/sass.rb +5 -1
  43. data/lib/capcode/render/webdav.rb +11 -7
  44. data/lib/capcode/version.rb +1 -1
  45. metadata +30 -3
  46. data/examples/my_blog.db +0 -0
@@ -12,8 +12,17 @@ Capcode is a web microframework
12
12
 
13
13
  == FEATURES/PROBLEMS:
14
14
 
15
+ === 0.8.8
16
+ * Add mustache renderer
17
+ * Add AcriveRecord support (see example blog-ar.rb)
18
+ * Add Sequel support (see example blog-sq.rb)
19
+ * Add Binary renderer (see example render-binary.rb)
20
+ * Add Mail renderer (see example render-mail.rb)
21
+ * Add Redirect renderer (see examples render-redirect.rb and render-mail.rb)
22
+ * Add "none" renderer (return a 204 status code)
23
+
15
24
  === 0.8.7
16
- * Route's captures are now passed to all methods in a coontroller
25
+ * Route's captures are now passed to all methods in a controller
17
26
  * Add :content_type option to renderers (see render-image.rb)
18
27
  * Add Capcode.set for configuration. So Capcode::Herpers#erb_path=, Capcode::Herpers#sass_path= and Capcode::Herpers#haml_path= are deprecated, you must now use `set :erb, ...', `set :sass, ...' and `set :haml, ...' (see render-erb.rb and render-haml_sass.rb)
19
28
  * Add Capcode.use to allow usage of Rack middlewares (see render-use.rb)
@@ -66,6 +66,14 @@
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>
69
77
  <br />
70
78
  <a href="../files/lib/capcode/render/erb_rb.html">
71
79
  lib/capcode/render/erb.rb
@@ -82,6 +90,18 @@
82
90
  <a href="../files/lib/capcode/render/markaby_rb.html">
83
91
  lib/capcode/render/markaby.rb
84
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>
85
105
  <br />
86
106
  <a href="../files/lib/capcode/render/sass_rb.html">
87
107
  lib/capcode/render/sass.rb
@@ -235,169 +255,169 @@ If the regexp in the route does not match, all arguments will be
235
255
  onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
236
256
  <div class="method-source-code" id="M000001-source">
237
257
  <pre>
238
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 302</span>
239
- 302: <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>
240
- 303: <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> {
241
- 304: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:__urls__</span>) {
242
- 305: <span class="ruby-comment cmt"># &lt; Route '/hello/world/([^\/]*)/id(\d*)', '/hello/(.*)', :agent =&gt; /Songbird (\d\.\d)[\d\/]*?/</span>
243
- 306: <span class="ruby-comment cmt"># # =&gt; [ {'/hello/world' =&gt; '([^\/]*)/id(\d*)', '/hello' =&gt; '(.*)'}, </span>
244
- 307: <span class="ruby-comment cmt"># 2, </span>
245
- 308: <span class="ruby-comment cmt"># &lt;Capcode::Klass&gt;, </span>
246
- 309: <span class="ruby-comment cmt"># {:agent =&gt; /Songbird (\d\.\d)[\d\/]*?/} ]</span>
247
- 310: <span class="ruby-identifier">hash_of_routes</span> = {}
248
- 311: <span class="ruby-identifier">max_captures_for_routes</span> = <span class="ruby-value">0</span>
249
- 312: <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>
250
- 313: <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>
251
- 314: <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> )
252
- 315: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span>
253
- 316: <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">&quot;Route `#{current_route_path}' already defined with regexp `#{hash_of_routes[current_route_path]}' !&quot;</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>)
254
- 317: <span class="ruby-identifier">hash_of_routes</span>[<span class="ruby-identifier">current_route_path</span>] = <span class="ruby-value str">''</span>
255
- 318: <span class="ruby-keyword kw">else</span>
256
- 319: <span class="ruby-identifier">_pre</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">pre_match</span>
257
- 320: <span class="ruby-identifier">_pre</span> = <span class="ruby-value str">&quot;/&quot;</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>
258
- 321: <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">&quot;Route `#{_pre}' already defined with regexp `#{hash_of_routes[_pre]}' !&quot;</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>)
259
- 322: <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>]
260
- 323: <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">&lt;</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>
261
- 324: <span class="ruby-keyword kw">end</span>
262
- 325: <span class="ruby-keyword kw">else</span>
263
- 326: <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">&quot;Bad route declaration !&quot;</span>, <span class="ruby-identifier">caller</span>
264
- 327: <span class="ruby-keyword kw">end</span>
265
- 328: <span class="ruby-keyword kw">end</span>
266
- 329: [<span class="ruby-identifier">hash_of_routes</span>, <span class="ruby-identifier">max_captures_for_routes</span>, <span class="ruby-keyword kw">self</span>]
267
- 330: }
268
- 331:
269
- 332: <span class="ruby-comment cmt"># Hash containing all the request parameters (GET or POST)</span>
270
- 333: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
271
- 334: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
272
- 335: <span class="ruby-keyword kw">end</span>
273
- 336:
274
- 337: <span class="ruby-comment cmt"># Hash containing all the environment variables</span>
275
- 338: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
276
- 339: <span class="ruby-ivar">@env</span>
277
- 340: <span class="ruby-keyword kw">end</span>
278
- 341:
279
- 342: <span class="ruby-comment cmt"># Session hash</span>
280
- 343: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
281
- 344: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
282
- 345: <span class="ruby-keyword kw">end</span>
283
- 346:
284
- 347: <span class="ruby-comment cmt"># Return the Rack::Request object</span>
285
- 348: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
286
- 349: <span class="ruby-ivar">@request</span>
287
- 350: <span class="ruby-keyword kw">end</span>
288
- 351:
289
- 352: <span class="ruby-comment cmt"># Return the Rack::Response object</span>
290
- 353: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
291
- 354: <span class="ruby-ivar">@response</span>
292
- 355: <span class="ruby-keyword kw">end</span>
293
- 356:
294
- 357: <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>
295
- 358: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">e</span>
296
- 359: <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>
297
- 360: <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>)
298
- 361:
299
- 362: <span class="ruby-comment cmt"># __k = self.class.to_s.split( /::/ )[-1].downcase.to_sym</span>
300
- 363: <span class="ruby-comment cmt"># @@__FILTERS.each do |f|</span>
301
- 364: <span class="ruby-comment cmt"># proc = f.delete(:action)</span>
302
- 365: <span class="ruby-comment cmt"># __run = true</span>
303
- 366: <span class="ruby-comment cmt"># if f[:only]</span>
304
- 367: <span class="ruby-comment cmt"># __run = f[:only].include?(__k)</span>
305
- 368: <span class="ruby-comment cmt"># end</span>
306
- 369: <span class="ruby-comment cmt"># if f[:except]</span>
307
- 370: <span class="ruby-comment cmt"># __run = !f[:except].include?(__k)</span>
258
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 305</span>
259
+ 305: <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>
260
+ 306: <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> {
261
+ 307: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:__urls__</span>) {
262
+ 308: <span class="ruby-comment cmt"># &lt; Route '/hello/world/([^\/]*)/id(\d*)', '/hello/(.*)', :agent =&gt; /Songbird (\d\.\d)[\d\/]*?/</span>
263
+ 309: <span class="ruby-comment cmt"># # =&gt; [ {'/hello/world' =&gt; '([^\/]*)/id(\d*)', '/hello' =&gt; '(.*)'}, </span>
264
+ 310: <span class="ruby-comment cmt"># 2, </span>
265
+ 311: <span class="ruby-comment cmt"># &lt;Capcode::Klass&gt;, </span>
266
+ 312: <span class="ruby-comment cmt"># {:agent =&gt; /Songbird (\d\.\d)[\d\/]*?/} ]</span>
267
+ 313: <span class="ruby-identifier">hash_of_routes</span> = {}
268
+ 314: <span class="ruby-identifier">max_captures_for_routes</span> = <span class="ruby-value">0</span>
269
+ 315: <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>
270
+ 316: <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>
271
+ 317: <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> )
272
+ 318: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span>
273
+ 319: <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">&quot;Route `#{current_route_path}' already defined with regexp `#{hash_of_routes[current_route_path]}' !&quot;</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>)
274
+ 320: <span class="ruby-identifier">hash_of_routes</span>[<span class="ruby-identifier">current_route_path</span>] = <span class="ruby-value str">''</span>
275
+ 321: <span class="ruby-keyword kw">else</span>
276
+ 322: <span class="ruby-identifier">_pre</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">pre_match</span>
277
+ 323: <span class="ruby-identifier">_pre</span> = <span class="ruby-value str">&quot;/&quot;</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>
278
+ 324: <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">&quot;Route `#{_pre}' already defined with regexp `#{hash_of_routes[_pre]}' !&quot;</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>)
279
+ 325: <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>]
280
+ 326: <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">&lt;</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>
281
+ 327: <span class="ruby-keyword kw">end</span>
282
+ 328: <span class="ruby-keyword kw">else</span>
283
+ 329: <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">&quot;Bad route declaration !&quot;</span>, <span class="ruby-identifier">caller</span>
284
+ 330: <span class="ruby-keyword kw">end</span>
285
+ 331: <span class="ruby-keyword kw">end</span>
286
+ 332: [<span class="ruby-identifier">hash_of_routes</span>, <span class="ruby-identifier">max_captures_for_routes</span>, <span class="ruby-keyword kw">self</span>]
287
+ 333: }
288
+ 334:
289
+ 335: <span class="ruby-comment cmt"># Hash containing all the request parameters (GET or POST)</span>
290
+ 336: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
291
+ 337: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
292
+ 338: <span class="ruby-keyword kw">end</span>
293
+ 339:
294
+ 340: <span class="ruby-comment cmt"># Hash containing all the environment variables</span>
295
+ 341: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
296
+ 342: <span class="ruby-ivar">@env</span>
297
+ 343: <span class="ruby-keyword kw">end</span>
298
+ 344:
299
+ 345: <span class="ruby-comment cmt"># Session hash</span>
300
+ 346: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
301
+ 347: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
302
+ 348: <span class="ruby-keyword kw">end</span>
303
+ 349:
304
+ 350: <span class="ruby-comment cmt"># Return the Rack::Request object</span>
305
+ 351: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
306
+ 352: <span class="ruby-ivar">@request</span>
307
+ 353: <span class="ruby-keyword kw">end</span>
308
+ 354:
309
+ 355: <span class="ruby-comment cmt"># Return the Rack::Response object</span>
310
+ 356: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
311
+ 357: <span class="ruby-ivar">@response</span>
312
+ 358: <span class="ruby-keyword kw">end</span>
313
+ 359:
314
+ 360: <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>
315
+ 361: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">e</span>
316
+ 362: <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>
317
+ 363: <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>)
318
+ 364:
319
+ 365: <span class="ruby-comment cmt"># __k = self.class.to_s.split( /::/ )[-1].downcase.to_sym</span>
320
+ 366: <span class="ruby-comment cmt"># @@__FILTERS.each do |f|</span>
321
+ 367: <span class="ruby-comment cmt"># proc = f.delete(:action)</span>
322
+ 368: <span class="ruby-comment cmt"># __run = true</span>
323
+ 369: <span class="ruby-comment cmt"># if f[:only]</span>
324
+ 370: <span class="ruby-comment cmt"># __run = f[:only].include?(__k)</span>
308
325
  371: <span class="ruby-comment cmt"># end</span>
309
- 372: <span class="ruby-comment cmt"># </span>
310
- 373: <span class="ruby-comment cmt"># # proc.call(self) if __run</span>
311
- 374: <span class="ruby-comment cmt"># puts &quot;call #{proc} for #{__k}&quot;</span>
312
- 375: <span class="ruby-comment cmt"># end</span>
313
- 376:
314
- 377: <span class="ruby-comment cmt"># Check authz</span>
315
- 378: <span class="ruby-identifier">authz_options</span> = <span class="ruby-keyword kw">nil</span>
316
- 379: <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">&gt;</span> <span class="ruby-value">0</span>
317
- 380: <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>
318
- 381: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">authz_options</span>.<span class="ruby-identifier">nil?</span>
319
- 382: <span class="ruby-identifier">route</span> = <span class="ruby-keyword kw">nil</span>
320
- 383:
321
- 384: <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>
322
- 385: <span class="ruby-identifier">regexp</span> = <span class="ruby-node">&quot;^#{r.gsub(/\/$/, &quot;&quot;)}([/]{1}.*)?$&quot;</span>
323
- 386: <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> )
324
- 387: <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">&gt;</span> <span class="ruby-identifier">route</span>.<span class="ruby-identifier">size</span>
325
- 388: <span class="ruby-identifier">route</span> = <span class="ruby-identifier">r</span>
326
- 389: <span class="ruby-identifier">authz_options</span> = <span class="ruby-identifier">o</span>
327
- 390: <span class="ruby-keyword kw">end</span>
328
- 391: <span class="ruby-keyword kw">end</span>
329
- 392: <span class="ruby-keyword kw">end</span>
330
- 393: <span class="ruby-keyword kw">end</span>
331
- 394: <span class="ruby-keyword kw">end</span>
332
- 395:
333
- 396: <span class="ruby-identifier">r</span> = <span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:halt</span>) {
334
- 397: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">authz_options</span>.<span class="ruby-identifier">nil?</span>
335
- 398: <span class="ruby-identifier">http_authentication</span>( <span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:type</span>], <span class="ruby-identifier">:realm</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:realm</span>], <span class="ruby-identifier">:opaque</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:realm</span>] ) {
336
- 399: <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:autz</span>]
337
- 400: }
338
- 401: <span class="ruby-keyword kw">end</span>
339
- 402:
340
- 403: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
341
- 404: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
342
- 405: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
343
- 406:
344
- 407: <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">&quot;&quot;</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-value str">&quot;/&quot;</span> )
345
- 408: <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>
346
- 409: <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">&quot;&quot;</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-value str">&quot;/&quot;</span> )
347
- 410: <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>
348
- 411: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
349
- 412: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
350
- 413: <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">&gt;</span> <span class="ruby-identifier">diffNArgs</span>
351
- 414: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
352
- 415: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
353
- 416: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
354
- 417: <span class="ruby-keyword kw">end</span>
355
- 418: <span class="ruby-keyword kw">end</span>
356
- 419:
357
- 420: <span class="ruby-keyword kw">end</span>
358
- 421:
359
- 422: <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>]
360
- 423: <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>] )
361
- 424: <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">&quot;^#{finalPath}&quot;</span> ), <span class="ruby-value str">&quot;&quot;</span> ).<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ) )
362
- 425: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
363
- 426: <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">&quot;Path info `#{@request.path_info}' does not match route regexp `#{regexp.source}'&quot;</span>
364
- 427: <span class="ruby-keyword kw">else</span>
365
- 428: <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> }
366
- 429: <span class="ruby-keyword kw">end</span>
367
- 430:
368
- 431: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">nargs</span>
369
- 432: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
370
- 433: <span class="ruby-keyword kw">end</span>
371
- 434:
372
- 435: <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
373
- 436: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>
374
- 437: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
375
- 438: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
376
- 439: <span class="ruby-identifier">_method</span> = <span class="ruby-identifier">params</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-value str">&quot;_method&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-value str">&quot;post&quot;</span> }
377
- 440: <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> )
378
- 441: <span class="ruby-keyword kw">else</span>
379
- 442: <span class="ruby-identifier">_method</span> = <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
326
+ 372: <span class="ruby-comment cmt"># if f[:except]</span>
327
+ 373: <span class="ruby-comment cmt"># __run = !f[:except].include?(__k)</span>
328
+ 374: <span class="ruby-comment cmt"># end</span>
329
+ 375: <span class="ruby-comment cmt"># </span>
330
+ 376: <span class="ruby-comment cmt"># # proc.call(self) if __run</span>
331
+ 377: <span class="ruby-comment cmt"># puts &quot;call #{proc} for #{__k}&quot;</span>
332
+ 378: <span class="ruby-comment cmt"># end</span>
333
+ 379:
334
+ 380: <span class="ruby-comment cmt"># Check authz</span>
335
+ 381: <span class="ruby-identifier">authz_options</span> = <span class="ruby-keyword kw">nil</span>
336
+ 382: <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">&gt;</span> <span class="ruby-value">0</span>
337
+ 383: <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>
338
+ 384: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">authz_options</span>.<span class="ruby-identifier">nil?</span>
339
+ 385: <span class="ruby-identifier">route</span> = <span class="ruby-keyword kw">nil</span>
340
+ 386:
341
+ 387: <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>
342
+ 388: <span class="ruby-identifier">regexp</span> = <span class="ruby-node">&quot;^#{r.gsub(/\/$/, &quot;&quot;)}([/]{1}.*)?$&quot;</span>
343
+ 389: <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> )
344
+ 390: <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">&gt;</span> <span class="ruby-identifier">route</span>.<span class="ruby-identifier">size</span>
345
+ 391: <span class="ruby-identifier">route</span> = <span class="ruby-identifier">r</span>
346
+ 392: <span class="ruby-identifier">authz_options</span> = <span class="ruby-identifier">o</span>
347
+ 393: <span class="ruby-keyword kw">end</span>
348
+ 394: <span class="ruby-keyword kw">end</span>
349
+ 395: <span class="ruby-keyword kw">end</span>
350
+ 396: <span class="ruby-keyword kw">end</span>
351
+ 397: <span class="ruby-keyword kw">end</span>
352
+ 398:
353
+ 399: <span class="ruby-identifier">r</span> = <span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:halt</span>) {
354
+ 400: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">authz_options</span>.<span class="ruby-identifier">nil?</span>
355
+ 401: <span class="ruby-identifier">http_authentication</span>( <span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:type</span>], <span class="ruby-identifier">:realm</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:realm</span>], <span class="ruby-identifier">:opaque</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:realm</span>] ) {
356
+ 402: <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:autz</span>]
357
+ 403: }
358
+ 404: <span class="ruby-keyword kw">end</span>
359
+ 405:
360
+ 406: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
361
+ 407: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
362
+ 408: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
363
+ 409:
364
+ 410: <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">&quot;&quot;</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-value str">&quot;/&quot;</span> )
365
+ 411: <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>
366
+ 412: <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">&quot;&quot;</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-value str">&quot;/&quot;</span> )
367
+ 413: <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>
368
+ 414: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
369
+ 415: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
370
+ 416: <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">&gt;</span> <span class="ruby-identifier">diffNArgs</span>
371
+ 417: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
372
+ 418: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
373
+ 419: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
374
+ 420: <span class="ruby-keyword kw">end</span>
375
+ 421: <span class="ruby-keyword kw">end</span>
376
+ 422:
377
+ 423: <span class="ruby-keyword kw">end</span>
378
+ 424:
379
+ 425: <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>]
380
+ 426: <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>] )
381
+ 427: <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">&quot;^#{finalPath}&quot;</span> ), <span class="ruby-value str">&quot;&quot;</span> ).<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ) )
382
+ 428: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
383
+ 429: <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">&quot;Path info `#{@request.path_info}' does not match route regexp `#{regexp.source}'&quot;</span>
384
+ 430: <span class="ruby-keyword kw">else</span>
385
+ 431: <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> }
386
+ 432: <span class="ruby-keyword kw">end</span>
387
+ 433:
388
+ 434: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">nargs</span>
389
+ 435: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
390
+ 436: <span class="ruby-keyword kw">end</span>
391
+ 437:
392
+ 438: <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
393
+ 439: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>
394
+ 440: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
395
+ 441: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
396
+ 442: <span class="ruby-identifier">_method</span> = <span class="ruby-identifier">params</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-value str">&quot;_method&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-value str">&quot;post&quot;</span> }
380
397
  443: <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> )
381
- 444: <span class="ruby-keyword kw">end</span>
382
- 445: }
383
- 446: <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>)
384
- 447: <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>
385
- 448: <span class="ruby-comment cmt">#r[1].each do |k,v|</span>
386
- 449: <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>
387
- 450: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
388
- 451: <span class="ruby-keyword kw">end</span>
389
- 452: <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>
390
- 453: <span class="ruby-keyword kw">else</span>
391
- 454: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
392
- 455: <span class="ruby-keyword kw">end</span>
393
- 456:
394
- 457: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
395
- 458: <span class="ruby-keyword kw">end</span>
396
- 459:
397
- 460: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
398
- 461: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>
399
- 462: }
400
- 463: <span class="ruby-keyword kw">end</span>
398
+ 444: <span class="ruby-keyword kw">else</span>
399
+ 445: <span class="ruby-identifier">_method</span> = <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
400
+ 446: <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> )
401
+ 447: <span class="ruby-keyword kw">end</span>
402
+ 448: }
403
+ 449: <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>)
404
+ 450: <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>
405
+ 451: <span class="ruby-comment cmt">#r[1].each do |k,v|</span>
406
+ 452: <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>
407
+ 453: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
408
+ 454: <span class="ruby-keyword kw">end</span>
409
+ 455: <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>
410
+ 456: <span class="ruby-keyword kw">else</span>
411
+ 457: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
412
+ 458: <span class="ruby-keyword kw">end</span>
413
+ 459:
414
+ 460: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
415
+ 461: <span class="ruby-keyword kw">end</span>
416
+ 462:
417
+ 463: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
418
+ 464: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>
419
+ 465: }
420
+ 466: <span class="ruby-keyword kw">end</span>
401
421
  </pre>
402
422
  </div>
403
423
  </div>
@@ -427,71 +447,71 @@ href="Capcode.html#M000012">set</a> globally
427
447
  onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
428
448
  <div class="method-source-code" id="M000010-source">
429
449
  <pre>
430
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 549</span>
431
- 549: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">application</span>( <span class="ruby-identifier">args</span> = {} )
432
- 550: <span class="ruby-identifier">conf</span> = <span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
433
- 551:
434
- 552: <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>
435
- 553: <span class="ruby-keyword kw">begin</span>
436
- 554: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;Capcode::#{k}.public_methods(true).include?( '__urls__' )&quot;</span>
437
- 555: <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">&quot;Capcode::#{k}.__urls__&quot;</span>
438
- 556: <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>
439
- 557: <span class="ruby-comment cmt">#raise Capcode::RouteError, &quot;Route `#{current_route_path}' already define !&quot;, caller if @@__ROUTES.keys.include?(current_route_path)</span>
440
- 558: <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">&quot;Route `#{current_route_path}' already define !&quot;</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>)
441
- 559: <span class="ruby-comment cmt">#@@__ROUTES[current_route_path] = klass.new</span>
442
- 560: <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>
443
- 561: <span class="ruby-keyword kw">end</span>
444
- 562: <span class="ruby-keyword kw">end</span>
445
- 563: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
446
- 564: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
447
- 565: <span class="ruby-keyword kw">end</span>
448
- 566: <span class="ruby-keyword kw">end</span>
449
- 567:
450
- 568: <span class="ruby-comment cmt"># Set Static directory</span>
451
- 569: <span class="ruby-comment cmt">#@@__STATIC_DIR = (conf[:static][0].chr == &quot;/&quot;)?conf[:static]:&quot;/&quot;+conf[:static] unless conf[:static].nil?</span>
452
- 570: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span> = (<span class="ruby-identifier">conf</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">&quot;/&quot;</span>)<span class="ruby-operator">?</span><span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>]<span class="ruby-operator">:</span><span class="ruby-value str">&quot;/&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>].<span class="ruby-identifier">nil?</span>
453
- 571:
454
- 572: <span class="ruby-comment cmt"># Initialize Rack App</span>
455
- 573: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;** Map routes.&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>]
456
- 574: <span class="ruby-comment cmt">#app = Rack::URLMap.new(@@__ROUTES)</span>
457
- 575: <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>)
458
- 576: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Initialize static directory (#{conf[:static]})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>]
459
- 577: <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>(
460
- 578: <span class="ruby-identifier">app</span>,
461
- 579: <span class="ruby-comment cmt">#:urls =&gt; [@@__STATIC_DIR], </span>
462
- 580: <span class="ruby-identifier">:urls</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>],
463
- 581: <span class="ruby-identifier">:root</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>])
464
- 582: ) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>].<span class="ruby-identifier">nil?</span>
465
- 583: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;** Initialize session&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>]
466
- 584: <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-identifier">conf</span>[<span class="ruby-identifier">:session</span>] )
467
- 585: <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>)
468
- 586: <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>)
469
- 587: <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>)
470
- 588: <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>)
471
- 589: <span class="ruby-comment cmt">#app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
472
- 590: <span class="ruby-comment cmt"># app = Rack::CommonLogger.new( app, Logger.new(conf[:log]) )</span>
473
- 591:
474
- 592: <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>
475
- 593: <span class="ruby-identifier">middleware</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span> = <span class="ruby-identifier">mw</span>
476
- 594: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Load middleware #{middleware}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>]
477
- 595: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
478
- 596: <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">&amp;</span><span class="ruby-identifier">block</span> )
479
- 597: <span class="ruby-keyword kw">else</span>
480
- 598: <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> )
481
- 599: <span class="ruby-keyword kw">end</span>
482
- 600: <span class="ruby-keyword kw">end</span>
483
- 601:
484
- 602: <span class="ruby-comment cmt"># Start database</span>
485
- 603: <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">&quot;db_connect&quot;</span>
486
- 604: <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>] )
487
- 605: <span class="ruby-keyword kw">end</span>
488
- 606:
489
- 607: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
490
- 608: <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> )
491
- 609: <span class="ruby-keyword kw">end</span>
492
- 610:
493
- 611: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">app</span>
494
- 612: <span class="ruby-keyword kw">end</span>
450
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 552</span>
451
+ 552: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">application</span>( <span class="ruby-identifier">args</span> = {} )
452
+ 553: <span class="ruby-identifier">conf</span> = <span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
453
+ 554:
454
+ 555: <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>
455
+ 556: <span class="ruby-keyword kw">begin</span>
456
+ 557: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;Capcode::#{k}.public_methods(true).include?( '__urls__' )&quot;</span>
457
+ 558: <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">&quot;Capcode::#{k}.__urls__&quot;</span>
458
+ 559: <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>
459
+ 560: <span class="ruby-comment cmt">#raise Capcode::RouteError, &quot;Route `#{current_route_path}' already define !&quot;, caller if @@__ROUTES.keys.include?(current_route_path)</span>
460
+ 561: <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">&quot;Route `#{current_route_path}' already define !&quot;</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>)
461
+ 562: <span class="ruby-comment cmt">#@@__ROUTES[current_route_path] = klass.new</span>
462
+ 563: <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>
463
+ 564: <span class="ruby-keyword kw">end</span>
464
+ 565: <span class="ruby-keyword kw">end</span>
465
+ 566: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
466
+ 567: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
467
+ 568: <span class="ruby-keyword kw">end</span>
468
+ 569: <span class="ruby-keyword kw">end</span>
469
+ 570:
470
+ 571: <span class="ruby-comment cmt"># Set Static directory</span>
471
+ 572: <span class="ruby-comment cmt">#@@__STATIC_DIR = (conf[:static][0].chr == &quot;/&quot;)?conf[:static]:&quot;/&quot;+conf[:static] unless conf[:static].nil?</span>
472
+ 573: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span> = (<span class="ruby-identifier">conf</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">&quot;/&quot;</span>)<span class="ruby-operator">?</span><span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>]<span class="ruby-operator">:</span><span class="ruby-value str">&quot;/&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>].<span class="ruby-identifier">nil?</span>
473
+ 574:
474
+ 575: <span class="ruby-comment cmt"># Initialize Rack App</span>
475
+ 576: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;** Map routes.&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>]
476
+ 577: <span class="ruby-comment cmt">#app = Rack::URLMap.new(@@__ROUTES)</span>
477
+ 578: <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>)
478
+ 579: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Initialize static directory (#{conf[:static]})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>]
479
+ 580: <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>(
480
+ 581: <span class="ruby-identifier">app</span>,
481
+ 582: <span class="ruby-comment cmt">#:urls =&gt; [@@__STATIC_DIR], </span>
482
+ 583: <span class="ruby-identifier">:urls</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>],
483
+ 584: <span class="ruby-identifier">:root</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>])
484
+ 585: ) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>].<span class="ruby-identifier">nil?</span>
485
+ 586: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;** Initialize session&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>]
486
+ 587: <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-identifier">conf</span>[<span class="ruby-identifier">:session</span>] )
487
+ 588: <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>)
488
+ 589: <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>)
489
+ 590: <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>)
490
+ 591: <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>)
491
+ 592: <span class="ruby-comment cmt">#app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
492
+ 593: <span class="ruby-comment cmt"># app = Rack::CommonLogger.new( app, Logger.new(conf[:log]) )</span>
493
+ 594:
494
+ 595: <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>
495
+ 596: <span class="ruby-identifier">middleware</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span> = <span class="ruby-identifier">mw</span>
496
+ 597: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Load middleware #{middleware}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>]
497
+ 598: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
498
+ 599: <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">&amp;</span><span class="ruby-identifier">block</span> )
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">&quot;db_connect&quot;</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>
495
515
  </pre>
496
516
  </div>
497
517
  </div>
@@ -537,10 +557,10 @@ Hash containing all the environment variables
537
557
  onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
538
558
  <div class="method-source-code" id="M000003-source">
539
559
  <pre>
540
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 338</span>
541
- 338: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
542
- 339: <span class="ruby-ivar">@env</span>
543
- 340: <span class="ruby-keyword kw">end</span>
560
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 341</span>
561
+ 341: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
562
+ 342: <span class="ruby-ivar">@env</span>
563
+ 343: <span class="ruby-keyword kw">end</span>
544
564
  </pre>
545
565
  </div>
546
566
  </div>
@@ -595,27 +615,27 @@ The block must return a Hash of username =&gt; password like that :
595
615
  onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
596
616
  <div class="method-source-code" id="M000009-source">
597
617
  <pre>
598
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 506</span>
599
- 506: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">http_authentication</span>( <span class="ruby-identifier">opts</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> )
600
- 507: <span class="ruby-identifier">options</span> = {
601
- 508: <span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:basic</span>,
602
- 509: <span class="ruby-identifier">:realm</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;Capcode.app&quot;</span>,
603
- 510: <span class="ruby-identifier">:opaque</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;opaque&quot;</span>,
604
- 511: <span class="ruby-identifier">:routes</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;/&quot;</span>
605
- 512: }.<span class="ruby-identifier">merge</span>( <span class="ruby-identifier">opts</span> )
606
- 513:
607
- 514: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:autz</span>] = <span class="ruby-identifier">b</span>.<span class="ruby-identifier">call</span>()
608
- 515:
609
- 516: <span class="ruby-ivar">@__auth__</span> <span class="ruby-operator">||=</span> {}
610
- 517:
611
- 518: <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>
612
- 519: <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>
613
- 520: <span class="ruby-ivar">@__auth__</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-identifier">options</span>
614
- 521: <span class="ruby-keyword kw">end</span>
615
- 522: <span class="ruby-keyword kw">else</span>
616
- 523: <span class="ruby-ivar">@__auth__</span>[<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:routes</span>]] = <span class="ruby-identifier">options</span>
617
- 524: <span class="ruby-keyword kw">end</span>
618
- 525: <span class="ruby-keyword kw">end</span>
618
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 509</span>
619
+ 509: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">http_authentication</span>( <span class="ruby-identifier">opts</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> )
620
+ 510: <span class="ruby-identifier">options</span> = {
621
+ 511: <span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:basic</span>,
622
+ 512: <span class="ruby-identifier">:realm</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;Capcode.app&quot;</span>,
623
+ 513: <span class="ruby-identifier">:opaque</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;opaque&quot;</span>,
624
+ 514: <span class="ruby-identifier">:routes</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;/&quot;</span>
625
+ 515: }.<span class="ruby-identifier">merge</span>( <span class="ruby-identifier">opts</span> )
626
+ 516:
627
+ 517: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:autz</span>] = <span class="ruby-identifier">b</span>.<span class="ruby-identifier">call</span>()
628
+ 518:
629
+ 519: <span class="ruby-ivar">@__auth__</span> <span class="ruby-operator">||=</span> {}
630
+ 520:
631
+ 521: <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>
632
+ 522: <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>
633
+ 523: <span class="ruby-ivar">@__auth__</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-identifier">options</span>
634
+ 524: <span class="ruby-keyword kw">end</span>
635
+ 525: <span class="ruby-keyword kw">else</span>
636
+ 526: <span class="ruby-ivar">@__auth__</span>[<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:routes</span>]] = <span class="ruby-identifier">options</span>
637
+ 527: <span class="ruby-keyword kw">end</span>
638
+ 528: <span class="ruby-keyword kw">end</span>
619
639
  </pre>
620
640
  </div>
621
641
  </div>
@@ -644,11 +664,11 @@ Rack or What you want Helper
644
664
  onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
645
665
  <div class="method-source-code" id="M000007-source">
646
666
  <pre>
647
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 470</span>
648
- 470: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map</span>( <span class="ruby-identifier">route</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> )
649
- 471: <span class="ruby-comment cmt">#@@__ROUTES[route] = yield</span>
650
- 472: <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>
651
- 473: <span class="ruby-keyword kw">end</span>
667
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 473</span>
668
+ 473: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map</span>( <span class="ruby-identifier">route</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> )
669
+ 474: <span class="ruby-comment cmt">#@@__ROUTES[route] = yield</span>
670
+ 475: <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>
671
+ 476: <span class="ruby-keyword kw">end</span>
652
672
  </pre>
653
673
  </div>
654
674
  </div>
@@ -672,10 +692,10 @@ parameters (GET or POST)
672
692
  onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
673
693
  <div class="method-source-code" id="M000002-source">
674
694
  <pre>
675
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 333</span>
676
- 333: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
677
- 334: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
678
- 335: <span class="ruby-keyword kw">end</span>
695
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 336</span>
696
+ 336: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
697
+ 337: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
698
+ 338: <span class="ruby-keyword kw">end</span>
679
699
  </pre>
680
700
  </div>
681
701
  </div>
@@ -698,10 +718,10 @@ Return the Rack::Request object
698
718
  onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
699
719
  <div class="method-source-code" id="M000005-source">
700
720
  <pre>
701
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 348</span>
702
- 348: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
703
- 349: <span class="ruby-ivar">@request</span>
704
- 350: <span class="ruby-keyword kw">end</span>
721
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 351</span>
722
+ 351: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
723
+ 352: <span class="ruby-ivar">@request</span>
724
+ 353: <span class="ruby-keyword kw">end</span>
705
725
  </pre>
706
726
  </div>
707
727
  </div>
@@ -724,10 +744,10 @@ Return the Rack::Response object
724
744
  onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
725
745
  <div class="method-source-code" id="M000006-source">
726
746
  <pre>
727
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 353</span>
728
- 353: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
729
- 354: <span class="ruby-ivar">@response</span>
730
- 355: <span class="ruby-keyword kw">end</span>
747
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 356</span>
748
+ 356: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
749
+ 357: <span class="ruby-ivar">@response</span>
750
+ 358: <span class="ruby-keyword kw">end</span>
731
751
  </pre>
732
752
  </div>
733
753
  </div>
@@ -757,126 +777,126 @@ href="Capcode.html#M000012">set</a> globally
757
777
  onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
758
778
  <div class="method-source-code" id="M000011-source">
759
779
  <pre>
760
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 619</span>
761
- 619: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
762
- 620: <span class="ruby-identifier">conf</span> = <span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
763
- 621:
764
- 622: <span class="ruby-comment cmt"># Parse options</span>
765
- 623: <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>
766
- 624: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;Usage: #{File.basename($0)} [options]&quot;</span>
767
- 625: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
768
- 626: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Specific options:&quot;</span>
769
- 627:
770
- 628: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-C&quot;</span>, <span class="ruby-value str">&quot;--console&quot;</span>, <span class="ruby-value str">&quot;Run in console mode with IRB (default: false)&quot;</span> ) {
771
- 629: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:console</span>] = <span class="ruby-keyword kw">true</span>
772
- 630: }
773
- 631: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-h&quot;</span>, <span class="ruby-value str">&quot;--host HOSTNAME&quot;</span>, <span class="ruby-node">&quot;Host for web server to bind to (default: #{conf[:host]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
774
- 632: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>] = <span class="ruby-identifier">h</span>
780
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 622</span>
781
+ 622: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
782
+ 623: <span class="ruby-identifier">conf</span> = <span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
783
+ 624:
784
+ 625: <span class="ruby-comment cmt"># Parse options</span>
785
+ 626: <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>
786
+ 627: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;Usage: #{File.basename($0)} [options]&quot;</span>
787
+ 628: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
788
+ 629: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Specific options:&quot;</span>
789
+ 630:
790
+ 631: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-C&quot;</span>, <span class="ruby-value str">&quot;--console&quot;</span>, <span class="ruby-value str">&quot;Run in console mode with IRB (default: false)&quot;</span> ) {
791
+ 632: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:console</span>] = <span class="ruby-keyword kw">true</span>
775
792
  633: }
776
- 634: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-p&quot;</span>, <span class="ruby-value str">&quot;--port NUM&quot;</span>, <span class="ruby-node">&quot;Port for web server (default: #{conf[:port]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
777
- 635: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>] = <span class="ruby-identifier">p</span>
793
+ 634: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-h&quot;</span>, <span class="ruby-value str">&quot;--host HOSTNAME&quot;</span>, <span class="ruby-node">&quot;Host for web server to bind to (default: #{conf[:host]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
794
+ 635: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>] = <span class="ruby-identifier">h</span>
778
795
  636: }
779
- 637: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-d&quot;</span>, <span class="ruby-value str">&quot;--daemonize [true|false]&quot;</span>, <span class="ruby-node">&quot;Daemonize (default: #{conf[:daemonize]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
780
- 638: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>] = <span class="ruby-identifier">d</span>
796
+ 637: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-p&quot;</span>, <span class="ruby-value str">&quot;--port NUM&quot;</span>, <span class="ruby-node">&quot;Port for web server (default: #{conf[:port]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
797
+ 638: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>] = <span class="ruby-identifier">p</span>
781
798
  639: }
782
- 640: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-r&quot;</span>, <span class="ruby-value str">&quot;--root PATH&quot;</span>, <span class="ruby-node">&quot;Working directory (default: #{conf[:root]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
783
- 641: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>] = <span class="ruby-identifier">w</span>
799
+ 640: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-d&quot;</span>, <span class="ruby-value str">&quot;--daemonize [true|false]&quot;</span>, <span class="ruby-node">&quot;Daemonize (default: #{conf[:daemonize]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
800
+ 641: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>] = <span class="ruby-identifier">d</span>
784
801
  642: }
785
- 643: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-s&quot;</span>, <span class="ruby-value str">&quot;--static PATH&quot;</span>, <span class="ruby-node">&quot;Static directory -- relative to the root directory (default: #{conf[:static]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
786
- 644: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>] = <span class="ruby-identifier">r</span>
802
+ 643: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-r&quot;</span>, <span class="ruby-value str">&quot;--root PATH&quot;</span>, <span class="ruby-node">&quot;Working directory (default: #{conf[:root]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
803
+ 644: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>] = <span class="ruby-identifier">w</span>
787
804
  645: }
788
- 646:
789
- 647: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
790
- 648: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Common options:&quot;</span>
805
+ 646: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-s&quot;</span>, <span class="ruby-value str">&quot;--static PATH&quot;</span>, <span class="ruby-node">&quot;Static directory -- relative to the root directory (default: #{conf[:static]})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
806
+ 647: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:static</span>] = <span class="ruby-identifier">r</span>
807
+ 648: }
791
808
  649:
792
- 650: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-?&quot;</span>, <span class="ruby-value str">&quot;--help&quot;</span>, <span class="ruby-value str">&quot;Show this message&quot;</span>) <span class="ruby-keyword kw">do</span>
793
- 651: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>
794
- 652: <span class="ruby-identifier">exit</span>
795
- 653: <span class="ruby-keyword kw">end</span>
796
- 654: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-v&quot;</span>, <span class="ruby-value str">&quot;--version&quot;</span>, <span class="ruby-value str">&quot;Show versions&quot;</span>) <span class="ruby-keyword kw">do</span>
797
- 655: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Capcode version #{Capcode::CAPCOD_VERION} (ruby v#{RUBY_VERSION})&quot;</span>
798
- 656: <span class="ruby-identifier">exit</span>
799
- 657: <span class="ruby-keyword kw">end</span>
800
- 658: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>( <span class="ruby-value str">&quot;-V&quot;</span>, <span class="ruby-value str">&quot;--verbose&quot;</span>, <span class="ruby-value str">&quot;Run in verbose mode&quot;</span> ) <span class="ruby-keyword kw">do</span>
801
- 659: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>] = <span class="ruby-keyword kw">true</span>
802
- 660: <span class="ruby-keyword kw">end</span>
803
- 661: <span class="ruby-keyword kw">end</span>
804
- 662:
805
- 663: <span class="ruby-keyword kw">begin</span>
806
- 664: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span> <span class="ruby-constant">ARGV</span>
807
- 665: <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">&gt;</span> <span class="ruby-identifier">ex</span>
808
- 666: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! #{ex.message}&quot;</span>
809
- 667: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** use `#{File.basename($0)} --help` for more details...&quot;</span>
810
- 668: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
811
- 669: <span class="ruby-keyword kw">end</span>
812
- 670:
813
- 671: <span class="ruby-comment cmt"># Run in the Working directory</span>
814
- 672: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Go on root directory (#{File.expand_path(conf[:root])})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>]
815
- 673: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>] ) <span class="ruby-keyword kw">do</span>
816
- 674:
817
- 675: <span class="ruby-comment cmt"># Check that mongrel exists </span>
818
- 676: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
819
- 677: <span class="ruby-keyword kw">begin</span>
820
- 678: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
821
- 679: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;mongrel&quot;</span>
822
- 680: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
823
- 681: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
824
- 682: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;webrick&quot;</span>
825
- 683: <span class="ruby-keyword kw">end</span>
826
- 684: <span class="ruby-keyword kw">end</span>
827
- 685:
828
- 686: <span class="ruby-comment cmt"># From rackup !!!</span>
829
- 687: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>]
830
- 688: <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>
831
- 689: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">RUBY_VERSION</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value str">&quot;1.9&quot;</span>
832
- 690: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
833
- 691: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
834
- 692: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
835
- 693: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
836
- 694: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
837
- 695: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
838
- 696: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>, <span class="ruby-value str">&quot;a&quot;</span>
839
- 697: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>, <span class="ruby-value str">&quot;a&quot;</span>
840
- 698: <span class="ruby-keyword kw">else</span>
841
- 699: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
842
- 700: <span class="ruby-keyword kw">end</span>
843
- 701: <span class="ruby-keyword kw">else</span>
844
- 702: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! daemonize option unavailable on #{RUBY_PLATFORM} platform.&quot;</span>
845
- 703: <span class="ruby-keyword kw">end</span>
846
- 704:
847
- 705: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">conf</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">&quot;#{Process.pid}&quot;</span>) }
848
- 706: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">conf</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-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) }
849
- 707: <span class="ruby-keyword kw">end</span>
850
- 708:
851
- 709: <span class="ruby-identifier">app</span> = <span class="ruby-keyword kw">nil</span>
852
- 710: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
853
- 711: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-identifier">conf</span>) { <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> ) }
854
- 712: <span class="ruby-keyword kw">else</span>
855
- 713: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-identifier">conf</span>)
856
- 714: <span class="ruby-keyword kw">end</span>
857
- 715: <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-identifier">conf</span>[<span class="ruby-identifier">:log</span>]) )
858
- 716:
859
- 717: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:console</span>]
860
- 718: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Run console...&quot;</span>
861
- 719: <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">start</span>
862
- 720: <span class="ruby-identifier">exit</span>
863
- 721: <span class="ruby-keyword kw">end</span>
864
- 722:
865
- 723: <span class="ruby-comment cmt"># Start server</span>
866
- 724: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>]
867
- 725: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
868
- 726: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{conf[:host]}:#{conf[:port]}&quot;</span>
869
- 727: <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">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
870
- 728: <span class="ruby-identifier">trap</span> <span class="ruby-value str">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">stop</span> }
871
- 729: }
872
- 730: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
873
- 731: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{conf[:host]}:#{conf[:port]}&quot;</span>
874
- 732: <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">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
875
- 733: <span class="ruby-identifier">trap</span> <span class="ruby-value str">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">shutdown</span> }
876
- 734: }
877
- 735: <span class="ruby-keyword kw">end</span>
878
- 736: <span class="ruby-keyword kw">end</span>
879
- 737: <span class="ruby-keyword kw">end</span>
809
+ 650: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
810
+ 651: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Common options:&quot;</span>
811
+ 652:
812
+ 653: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-?&quot;</span>, <span class="ruby-value str">&quot;--help&quot;</span>, <span class="ruby-value str">&quot;Show this message&quot;</span>) <span class="ruby-keyword kw">do</span>
813
+ 654: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>
814
+ 655: <span class="ruby-identifier">exit</span>
815
+ 656: <span class="ruby-keyword kw">end</span>
816
+ 657: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&quot;-v&quot;</span>, <span class="ruby-value str">&quot;--version&quot;</span>, <span class="ruby-value str">&quot;Show versions&quot;</span>) <span class="ruby-keyword kw">do</span>
817
+ 658: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Capcode version #{Capcode::CAPCOD_VERION} (ruby v#{RUBY_VERSION})&quot;</span>
818
+ 659: <span class="ruby-identifier">exit</span>
819
+ 660: <span class="ruby-keyword kw">end</span>
820
+ 661: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>( <span class="ruby-value str">&quot;-V&quot;</span>, <span class="ruby-value str">&quot;--verbose&quot;</span>, <span class="ruby-value str">&quot;Run in verbose mode&quot;</span> ) <span class="ruby-keyword kw">do</span>
821
+ 662: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>] = <span class="ruby-keyword kw">true</span>
822
+ 663: <span class="ruby-keyword kw">end</span>
823
+ 664: <span class="ruby-keyword kw">end</span>
824
+ 665:
825
+ 666: <span class="ruby-keyword kw">begin</span>
826
+ 667: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span> <span class="ruby-constant">ARGV</span>
827
+ 668: <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">&gt;</span> <span class="ruby-identifier">ex</span>
828
+ 669: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! #{ex.message}&quot;</span>
829
+ 670: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** use `#{File.basename($0)} --help` for more details...&quot;</span>
830
+ 671: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
831
+ 672: <span class="ruby-keyword kw">end</span>
832
+ 673:
833
+ 674: <span class="ruby-comment cmt"># Run in the Working directory</span>
834
+ 675: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Go on root directory (#{File.expand_path(conf[:root])})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:verbose</span>]
835
+ 676: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>] ) <span class="ruby-keyword kw">do</span>
836
+ 677:
837
+ 678: <span class="ruby-comment cmt"># Check that mongrel exists </span>
838
+ 679: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
839
+ 680: <span class="ruby-keyword kw">begin</span>
840
+ 681: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
841
+ 682: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;mongrel&quot;</span>
842
+ 683: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
843
+ 684: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
844
+ 685: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;webrick&quot;</span>
845
+ 686: <span class="ruby-keyword kw">end</span>
846
+ 687: <span class="ruby-keyword kw">end</span>
847
+ 688:
848
+ 689: <span class="ruby-comment cmt"># From rackup !!!</span>
849
+ 690: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>]
850
+ 691: <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>
851
+ 692: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">RUBY_VERSION</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value str">&quot;1.9&quot;</span>
852
+ 693: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
853
+ 694: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
854
+ 695: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
855
+ 696: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
856
+ 697: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
857
+ 698: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
858
+ 699: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>, <span class="ruby-value str">&quot;a&quot;</span>
859
+ 700: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>, <span class="ruby-value str">&quot;a&quot;</span>
860
+ 701: <span class="ruby-keyword kw">else</span>
861
+ 702: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
862
+ 703: <span class="ruby-keyword kw">end</span>
863
+ 704: <span class="ruby-keyword kw">else</span>
864
+ 705: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! daemonize option unavailable on #{RUBY_PLATFORM} platform.&quot;</span>
865
+ 706: <span class="ruby-keyword kw">end</span>
866
+ 707:
867
+ 708: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">conf</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">&quot;#{Process.pid}&quot;</span>) }
868
+ 709: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">conf</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-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) }
869
+ 710: <span class="ruby-keyword kw">end</span>
870
+ 711:
871
+ 712: <span class="ruby-identifier">app</span> = <span class="ruby-keyword kw">nil</span>
872
+ 713: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
873
+ 714: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-identifier">conf</span>) { <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> ) }
874
+ 715: <span class="ruby-keyword kw">else</span>
875
+ 716: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-identifier">conf</span>)
876
+ 717: <span class="ruby-keyword kw">end</span>
877
+ 718: <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-identifier">conf</span>[<span class="ruby-identifier">:log</span>]) )
878
+ 719:
879
+ 720: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:console</span>]
880
+ 721: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Run console...&quot;</span>
881
+ 722: <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">start</span>
882
+ 723: <span class="ruby-identifier">exit</span>
883
+ 724: <span class="ruby-keyword kw">end</span>
884
+ 725:
885
+ 726: <span class="ruby-comment cmt"># Start server</span>
886
+ 727: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>]
887
+ 728: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
888
+ 729: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{conf[:host]}:#{conf[:port]}&quot;</span>
889
+ 730: <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">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
890
+ 731: <span class="ruby-identifier">trap</span> <span class="ruby-value str">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">stop</span> }
891
+ 732: }
892
+ 733: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
893
+ 734: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{conf[:host]}:#{conf[:port]}&quot;</span>
894
+ 735: <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">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
895
+ 736: <span class="ruby-identifier">trap</span> <span class="ruby-value str">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">shutdown</span> }
896
+ 737: }
897
+ 738: <span class="ruby-keyword kw">end</span>
898
+ 739: <span class="ruby-keyword kw">end</span>
899
+ 740: <span class="ruby-keyword kw">end</span>
880
900
  </pre>
881
901
  </div>
882
902
  </div>
@@ -899,10 +919,10 @@ Session hash
899
919
  onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
900
920
  <div class="method-source-code" id="M000004-source">
901
921
  <pre>
902
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 343</span>
903
- 343: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
904
- 344: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
905
- 345: <span class="ruby-keyword kw">end</span>
922
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 346</span>
923
+ 346: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
924
+ 347: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
925
+ 348: <span class="ruby-keyword kw">end</span>
906
926
  </pre>
907
927
  </div>
908
928
  </div>
@@ -1019,10 +1039,10 @@ Example :
1019
1039
  onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
1020
1040
  <div class="method-source-code" id="M000008-source">
1021
1041
  <pre>
1022
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 485</span>
1023
- 485: <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">&amp;</span><span class="ruby-identifier">block</span>)
1024
- 486: <span class="ruby-identifier">middlewares</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">middleware</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>]
1025
- 487: <span class="ruby-keyword kw">end</span>
1042
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 488</span>
1043
+ 488: <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">&amp;</span><span class="ruby-identifier">block</span>)
1044
+ 489: <span class="ruby-identifier">middlewares</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">middleware</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span>]
1045
+ 490: <span class="ruby-keyword kw">end</span>
1026
1046
  </pre>
1027
1047
  </div>
1028
1048
  </div>