Capcode 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,10 @@ Capcode is a web microframework
12
12
 
13
13
  == FEATURES/PROBLEMS:
14
14
 
15
+ === 0.9.1
16
+ * You don't need to require the renderers. This will be done by Capcode at use time.
17
+ * Major bug correction for jRuby
18
+
15
19
  === 0.9.0
16
20
 
17
21
  * <b>IMPORTANT</b>
@@ -224,12 +228,13 @@ See <tt>examples/blog-dm.rb</tt> and/or <tt>examples/blog-couchdb.rb</tt> for co
224
228
  # file: sample.rb
225
229
  require 'rubygems'
226
230
  require 'capcode'
227
- require 'capcode/render/markaby'
228
231
 
229
232
  module Capcode
230
233
  class Hello < Route '/hello'
231
234
  def get
232
235
  @t = Time.now
236
+
237
+ # This implies that capcode-render-markaby is installed !
233
238
  render :markaby => :time
234
239
  end
235
240
  end
@@ -256,13 +261,15 @@ See <tt>examples/blog-dm.rb</tt> and/or <tt>examples/blog-couchdb.rb</tt> for co
256
261
  # file: sample.rb
257
262
  require 'rubygems'
258
263
  require 'capcode'
259
- require 'capcode/render/haml'
260
- Capcode::Helpers.haml_path = "./my_haml_views"
261
264
 
262
265
  module Capcode
266
+ set :haml, "./my_haml_views"
267
+
263
268
  class Hello < Route '/hello'
264
269
  def get
265
270
  @t = Time.now
271
+
272
+ # This implies that capcode-render-haml is installed !
266
273
  render :haml => :time
267
274
  end
268
275
  end
@@ -282,12 +289,13 @@ See <tt>examples/blog-dm.rb</tt> and/or <tt>examples/blog-couchdb.rb</tt> for co
282
289
  # file: sample.rb
283
290
  require 'rubygems'
284
291
  require 'capcode'
285
- require 'capcode/render/json'
286
292
 
287
293
  module Capcode
288
294
  class Hello < Route '/hello'
289
295
  def get
290
296
  @t = Time.now
297
+
298
+ # This implies that capcode-render-json is installed !
291
299
  render :json => { :time => @t }
292
300
  end
293
301
  end
@@ -300,13 +308,13 @@ See <tt>examples/blog-dm.rb</tt> and/or <tt>examples/blog-couchdb.rb</tt> for co
300
308
  # file: sample.rb
301
309
  require 'rubygems'
302
310
  require 'capcode'
303
- require 'capcode/render/webdav'
304
311
 
305
312
  module Capcode
306
313
 
307
314
  # !!! Render file from /Users/greg/temp !!!
308
315
  class WebDav < Route '/temp'
309
316
  def get
317
+ # This implies that capcode-render-webdav is installed !
310
318
  render :webdav => "/Users/greg/temp"
311
319
  end
312
320
 
@@ -202,169 +202,169 @@ If the regexp in the route does not match, all arguments will be
202
202
  onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
203
203
  <div class="method-source-code" id="M000001-source">
204
204
  <pre>
205
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 306</span>
206
- 306: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Route</span> <span class="ruby-operator">*</span><span class="ruby-identifier">routes_paths</span>
207
- 307: <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> {
208
- 308: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:__urls__</span>) {
209
- 309: <span class="ruby-comment cmt"># &lt; Route '/hello/world/([^\/]*)/id(\d*)', '/hello/(.*)', :agent =&gt; /Songbird (\d\.\d)[\d\/]*?/</span>
210
- 310: <span class="ruby-comment cmt"># # =&gt; [ {'/hello/world' =&gt; '([^\/]*)/id(\d*)', '/hello' =&gt; '(.*)'}, </span>
211
- 311: <span class="ruby-comment cmt"># 2, </span>
212
- 312: <span class="ruby-comment cmt"># &lt;Capcode::Klass&gt;, </span>
213
- 313: <span class="ruby-comment cmt"># {:agent =&gt; /Songbird (\d\.\d)[\d\/]*?/} ]</span>
214
- 314: <span class="ruby-identifier">hash_of_routes</span> = {}
215
- 315: <span class="ruby-identifier">max_captures_for_routes</span> = <span class="ruby-value">0</span>
216
- 316: <span class="ruby-identifier">routes_paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">current_route_path</span><span class="ruby-operator">|</span>
217
- 317: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">current_route_path</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">String</span>
218
- 318: <span class="ruby-identifier">m</span> = <span class="ruby-regexp re">/\/([^\/]*\(.*)/</span>.<span class="ruby-identifier">match</span>( <span class="ruby-identifier">current_route_path</span> )
219
- 319: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span>
220
- 320: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">&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>)
221
- 321: <span class="ruby-identifier">hash_of_routes</span>[<span class="ruby-identifier">current_route_path</span>] = <span class="ruby-value str">''</span>
222
- 322: <span class="ruby-keyword kw">else</span>
223
- 323: <span class="ruby-identifier">_pre</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">pre_match</span>
224
- 324: <span class="ruby-identifier">_pre</span> = <span class="ruby-value str">&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>
225
- 325: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">&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>)
226
- 326: <span class="ruby-identifier">hash_of_routes</span>[<span class="ruby-identifier">_pre</span>] = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]
227
- 327: <span class="ruby-identifier">max_captures_for_routes</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]).<span class="ruby-identifier">number_of_captures</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">max_captures_for_routes</span> <span class="ruby-operator">&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>
228
- 328: <span class="ruby-keyword kw">end</span>
229
- 329: <span class="ruby-keyword kw">else</span>
230
- 330: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">ParameterError</span>, <span class="ruby-value str">&quot;Bad route declaration !&quot;</span>, <span class="ruby-identifier">caller</span>
231
- 331: <span class="ruby-keyword kw">end</span>
232
- 332: <span class="ruby-keyword kw">end</span>
233
- 333: [<span class="ruby-identifier">hash_of_routes</span>, <span class="ruby-identifier">max_captures_for_routes</span>, <span class="ruby-keyword kw">self</span>]
234
- 334: }
235
- 335:
236
- 336: <span class="ruby-comment cmt"># Hash containing all the request parameters (GET or POST)</span>
237
- 337: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
238
- 338: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
239
- 339: <span class="ruby-keyword kw">end</span>
240
- 340:
241
- 341: <span class="ruby-comment cmt"># Hash containing all the environment variables</span>
242
- 342: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
243
- 343: <span class="ruby-ivar">@env</span>
244
- 344: <span class="ruby-keyword kw">end</span>
245
- 345:
246
- 346: <span class="ruby-comment cmt"># Session hash</span>
247
- 347: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
248
- 348: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
205
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 316</span>
206
+ 316: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Route</span> <span class="ruby-operator">*</span><span class="ruby-identifier">routes_paths</span>
207
+ 317: <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span> {
208
+ 318: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:__urls__</span>) {
209
+ 319: <span class="ruby-comment cmt"># &lt; Route '/hello/world/([^\/]*)/id(\d*)', '/hello/(.*)', :agent =&gt; /Songbird (\d\.\d)[\d\/]*?/</span>
210
+ 320: <span class="ruby-comment cmt"># # =&gt; [ {'/hello/world' =&gt; '([^\/]*)/id(\d*)', '/hello' =&gt; '(.*)'}, </span>
211
+ 321: <span class="ruby-comment cmt"># 2, </span>
212
+ 322: <span class="ruby-comment cmt"># &lt;Capcode::Klass&gt;, </span>
213
+ 323: <span class="ruby-comment cmt"># {:agent =&gt; /Songbird (\d\.\d)[\d\/]*?/} ]</span>
214
+ 324: <span class="ruby-identifier">hash_of_routes</span> = {}
215
+ 325: <span class="ruby-identifier">max_captures_for_routes</span> = <span class="ruby-value">0</span>
216
+ 326: <span class="ruby-identifier">routes_paths</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">current_route_path</span><span class="ruby-operator">|</span>
217
+ 327: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">current_route_path</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">String</span>
218
+ 328: <span class="ruby-identifier">m</span> = <span class="ruby-regexp re">/\/([^\/]*\(.*)/</span>.<span class="ruby-identifier">match</span>( <span class="ruby-identifier">current_route_path</span> )
219
+ 329: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">nil?</span>
220
+ 330: <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>)
221
+ 331: <span class="ruby-identifier">hash_of_routes</span>[<span class="ruby-identifier">current_route_path</span>] = <span class="ruby-value str">''</span>
222
+ 332: <span class="ruby-keyword kw">else</span>
223
+ 333: <span class="ruby-identifier">_pre</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">pre_match</span>
224
+ 334: <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>
225
+ 335: <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>)
226
+ 336: <span class="ruby-identifier">hash_of_routes</span>[<span class="ruby-identifier">_pre</span>] = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">captures</span>[<span class="ruby-value">0</span>]
227
+ 337: <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>
228
+ 338: <span class="ruby-keyword kw">end</span>
229
+ 339: <span class="ruby-keyword kw">else</span>
230
+ 340: <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>
231
+ 341: <span class="ruby-keyword kw">end</span>
232
+ 342: <span class="ruby-keyword kw">end</span>
233
+ 343: [<span class="ruby-identifier">hash_of_routes</span>, <span class="ruby-identifier">max_captures_for_routes</span>, <span class="ruby-keyword kw">self</span>]
234
+ 344: }
235
+ 345:
236
+ 346: <span class="ruby-comment cmt"># Hash containing all the request parameters (GET or POST)</span>
237
+ 347: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
238
+ 348: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
249
239
  349: <span class="ruby-keyword kw">end</span>
250
240
  350:
251
- 351: <span class="ruby-comment cmt"># Return the Rack::Request object</span>
252
- 352: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
253
- 353: <span class="ruby-ivar">@request</span>
241
+ 351: <span class="ruby-comment cmt"># Hash containing all the environment variables</span>
242
+ 352: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
243
+ 353: <span class="ruby-ivar">@env</span>
254
244
  354: <span class="ruby-keyword kw">end</span>
255
245
  355:
256
- 356: <span class="ruby-comment cmt"># Return the Rack::Response object</span>
257
- 357: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
258
- 358: <span class="ruby-ivar">@response</span>
246
+ 356: <span class="ruby-comment cmt"># Session hash</span>
247
+ 357: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
248
+ 358: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
259
249
  359: <span class="ruby-keyword kw">end</span>
260
250
  360:
261
- 361: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>( <span class="ruby-identifier">e</span> ) <span class="ruby-comment cmt">#:nodoc:</span>
262
- 362: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">e</span>
263
- 363: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>
264
- 364: <span class="ruby-ivar">@request</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@env</span>)
265
- 365:
266
- 366: <span class="ruby-comment cmt"># __k = self.class.to_s.split( /::/ )[-1].downcase.to_sym</span>
267
- 367: <span class="ruby-comment cmt"># @@__FILTERS.each do |f|</span>
268
- 368: <span class="ruby-comment cmt"># proc = f.delete(:action)</span>
269
- 369: <span class="ruby-comment cmt"># __run = true</span>
270
- 370: <span class="ruby-comment cmt"># if f[:only]</span>
271
- 371: <span class="ruby-comment cmt"># __run = f[:only].include?(__k)</span>
272
- 372: <span class="ruby-comment cmt"># end</span>
273
- 373: <span class="ruby-comment cmt"># if f[:except]</span>
274
- 374: <span class="ruby-comment cmt"># __run = !f[:except].include?(__k)</span>
275
- 375: <span class="ruby-comment cmt"># end</span>
276
- 376: <span class="ruby-comment cmt"># </span>
277
- 377: <span class="ruby-comment cmt"># # proc.call(self) if __run</span>
278
- 378: <span class="ruby-comment cmt"># puts &quot;call #{proc} for #{__k}&quot;</span>
279
- 379: <span class="ruby-comment cmt"># end</span>
280
- 380:
281
- 381: <span class="ruby-comment cmt"># Check authz</span>
282
- 382: <span class="ruby-identifier">authz_options</span> = <span class="ruby-keyword kw">nil</span>
283
- 383: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">__auth__</span> <span class="ruby-keyword kw">and</span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">__auth__</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
284
- 384: <span class="ruby-identifier">authz_options</span> = <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">__auth__</span>[<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">nil</span>
285
- 385: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">authz_options</span>.<span class="ruby-identifier">nil?</span>
286
- 386: <span class="ruby-identifier">route</span> = <span class="ruby-keyword kw">nil</span>
287
- 387:
288
- 388: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">__auth__</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span>, <span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
289
- 389: <span class="ruby-identifier">regexp</span> = <span class="ruby-node">&quot;^#{r.gsub(/\/$/, &quot;&quot;)}([/]{1}.*)?$&quot;</span>
290
- 390: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">regexp</span>).<span class="ruby-identifier">match</span>( <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span> )
291
- 391: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">route</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">route</span>.<span class="ruby-identifier">size</span>
292
- 392: <span class="ruby-identifier">route</span> = <span class="ruby-identifier">r</span>
293
- 393: <span class="ruby-identifier">authz_options</span> = <span class="ruby-identifier">o</span>
294
- 394: <span class="ruby-keyword kw">end</span>
295
- 395: <span class="ruby-keyword kw">end</span>
296
- 396: <span class="ruby-keyword kw">end</span>
297
- 397: <span class="ruby-keyword kw">end</span>
298
- 398: <span class="ruby-keyword kw">end</span>
299
- 399:
300
- 400: <span class="ruby-identifier">r</span> = <span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:halt</span>) {
301
- 401: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">authz_options</span>.<span class="ruby-identifier">nil?</span>
302
- 402: <span class="ruby-identifier">http_authentication</span>( <span class="ruby-identifier">:type</span> =<span class="ruby-operator">&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>] ) {
303
- 403: <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:autz</span>]
304
- 404: }
305
- 405: <span class="ruby-keyword kw">end</span>
306
- 406:
307
- 407: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
308
- 408: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
309
- 409: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
310
- 410:
311
- 411: <span class="ruby-identifier">aPath</span> = <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-value str">&quot;/&quot;</span> )
312
- 412: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
313
- 413: <span class="ruby-identifier">xPath</span> = <span class="ruby-identifier">p</span>.<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ).<span class="ruby-identifier">split</span>( <span class="ruby-value str">&quot;/&quot;</span> )
314
- 414: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">xPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">aPath</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
315
- 415: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
316
- 416: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
317
- 417: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">finalNArgs</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">finalNArgs</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">diffNArgs</span>
318
- 418: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
319
- 419: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
320
- 420: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
321
- 421: <span class="ruby-keyword kw">end</span>
322
- 422: <span class="ruby-keyword kw">end</span>
323
- 423:
324
- 424: <span class="ruby-keyword kw">end</span>
325
- 425:
326
- 426: <span class="ruby-identifier">nargs</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">1</span>]
327
- 427: <span class="ruby-identifier">regexp</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">0</span>][<span class="ruby-identifier">finalPath</span>] )
328
- 428: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">regexp</span>.<span class="ruby-identifier">match</span>( <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Utils</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span>).<span class="ruby-identifier">gsub</span>( <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-node">&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> ) )
329
- 429: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
330
- 430: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">ParameterError</span>, <span class="ruby-node">&quot;Path info `#{@request.path_info}' does not match route regexp `#{regexp.source}'&quot;</span>
331
- 431: <span class="ruby-keyword kw">else</span>
332
- 432: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">captures</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> (<span class="ruby-identifier">x</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>)<span class="ruby-operator">?</span><span class="ruby-keyword kw">nil</span><span class="ruby-operator">:</span><span class="ruby-identifier">x</span> }
333
- 433: <span class="ruby-keyword kw">end</span>
334
- 434:
335
- 435: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">nargs</span>
336
- 436: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
337
- 437: <span class="ruby-keyword kw">end</span>
338
- 438:
339
- 439: <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
340
- 440: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>
341
- 441: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
342
- 442: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
343
- 443: <span class="ruby-identifier">_method</span> = <span class="ruby-identifier">params</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-value str">&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> }
344
- 444: <span class="ruby-identifier">send</span>( <span class="ruby-identifier">_method</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
345
- 445: <span class="ruby-keyword kw">else</span>
346
- 446: <span class="ruby-identifier">_method</span> = <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
347
- 447: <span class="ruby-identifier">send</span>( <span class="ruby-identifier">_method</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
348
- 448: <span class="ruby-keyword kw">end</span>
349
- 449: }
350
- 450: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_ary</span>)
351
- 451: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">shift</span> <span class="ruby-comment cmt">#r[0]</span>
352
- 452: <span class="ruby-comment cmt">#r[1].each do |k,v|</span>
353
- 453: <span class="ruby-identifier">r</span>.<span class="ruby-identifier">shift</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
354
- 454: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
355
- 455: <span class="ruby-keyword kw">end</span>
356
- 456: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">shift</span> <span class="ruby-comment cmt">#r[2]</span>
357
- 457: <span class="ruby-keyword kw">else</span>
358
- 458: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
359
- 459: <span class="ruby-keyword kw">end</span>
360
- 460:
361
- 461: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
362
- 462: <span class="ruby-keyword kw">end</span>
363
- 463:
364
- 464: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
365
- 465: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>
366
- 466: }
367
- 467: <span class="ruby-keyword kw">end</span>
251
+ 361: <span class="ruby-comment cmt"># Return the Rack::Request object</span>
252
+ 362: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
253
+ 363: <span class="ruby-ivar">@request</span>
254
+ 364: <span class="ruby-keyword kw">end</span>
255
+ 365:
256
+ 366: <span class="ruby-comment cmt"># Return the Rack::Response object</span>
257
+ 367: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
258
+ 368: <span class="ruby-ivar">@response</span>
259
+ 369: <span class="ruby-keyword kw">end</span>
260
+ 370:
261
+ 371: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>( <span class="ruby-identifier">e</span> ) <span class="ruby-comment cmt">#:nodoc:</span>
262
+ 372: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">e</span>
263
+ 373: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>
264
+ 374: <span class="ruby-ivar">@request</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@env</span>)
265
+ 375:
266
+ 376: <span class="ruby-comment cmt"># __k = self.class.to_s.split( /::/ )[-1].downcase.to_sym</span>
267
+ 377: <span class="ruby-comment cmt"># @@__FILTERS.each do |f|</span>
268
+ 378: <span class="ruby-comment cmt"># proc = f.delete(:action)</span>
269
+ 379: <span class="ruby-comment cmt"># __run = true</span>
270
+ 380: <span class="ruby-comment cmt"># if f[:only]</span>
271
+ 381: <span class="ruby-comment cmt"># __run = f[:only].include?(__k)</span>
272
+ 382: <span class="ruby-comment cmt"># end</span>
273
+ 383: <span class="ruby-comment cmt"># if f[:except]</span>
274
+ 384: <span class="ruby-comment cmt"># __run = !f[:except].include?(__k)</span>
275
+ 385: <span class="ruby-comment cmt"># end</span>
276
+ 386: <span class="ruby-comment cmt"># </span>
277
+ 387: <span class="ruby-comment cmt"># # proc.call(self) if __run</span>
278
+ 388: <span class="ruby-comment cmt"># puts &quot;call #{proc} for #{__k}&quot;</span>
279
+ 389: <span class="ruby-comment cmt"># end</span>
280
+ 390:
281
+ 391: <span class="ruby-comment cmt"># Check authz</span>
282
+ 392: <span class="ruby-identifier">authz_options</span> = <span class="ruby-keyword kw">nil</span>
283
+ 393: <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>
284
+ 394: <span class="ruby-identifier">authz_options</span> = <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">__auth__</span>[<span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">nil</span>
285
+ 395: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">authz_options</span>.<span class="ruby-identifier">nil?</span>
286
+ 396: <span class="ruby-identifier">route</span> = <span class="ruby-keyword kw">nil</span>
287
+ 397:
288
+ 398: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">__auth__</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span>, <span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
289
+ 399: <span class="ruby-identifier">regexp</span> = <span class="ruby-node">&quot;^#{r.gsub(/\/$/, &quot;&quot;)}([/]{1}.*)?$&quot;</span>
290
+ 400: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">regexp</span>).<span class="ruby-identifier">match</span>( <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">path</span> )
291
+ 401: <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>
292
+ 402: <span class="ruby-identifier">route</span> = <span class="ruby-identifier">r</span>
293
+ 403: <span class="ruby-identifier">authz_options</span> = <span class="ruby-identifier">o</span>
294
+ 404: <span class="ruby-keyword kw">end</span>
295
+ 405: <span class="ruby-keyword kw">end</span>
296
+ 406: <span class="ruby-keyword kw">end</span>
297
+ 407: <span class="ruby-keyword kw">end</span>
298
+ 408: <span class="ruby-keyword kw">end</span>
299
+ 409:
300
+ 410: <span class="ruby-identifier">r</span> = <span class="ruby-identifier">catch</span>(<span class="ruby-identifier">:halt</span>) {
301
+ 411: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">authz_options</span>.<span class="ruby-identifier">nil?</span>
302
+ 412: <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>] ) {
303
+ 413: <span class="ruby-identifier">authz_options</span>[<span class="ruby-identifier">:autz</span>]
304
+ 414: }
305
+ 415: <span class="ruby-keyword kw">end</span>
306
+ 416:
307
+ 417: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
308
+ 418: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
309
+ 419: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
310
+ 420:
311
+ 421: <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> )
312
+ 422: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
313
+ 423: <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> )
314
+ 424: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">xPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">aPath</span>).<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
315
+ 425: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
316
+ 426: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
317
+ 427: <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>
318
+ 428: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
319
+ 429: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
320
+ 430: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
321
+ 431: <span class="ruby-keyword kw">end</span>
322
+ 432: <span class="ruby-keyword kw">end</span>
323
+ 433:
324
+ 434: <span class="ruby-keyword kw">end</span>
325
+ 435:
326
+ 436: <span class="ruby-identifier">nargs</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">1</span>]
327
+ 437: <span class="ruby-identifier">regexp</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__urls__</span>[<span class="ruby-value">0</span>][<span class="ruby-identifier">finalPath</span>] )
328
+ 438: <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> ) )
329
+ 439: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
330
+ 440: <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>
331
+ 441: <span class="ruby-keyword kw">else</span>
332
+ 442: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">captures</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> (<span class="ruby-identifier">x</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>)<span class="ruby-operator">?</span><span class="ruby-keyword kw">nil</span><span class="ruby-operator">:</span><span class="ruby-identifier">x</span> }
333
+ 443: <span class="ruby-keyword kw">end</span>
334
+ 444:
335
+ 445: <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>
336
+ 446: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
337
+ 447: <span class="ruby-keyword kw">end</span>
338
+ 448:
339
+ 449: <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
340
+ 450: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>
341
+ 451: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
342
+ 452: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
343
+ 453: <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> }
344
+ 454: <span class="ruby-identifier">send</span>( <span class="ruby-identifier">_method</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
345
+ 455: <span class="ruby-keyword kw">else</span>
346
+ 456: <span class="ruby-identifier">_method</span> = <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
347
+ 457: <span class="ruby-identifier">send</span>( <span class="ruby-identifier">_method</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
348
+ 458: <span class="ruby-keyword kw">end</span>
349
+ 459: }
350
+ 460: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_ary</span>)
351
+ 461: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">shift</span> <span class="ruby-comment cmt">#r[0]</span>
352
+ 462: <span class="ruby-comment cmt">#r[1].each do |k,v|</span>
353
+ 463: <span class="ruby-identifier">r</span>.<span class="ruby-identifier">shift</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
354
+ 464: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
355
+ 465: <span class="ruby-keyword kw">end</span>
356
+ 466: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">r</span>.<span class="ruby-identifier">shift</span> <span class="ruby-comment cmt">#r[2]</span>
357
+ 467: <span class="ruby-keyword kw">else</span>
358
+ 468: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
359
+ 469: <span class="ruby-keyword kw">end</span>
360
+ 470:
361
+ 471: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
362
+ 472: <span class="ruby-keyword kw">end</span>
363
+ 473:
364
+ 474: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
365
+ 475: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Views</span>
366
+ 476: }
367
+ 477: <span class="ruby-keyword kw">end</span>
368
368
  </pre>
369
369
  </div>
370
370
  </div>
@@ -395,71 +395,71 @@ href="Capcode.html#M000012">set</a> globally
395
395
  onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
396
396
  <div class="method-source-code" id="M000010-source">
397
397
  <pre>
398
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 536</span>
399
- 536: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">application</span>( <span class="ruby-identifier">args</span> = {} )
400
- 537: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
401
- 538:
402
- 539: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
403
- 540: <span class="ruby-keyword kw">begin</span>
404
- 541: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;Capcode::#{k}.public_methods(true).include?( '__urls__' )&quot;</span>
405
- 542: <span class="ruby-identifier">hash_of_routes</span>, <span class="ruby-identifier">max_captures_for_routes</span>, <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;Capcode::#{k}.__urls__&quot;</span>
406
- 543: <span class="ruby-identifier">hash_of_routes</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">current_route_path</span><span class="ruby-operator">|</span>
407
- 544: <span class="ruby-comment cmt">#raise Capcode::RouteError, &quot;Route `#{current_route_path}' already define !&quot;, caller if @@__ROUTES.keys.include?(current_route_path)</span>
408
- 545: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RouteError</span>, <span class="ruby-node">&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>)
409
- 546: <span class="ruby-comment cmt">#@@__ROUTES[current_route_path] = klass.new</span>
410
- 547: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>[<span class="ruby-identifier">current_route_path</span>] = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>
411
- 548: <span class="ruby-keyword kw">end</span>
412
- 549: <span class="ruby-keyword kw">end</span>
413
- 550: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
414
- 551: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
415
- 552: <span class="ruby-keyword kw">end</span>
416
- 553: <span class="ruby-keyword kw">end</span>
417
- 554:
418
- 555: <span class="ruby-comment cmt"># Set Static directory</span>
419
- 556: <span class="ruby-comment cmt">#@@__STATIC_DIR = (conf[:static][0].chr == &quot;/&quot;)?conf[:static]:&quot;/&quot;+conf[:static] unless conf[:static].nil?</span>
420
- 557: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span> = (<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">chr</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>)<span class="ruby-operator">?</span><span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>)<span class="ruby-operator">:</span><span class="ruby-value str">&quot;/&quot;</span><span class="ruby-operator">+</span><span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>).<span class="ruby-identifier">nil?</span>
421
- 558:
422
- 559: <span class="ruby-comment cmt"># Initialize Rack App</span>
423
- 560: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;** Map routes.&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
424
- 561: <span class="ruby-comment cmt">#app = Rack::URLMap.new(@@__ROUTES)</span>
425
- 562: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">URLMap</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>)
426
- 563: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Initialize static directory (#{Capcode::Configuration.get(:static)})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
427
- 564: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Static</span>.<span class="ruby-identifier">new</span>(
428
- 565: <span class="ruby-identifier">app</span>,
429
- 566: <span class="ruby-comment cmt">#:urls =&gt; [@@__STATIC_DIR], </span>
430
- 567: <span class="ruby-identifier">:urls</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>],
431
- 568: <span class="ruby-identifier">:root</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:root</span>))
432
- 569: ) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>).<span class="ruby-identifier">nil?</span>
433
- 570: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;** Initialize session&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
434
- 571: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:session</span>) )
435
- 572: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
436
- 573: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">ContentLength</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
437
- 574: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Lint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
438
- 575: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">ShowExceptions</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
439
- 576: <span class="ruby-comment cmt">#app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
440
- 577: <span class="ruby-comment cmt"># app = Rack::CommonLogger.new( app, Logger.new(conf[:log]) )</span>
441
- 578:
442
- 579: <span class="ruby-identifier">middlewares</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mw</span><span class="ruby-operator">|</span>
443
- 580: <span class="ruby-identifier">middleware</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span> = <span class="ruby-identifier">mw</span>
444
- 581: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Load middleware #{middleware}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
445
- 582: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
446
- 583: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">middleware</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
447
- 584: <span class="ruby-keyword kw">else</span>
448
- 585: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">middleware</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
449
- 586: <span class="ruby-keyword kw">end</span>
450
- 587: <span class="ruby-keyword kw">end</span>
398
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 546</span>
399
+ 546: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">application</span>( <span class="ruby-identifier">args</span> = {} )
400
+ 547: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
401
+ 548:
402
+ 549: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
403
+ 550: <span class="ruby-keyword kw">begin</span>
404
+ 551: <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>
405
+ 552: <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>
406
+ 553: <span class="ruby-identifier">hash_of_routes</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">current_route_path</span><span class="ruby-operator">|</span>
407
+ 554: <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>
408
+ 555: <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>)
409
+ 556: <span class="ruby-comment cmt">#@@__ROUTES[current_route_path] = klass.new</span>
410
+ 557: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>[<span class="ruby-identifier">current_route_path</span>] = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>
411
+ 558: <span class="ruby-keyword kw">end</span>
412
+ 559: <span class="ruby-keyword kw">end</span>
413
+ 560: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
414
+ 561: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
415
+ 562: <span class="ruby-keyword kw">end</span>
416
+ 563: <span class="ruby-keyword kw">end</span>
417
+ 564:
418
+ 565: <span class="ruby-comment cmt"># Set Static directory</span>
419
+ 566: <span class="ruby-comment cmt">#@@__STATIC_DIR = (conf[:static][0].chr == &quot;/&quot;)?conf[:static]:&quot;/&quot;+conf[:static] unless conf[:static].nil?</span>
420
+ 567: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span> = (<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">chr</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>)<span class="ruby-operator">?</span><span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>)<span class="ruby-operator">:</span><span class="ruby-value str">&quot;/&quot;</span><span class="ruby-operator">+</span><span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>).<span class="ruby-identifier">nil?</span>
421
+ 568:
422
+ 569: <span class="ruby-comment cmt"># Initialize Rack App</span>
423
+ 570: <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-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
424
+ 571: <span class="ruby-comment cmt">#app = Rack::URLMap.new(@@__ROUTES)</span>
425
+ 572: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">URLMap</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>)
426
+ 573: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Initialize static directory (#{Capcode::Configuration.get(:static)})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
427
+ 574: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Static</span>.<span class="ruby-identifier">new</span>(
428
+ 575: <span class="ruby-identifier">app</span>,
429
+ 576: <span class="ruby-comment cmt">#:urls =&gt; [@@__STATIC_DIR], </span>
430
+ 577: <span class="ruby-identifier">:urls</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>],
431
+ 578: <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-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:root</span>))
432
+ 579: ) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>).<span class="ruby-identifier">nil?</span>
433
+ 580: <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-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
434
+ 581: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:session</span>) )
435
+ 582: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
436
+ 583: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">ContentLength</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
437
+ 584: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Lint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
438
+ 585: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">ShowExceptions</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">app</span>)
439
+ 586: <span class="ruby-comment cmt">#app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
440
+ 587: <span class="ruby-comment cmt"># app = Rack::CommonLogger.new( app, Logger.new(conf[:log]) )</span>
451
441
  588:
452
- 589: <span class="ruby-comment cmt"># Start database</span>
453
- 590: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">&quot;db_connect&quot;</span>
454
- 591: <span class="ruby-identifier">db_connect</span>( <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:db_config</span>), <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:log</span>) )
455
- 592: <span class="ruby-keyword kw">end</span>
456
- 593:
457
- 594: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
458
- 595: <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> )
459
- 596: <span class="ruby-keyword kw">end</span>
460
- 597:
461
- 598: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">app</span>
462
- 599: <span class="ruby-keyword kw">end</span>
442
+ 589: <span class="ruby-identifier">middlewares</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mw</span><span class="ruby-operator">|</span>
443
+ 590: <span class="ruby-identifier">middleware</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span> = <span class="ruby-identifier">mw</span>
444
+ 591: <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-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
445
+ 592: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
446
+ 593: <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> )
447
+ 594: <span class="ruby-keyword kw">else</span>
448
+ 595: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">middleware</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
449
+ 596: <span class="ruby-keyword kw">end</span>
450
+ 597: <span class="ruby-keyword kw">end</span>
451
+ 598:
452
+ 599: <span class="ruby-comment cmt"># Start database</span>
453
+ 600: <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>
454
+ 601: <span class="ruby-identifier">db_connect</span>( <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:db_config</span>), <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:log</span>) )
455
+ 602: <span class="ruby-keyword kw">end</span>
456
+ 603:
457
+ 604: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
458
+ 605: <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> )
459
+ 606: <span class="ruby-keyword kw">end</span>
460
+ 607:
461
+ 608: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">app</span>
462
+ 609: <span class="ruby-keyword kw">end</span>
463
463
  </pre>
464
464
  </div>
465
465
  </div>
@@ -482,10 +482,10 @@ Hash containing all the environment variables
482
482
  onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
483
483
  <div class="method-source-code" id="M000003-source">
484
484
  <pre>
485
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 342</span>
486
- 342: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
487
- 343: <span class="ruby-ivar">@env</span>
488
- 344: <span class="ruby-keyword kw">end</span>
485
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 352</span>
486
+ 352: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">env</span>
487
+ 353: <span class="ruby-ivar">@env</span>
488
+ 354: <span class="ruby-keyword kw">end</span>
489
489
  </pre>
490
490
  </div>
491
491
  </div>
@@ -540,27 +540,27 @@ The block must return a Hash of username =&gt; password like that :
540
540
  onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
541
541
  <div class="method-source-code" id="M000009-source">
542
542
  <pre>
543
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 510</span>
544
- 510: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">http_authentication</span>( <span class="ruby-identifier">opts</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> )
545
- 511: <span class="ruby-identifier">options</span> = {
546
- 512: <span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:basic</span>,
547
- 513: <span class="ruby-identifier">:realm</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;Capcode.app&quot;</span>,
548
- 514: <span class="ruby-identifier">:opaque</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;opaque&quot;</span>,
549
- 515: <span class="ruby-identifier">:routes</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;/&quot;</span>
550
- 516: }.<span class="ruby-identifier">merge</span>( <span class="ruby-identifier">opts</span> )
551
- 517:
552
- 518: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:autz</span>] = <span class="ruby-identifier">b</span>.<span class="ruby-identifier">call</span>()
553
- 519:
554
- 520: <span class="ruby-ivar">@__auth__</span> <span class="ruby-operator">||=</span> {}
555
- 521:
556
- 522: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:routes</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>
557
- 523: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:routes</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
558
- 524: <span class="ruby-ivar">@__auth__</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-identifier">options</span>
559
- 525: <span class="ruby-keyword kw">end</span>
560
- 526: <span class="ruby-keyword kw">else</span>
561
- 527: <span class="ruby-ivar">@__auth__</span>[<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:routes</span>]] = <span class="ruby-identifier">options</span>
562
- 528: <span class="ruby-keyword kw">end</span>
563
- 529: <span class="ruby-keyword kw">end</span>
543
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 520</span>
544
+ 520: <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> )
545
+ 521: <span class="ruby-identifier">options</span> = {
546
+ 522: <span class="ruby-identifier">:type</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:basic</span>,
547
+ 523: <span class="ruby-identifier">:realm</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;Capcode.app&quot;</span>,
548
+ 524: <span class="ruby-identifier">:opaque</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;opaque&quot;</span>,
549
+ 525: <span class="ruby-identifier">:routes</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;/&quot;</span>
550
+ 526: }.<span class="ruby-identifier">merge</span>( <span class="ruby-identifier">opts</span> )
551
+ 527:
552
+ 528: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:autz</span>] = <span class="ruby-identifier">b</span>.<span class="ruby-identifier">call</span>()
553
+ 529:
554
+ 530: <span class="ruby-ivar">@__auth__</span> <span class="ruby-operator">||=</span> {}
555
+ 531:
556
+ 532: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:routes</span>].<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span>
557
+ 533: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:routes</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
558
+ 534: <span class="ruby-ivar">@__auth__</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-identifier">options</span>
559
+ 535: <span class="ruby-keyword kw">end</span>
560
+ 536: <span class="ruby-keyword kw">else</span>
561
+ 537: <span class="ruby-ivar">@__auth__</span>[<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:routes</span>]] = <span class="ruby-identifier">options</span>
562
+ 538: <span class="ruby-keyword kw">end</span>
563
+ 539: <span class="ruby-keyword kw">end</span>
564
564
  </pre>
565
565
  </div>
566
566
  </div>
@@ -589,11 +589,11 @@ Rack or What you want Helper
589
589
  onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
590
590
  <div class="method-source-code" id="M000007-source">
591
591
  <pre>
592
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 474</span>
593
- 474: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map</span>( <span class="ruby-identifier">route</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> )
594
- 475: <span class="ruby-comment cmt">#@@__ROUTES[route] = yield</span>
595
- 476: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>[<span class="ruby-identifier">route</span>] = <span class="ruby-keyword kw">yield</span>
596
- 477: <span class="ruby-keyword kw">end</span>
592
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 484</span>
593
+ 484: <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> )
594
+ 485: <span class="ruby-comment cmt">#@@__ROUTES[route] = yield</span>
595
+ 486: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>[<span class="ruby-identifier">route</span>] = <span class="ruby-keyword kw">yield</span>
596
+ 487: <span class="ruby-keyword kw">end</span>
597
597
  </pre>
598
598
  </div>
599
599
  </div>
@@ -617,10 +617,10 @@ parameters (GET or POST)
617
617
  onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
618
618
  <div class="method-source-code" id="M000002-source">
619
619
  <pre>
620
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 337</span>
621
- 337: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
622
- 338: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
623
- 339: <span class="ruby-keyword kw">end</span>
620
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 347</span>
621
+ 347: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">params</span>
622
+ 348: <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">params</span>
623
+ 349: <span class="ruby-keyword kw">end</span>
624
624
  </pre>
625
625
  </div>
626
626
  </div>
@@ -643,10 +643,10 @@ Return the Rack::Request object
643
643
  onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
644
644
  <div class="method-source-code" id="M000005-source">
645
645
  <pre>
646
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 352</span>
647
- 352: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
648
- 353: <span class="ruby-ivar">@request</span>
649
- 354: <span class="ruby-keyword kw">end</span>
646
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 362</span>
647
+ 362: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">request</span>
648
+ 363: <span class="ruby-ivar">@request</span>
649
+ 364: <span class="ruby-keyword kw">end</span>
650
650
  </pre>
651
651
  </div>
652
652
  </div>
@@ -669,10 +669,10 @@ Return the Rack::Response object
669
669
  onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
670
670
  <div class="method-source-code" id="M000006-source">
671
671
  <pre>
672
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 357</span>
673
- 357: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
674
- 358: <span class="ruby-ivar">@response</span>
675
- 359: <span class="ruby-keyword kw">end</span>
672
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 367</span>
673
+ 367: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response</span>
674
+ 368: <span class="ruby-ivar">@response</span>
675
+ 369: <span class="ruby-keyword kw">end</span>
676
676
  </pre>
677
677
  </div>
678
678
  </div>
@@ -703,131 +703,131 @@ href="Capcode.html#M000012">set</a> globally
703
703
  onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
704
704
  <div class="method-source-code" id="M000011-source">
705
705
  <pre>
706
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 606</span>
707
- 606: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
708
- 607: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
709
- 608:
710
- 609: <span class="ruby-comment cmt"># Parse options</span>
711
- 610: <span class="ruby-identifier">opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
712
- 611: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;Usage: #{File.basename($0)} [options]&quot;</span>
713
- 612: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
714
- 613: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Specific options:&quot;</span>
715
- 614:
716
- 615: <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> ) {
717
- 616: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:console</span>, <span class="ruby-keyword kw">true</span>
718
- 617: }
719
- 618: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&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: #{Capcode::Configuration.get(:host)})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
720
- 619: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:host</span>, <span class="ruby-identifier">h</span>
721
- 620: }
722
- 621: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-p&quot;</span>, <span class="ruby-value str">&quot;--port NUM&quot;</span>, <span class="ruby-node">&quot;Port for web server (default: #{Capcode::Configuration.get(:port)})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
723
- 622: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:port</span>, <span class="ruby-identifier">p</span>
724
- 623: }
725
- 624: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-d&quot;</span>, <span class="ruby-value str">&quot;--daemonize [true|false]&quot;</span>, <span class="ruby-node">&quot;Daemonize (default: #{Capcode::Configuration.get(:daemonize)})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
726
- 625: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:daemonize</span>, <span class="ruby-identifier">d</span>
727
- 626: }
728
- 627: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&quot;-r&quot;</span>, <span class="ruby-value str">&quot;--root PATH&quot;</span>, <span class="ruby-node">&quot;Working directory (default: #{Capcode::Configuration.get(:root)})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
729
- 628: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:root</span>, <span class="ruby-identifier">w</span>
730
- 629: }
731
- 630: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">&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: #{Capcode::Configuration.get(:static)})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
732
- 631: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:static</span>, <span class="ruby-identifier">r</span>
733
- 632: }
734
- 633:
735
- 634: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
736
- 635: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Common options:&quot;</span>
737
- 636:
738
- 637: <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>
739
- 638: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>
740
- 639: <span class="ruby-identifier">exit</span>
741
- 640: <span class="ruby-keyword kw">end</span>
742
- 641: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">&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>
743
- 642: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Capcode version #{Capcode::CAPCOD_VERION} (ruby v#{RUBY_VERSION})&quot;</span>
744
- 643: <span class="ruby-identifier">exit</span>
745
- 644: <span class="ruby-keyword kw">end</span>
746
- 645: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>( <span class="ruby-value str">&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>
747
- 646: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:verbose</span>, <span class="ruby-keyword kw">true</span>
748
- 647: <span class="ruby-keyword kw">end</span>
749
- 648: <span class="ruby-keyword kw">end</span>
750
- 649:
751
- 650: <span class="ruby-keyword kw">begin</span>
752
- 651: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span> <span class="ruby-constant">ARGV</span>
753
- 652: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>
754
- 653: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! #{ex.message}&quot;</span>
755
- 654: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** use `#{File.basename($0)} --help` for more details...&quot;</span>
756
- 655: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
757
- 656: <span class="ruby-keyword kw">end</span>
758
- 657:
759
- 658: <span class="ruby-comment cmt"># Run in the Working directory</span>
760
- 659: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Go on root directory (#{File.expand_path(Capcode::Configuration.get(:root))})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
761
- 660: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:root</span>) ) <span class="ruby-keyword kw">do</span>
762
- 661:
763
- 662: <span class="ruby-comment cmt"># Check that mongrel exists </span>
764
- 663: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:server</span>).<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:server</span>) <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
765
- 664: <span class="ruby-keyword kw">begin</span>
766
- 665: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
767
- 666: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:server</span>, <span class="ruby-identifier">:mongrel</span>
768
- 667: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
769
- 668: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
770
- 669: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:server</span>, <span class="ruby-identifier">:webrick</span>
771
- 670: <span class="ruby-keyword kw">end</span>
772
- 671: <span class="ruby-keyword kw">end</span>
773
- 672:
774
- 673: <span class="ruby-comment cmt"># From rackup !!!</span>
775
- 674: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:daemonize</span>)
776
- 675: <span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">/java/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-constant">RUBY_PLATFORM</span>).<span class="ruby-identifier">nil?</span>
777
- 676: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">RUBY_VERSION</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value str">&quot;1.9&quot;</span>
778
- 677: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
779
- 678: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
780
- 679: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
781
- 680: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
782
- 681: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
783
- 682: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
784
- 683: <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>
785
- 684: <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>
786
- 685: <span class="ruby-keyword kw">else</span>
787
- 686: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
788
- 687: <span class="ruby-keyword kw">end</span>
789
- 688: <span class="ruby-keyword kw">else</span>
790
- 689: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! daemonize option unavailable on #{RUBY_PLATFORM} platform.&quot;</span>
791
- 690: <span class="ruby-keyword kw">end</span>
792
- 691:
793
- 692: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:pid</span>), <span class="ruby-value str">'w'</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;#{Process.pid}&quot;</span>) }
794
- 693: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:pid</span>)) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:pid</span>)) }
795
- 694: <span class="ruby-keyword kw">end</span>
796
- 695:
797
- 696: <span class="ruby-identifier">app</span> = <span class="ruby-keyword kw">nil</span>
798
- 697: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
799
- 698: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>) { <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> ) }
800
- 699: <span class="ruby-keyword kw">else</span>
801
- 700: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>)
802
- 701: <span class="ruby-keyword kw">end</span>
803
- 702: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">CommonLogger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:log</span>)) )
804
- 703:
805
- 704: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:console</span>)
806
- 705: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Run console...&quot;</span>
807
- 706: <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">start</span>
808
- 707: <span class="ruby-identifier">exit</span>
809
- 708: <span class="ruby-keyword kw">end</span>
810
- 709:
811
- 710: <span class="ruby-comment cmt"># Start server</span>
812
- 711: <span class="ruby-keyword kw">case</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:server</span>).<span class="ruby-identifier">to_s</span>
813
- 712: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
814
- 713: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}&quot;</span>
815
- 714: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Mongrel</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:port</span>), <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
816
- 715: <span class="ruby-identifier">trap</span> <span class="ruby-value str">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">stop</span> }
817
- 716: }
818
- 717: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
819
- 718: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}&quot;</span>
820
- 719: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">WEBrick</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:port</span>), <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
821
- 720: <span class="ruby-identifier">trap</span> <span class="ruby-value str">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">shutdown</span> }
822
- 721: }
823
- 722: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;thin&quot;</span>
824
- 723: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Thin on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}&quot;</span>
825
- 724: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Thin</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:port</span>), <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
706
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 616</span>
707
+ 616: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
708
+ 617: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
709
+ 618:
710
+ 619: <span class="ruby-comment cmt"># Parse options</span>
711
+ 620: <span class="ruby-identifier">opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
712
+ 621: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;Usage: #{File.basename($0)} [options]&quot;</span>
713
+ 622: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
714
+ 623: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Specific options:&quot;</span>
715
+ 624:
716
+ 625: <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> ) {
717
+ 626: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:console</span>, <span class="ruby-keyword kw">true</span>
718
+ 627: }
719
+ 628: <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: #{Capcode::Configuration.get(:host)})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
720
+ 629: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:host</span>, <span class="ruby-identifier">h</span>
721
+ 630: }
722
+ 631: <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: #{Capcode::Configuration.get(:port)})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
723
+ 632: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:port</span>, <span class="ruby-identifier">p</span>
724
+ 633: }
725
+ 634: <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: #{Capcode::Configuration.get(:daemonize)})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
726
+ 635: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:daemonize</span>, <span class="ruby-identifier">d</span>
727
+ 636: }
728
+ 637: <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: #{Capcode::Configuration.get(:root)})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
729
+ 638: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:root</span>, <span class="ruby-identifier">w</span>
730
+ 639: }
731
+ 640: <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: #{Capcode::Configuration.get(:static)})&quot;</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
732
+ 641: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:static</span>, <span class="ruby-identifier">r</span>
733
+ 642: }
734
+ 643:
735
+ 644: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;&quot;</span>
736
+ 645: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">&quot;Common options:&quot;</span>
737
+ 646:
738
+ 647: <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>
739
+ 648: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>
740
+ 649: <span class="ruby-identifier">exit</span>
741
+ 650: <span class="ruby-keyword kw">end</span>
742
+ 651: <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>
743
+ 652: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Capcode version #{Capcode::CAPCOD_VERION} (ruby v#{RUBY_VERSION})&quot;</span>
744
+ 653: <span class="ruby-identifier">exit</span>
745
+ 654: <span class="ruby-keyword kw">end</span>
746
+ 655: <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>
747
+ 656: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:verbose</span>, <span class="ruby-keyword kw">true</span>
748
+ 657: <span class="ruby-keyword kw">end</span>
749
+ 658: <span class="ruby-keyword kw">end</span>
750
+ 659:
751
+ 660: <span class="ruby-keyword kw">begin</span>
752
+ 661: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span> <span class="ruby-constant">ARGV</span>
753
+ 662: <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>
754
+ 663: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! #{ex.message}&quot;</span>
755
+ 664: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** use `#{File.basename($0)} --help` for more details...&quot;</span>
756
+ 665: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
757
+ 666: <span class="ruby-keyword kw">end</span>
758
+ 667:
759
+ 668: <span class="ruby-comment cmt"># Run in the Working directory</span>
760
+ 669: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Go on root directory (#{File.expand_path(Capcode::Configuration.get(:root))})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
761
+ 670: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:root</span>) ) <span class="ruby-keyword kw">do</span>
762
+ 671:
763
+ 672: <span class="ruby-comment cmt"># Check that mongrel exists </span>
764
+ 673: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:server</span>).<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:server</span>) <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
765
+ 674: <span class="ruby-keyword kw">begin</span>
766
+ 675: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
767
+ 676: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:server</span>, <span class="ruby-identifier">:mongrel</span>
768
+ 677: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
769
+ 678: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
770
+ 679: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:server</span>, <span class="ruby-identifier">:webrick</span>
771
+ 680: <span class="ruby-keyword kw">end</span>
772
+ 681: <span class="ruby-keyword kw">end</span>
773
+ 682:
774
+ 683: <span class="ruby-comment cmt"># From rackup !!!</span>
775
+ 684: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:daemonize</span>)
776
+ 685: <span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">/java/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-constant">RUBY_PLATFORM</span>).<span class="ruby-identifier">nil?</span>
777
+ 686: <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>
778
+ 687: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
779
+ 688: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
780
+ 689: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
781
+ 690: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
782
+ 691: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
783
+ 692: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
784
+ 693: <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>
785
+ 694: <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>
786
+ 695: <span class="ruby-keyword kw">else</span>
787
+ 696: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
788
+ 697: <span class="ruby-keyword kw">end</span>
789
+ 698: <span class="ruby-keyword kw">else</span>
790
+ 699: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;!! daemonize option unavailable on #{RUBY_PLATFORM} platform.&quot;</span>
791
+ 700: <span class="ruby-keyword kw">end</span>
792
+ 701:
793
+ 702: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:pid</span>), <span class="ruby-value str">'w'</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;#{Process.pid}&quot;</span>) }
794
+ 703: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:pid</span>)) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:pid</span>)) }
795
+ 704: <span class="ruby-keyword kw">end</span>
796
+ 705:
797
+ 706: <span class="ruby-identifier">app</span> = <span class="ruby-keyword kw">nil</span>
798
+ 707: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
799
+ 708: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>) { <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> ) }
800
+ 709: <span class="ruby-keyword kw">else</span>
801
+ 710: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>)
802
+ 711: <span class="ruby-keyword kw">end</span>
803
+ 712: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">CommonLogger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:log</span>)) )
804
+ 713:
805
+ 714: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:console</span>)
806
+ 715: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Run console...&quot;</span>
807
+ 716: <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">start</span>
808
+ 717: <span class="ruby-identifier">exit</span>
809
+ 718: <span class="ruby-keyword kw">end</span>
810
+ 719:
811
+ 720: <span class="ruby-comment cmt"># Start server</span>
812
+ 721: <span class="ruby-keyword kw">case</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:server</span>).<span class="ruby-identifier">to_s</span>
813
+ 722: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
814
+ 723: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}&quot;</span>
815
+ 724: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">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-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:port</span>), <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
826
816
  725: <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> }
827
817
  726: }
828
- 727: <span class="ruby-keyword kw">end</span>
829
- 728: <span class="ruby-keyword kw">end</span>
830
- 729: <span class="ruby-keyword kw">end</span>
818
+ 727: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
819
+ 728: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}&quot;</span>
820
+ 729: <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-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:port</span>), <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
821
+ 730: <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> }
822
+ 731: }
823
+ 732: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;thin&quot;</span>
824
+ 733: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Thin on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}&quot;</span>
825
+ 734: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Thin</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:port</span>), <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
826
+ 735: <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> }
827
+ 736: }
828
+ 737: <span class="ruby-keyword kw">end</span>
829
+ 738: <span class="ruby-keyword kw">end</span>
830
+ 739: <span class="ruby-keyword kw">end</span>
831
831
  </pre>
832
832
  </div>
833
833
  </div>
@@ -850,10 +850,10 @@ Session hash
850
850
  onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
851
851
  <div class="method-source-code" id="M000004-source">
852
852
  <pre>
853
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 347</span>
854
- 347: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
855
- 348: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
856
- 349: <span class="ruby-keyword kw">end</span>
853
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 357</span>
854
+ 357: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>
855
+ 358: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'rack.session'</span>]
856
+ 359: <span class="ruby-keyword kw">end</span>
857
857
  </pre>
858
858
  </div>
859
859
  </div>
@@ -909,10 +909,10 @@ Example :
909
909
  onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
910
910
  <div class="method-source-code" id="M000008-source">
911
911
  <pre>
912
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 489</span>
913
- 489: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use</span>(<span class="ruby-identifier">middleware</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
914
- 490: <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>]
915
- 491: <span class="ruby-keyword kw">end</span>
912
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 499</span>
913
+ 499: <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>)
914
+ 500: <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>]
915
+ 501: <span class="ruby-keyword kw">end</span>
916
916
  </pre>
917
917
  </div>
918
918
  </div>