Capcode 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -10,6 +10,9 @@ Capcode is a web microframework
10
10
 
11
11
  == FEATURES/PROBLEMS:
12
12
 
13
+ === 0.3.0
14
+ * Work with Rack 1.0.0
15
+
13
16
  === 0.2.0
14
17
  * Add models with DataMapper and couch_foo
15
18
  * Add two new options : :daemonize and :pid
@@ -183,42 +183,64 @@ If the regexp in the route does not match, all arguments will be
183
183
  182:
184
184
  183: <span class="ruby-identifier">r</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>]
185
185
  184: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;GET&quot;</span>
186
- 185: <span class="ruby-identifier">sc</span> = <span class="ruby-ivar">@request</span>.<span class="ruby-identifier">script_name</span>
187
- 186: <span class="ruby-identifier">sc</span> = <span class="ruby-value str">&quot;/&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">sc</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
188
- 187: <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">sc</span>] )
189
- 188: <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>]
190
- 189:
191
- 190: <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_info</span>).<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ) )
192
- 191: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
193
- 192: <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>
194
- 193: <span class="ruby-keyword kw">else</span>
195
- 194: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">captures</span>
196
- 195: <span class="ruby-keyword kw">end</span>
197
- 196:
198
- 197: <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>
199
- 198: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
200
- 199: <span class="ruby-keyword kw">end</span>
201
- 200:
202
- 201: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
203
- 202: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
204
- 203: <span class="ruby-identifier">post</span>
205
- 204: <span class="ruby-keyword kw">end</span>
206
- 205: <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>)
207
- 206: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">0</span>]
208
- 207: <span class="ruby-identifier">r</span>[<span class="ruby-value">1</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>
209
- 208: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
210
- 209: <span class="ruby-keyword kw">end</span>
211
- 210: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">2</span>]
212
- 211: <span class="ruby-keyword kw">else</span>
213
- 212: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
214
- 213: <span class="ruby-keyword kw">end</span>
215
- 214:
216
- 215: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
217
- 216: <span class="ruby-keyword kw">end</span>
218
- 217:
219
- 218: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
220
- 219: }
221
- 220: <span class="ruby-keyword kw">end</span>
186
+ 185: <span class="ruby-identifier">finalPath</span> = <span class="ruby-keyword kw">nil</span>
187
+ 186: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-keyword kw">nil</span>
188
+ 187: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-keyword kw">nil</span>
189
+ 188:
190
+ 189: <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> )
191
+ 190: <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>
192
+ 191: <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> )
193
+ 192: <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>
194
+ 193: <span class="ruby-identifier">diffArgs</span> = <span class="ruby-identifier">aPath</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">xPath</span>
195
+ 194: <span class="ruby-identifier">diffNArgs</span> = <span class="ruby-identifier">diffArgs</span>.<span class="ruby-identifier">size</span>
196
+ 195: <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>
197
+ 196: <span class="ruby-identifier">finalPath</span> = <span class="ruby-identifier">p</span>
198
+ 197: <span class="ruby-identifier">finalNArgs</span> = <span class="ruby-identifier">diffNArgs</span>
199
+ 198: <span class="ruby-identifier">finalArgs</span> = <span class="ruby-identifier">diffArgs</span>
200
+ 199: <span class="ruby-keyword kw">end</span>
201
+ 200: <span class="ruby-keyword kw">end</span>
202
+ 201:
203
+ 202: <span class="ruby-keyword kw">end</span>
204
+ 203:
205
+ 204: <span class="ruby-comment cmt"># TODO : correct above to use this :</span>
206
+ 205: <span class="ruby-comment cmt">#puts &quot;finalPath = #{finalPath}&quot;</span>
207
+ 206: <span class="ruby-comment cmt">#puts &quot;finalNArgs = #{finalNArgs}&quot;</span>
208
+ 207: <span class="ruby-comment cmt">#print &quot;finalArgs = &quot;; p finalArgs</span>
209
+ 208:
210
+ 209: <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>]
211
+ 210: <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>] )
212
+ 211:
213
+ 212: <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_info</span>).<span class="ruby-identifier">gsub</span>( <span class="ruby-regexp re">/^\//</span>, <span class="ruby-value str">&quot;&quot;</span> ) )
214
+ 213: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">nil?</span>
215
+ 214: <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>
216
+ 215: <span class="ruby-keyword kw">else</span>
217
+ 216: <span class="ruby-identifier">args</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">captures</span>
218
+ 217: <span class="ruby-keyword kw">end</span>
219
+ 218:
220
+ 219: <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>
221
+ 220: <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">nil</span>
222
+ 221: <span class="ruby-keyword kw">end</span>
223
+ 222:
224
+ 223: <span class="ruby-identifier">get</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
225
+ 224: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;POST&quot;</span>
226
+ 225: <span class="ruby-identifier">post</span>
227
+ 226: <span class="ruby-keyword kw">end</span>
228
+ 227: <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>)
229
+ 228: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">status</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">0</span>]
230
+ 229: <span class="ruby-identifier">r</span>[<span class="ruby-value">1</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>
231
+ 230: <span class="ruby-ivar">@response</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span>
232
+ 231: <span class="ruby-keyword kw">end</span>
233
+ 232: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">r</span>[<span class="ruby-value">2</span>]
234
+ 233: <span class="ruby-keyword kw">else</span>
235
+ 234: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">r</span>
236
+ 235: <span class="ruby-keyword kw">end</span>
237
+ 236:
238
+ 237: <span class="ruby-ivar">@response</span>.<span class="ruby-identifier">finish</span>
239
+ 238: <span class="ruby-keyword kw">end</span>
240
+ 239:
241
+ 240: <span class="ruby-identifier">include</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>
242
+ 241: }
243
+ 242: <span class="ruby-keyword kw">end</span>
222
244
  </pre>
223
245
  </div>
224
246
  </div>
@@ -257,10 +279,10 @@ Rack or What you want Helper
257
279
  <p class="source-link">[ <a href="javascript:toggleSource('M000007_source')" id="l_M000007_source">show source</a> ]</p>
258
280
  <div id="M000007_source" class="dyn-source">
259
281
  <pre>
260
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 227</span>
261
- 227: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map</span>( <span class="ruby-identifier">r</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> )
262
- 228: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-keyword kw">yield</span>
263
- 229: <span class="ruby-keyword kw">end</span>
282
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 249</span>
283
+ 249: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map</span>( <span class="ruby-identifier">r</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span> )
284
+ 250: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">r</span>] = <span class="ruby-keyword kw">yield</span>
285
+ 251: <span class="ruby-keyword kw">end</span>
264
286
  </pre>
265
287
  </div>
266
288
  </div>
@@ -357,91 +379,91 @@ See Rack::Session for more informations
357
379
  <p class="source-link">[ <a href="javascript:toggleSource('M000008_source')" id="l_M000008_source">show source</a> ]</p>
358
380
  <div id="M000008_source" class="dyn-source">
359
381
  <pre>
360
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 241</span>
361
- 241: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
362
- 242: <span class="ruby-identifier">conf</span> = {
363
- 243: <span class="ruby-identifier">:port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:port</span>]<span class="ruby-operator">||</span><span class="ruby-value">3000</span>,
364
- 244: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:host</span>]<span class="ruby-operator">||</span><span class="ruby-value str">&quot;localhost&quot;</span>,
365
- 245: <span class="ruby-identifier">:server</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:server</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">nil</span>,
366
- 246: <span class="ruby-identifier">:log</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:log</span>]<span class="ruby-operator">||</span><span class="ruby-identifier">$stdout</span>,
367
- 247: <span class="ruby-identifier">:session</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:session</span>]<span class="ruby-operator">||</span>{},
368
- 248: <span class="ruby-identifier">:pid</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:pid</span>]<span class="ruby-operator">||</span><span class="ruby-node">&quot;#{$0}.pid&quot;</span>,
369
- 249: <span class="ruby-identifier">:daemonize</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:daemonize</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">false</span>,
370
- 250: <span class="ruby-identifier">:db_config</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:db_config</span>]<span class="ruby-operator">||</span><span class="ruby-value str">&quot;database.yml&quot;</span>
371
- 251: }
372
- 252:
373
- 253: <span class="ruby-comment cmt"># Check that mongrel exists </span>
374
- 254: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
375
- 255: <span class="ruby-keyword kw">begin</span>
376
- 256: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
377
- 257: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;mongrel&quot;</span>
378
- 258: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
379
- 259: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
380
- 260: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;webrick&quot;</span>
381
- 261: <span class="ruby-keyword kw">end</span>
382
- 262: <span class="ruby-keyword kw">end</span>
383
- 263:
384
- 264: <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>
385
- 265: <span class="ruby-keyword kw">begin</span>
386
- 266: <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>
387
- 267: <span class="ruby-identifier">u</span>, <span class="ruby-identifier">m</span>, <span class="ruby-identifier">c</span> = <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;Capcode::#{k}.__urls__&quot;</span>
388
- 268: <span class="ruby-identifier">u</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">_u</span><span class="ruby-operator">|</span>
389
- 269: <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 `#{_u}' already define !&quot;</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@@__ROUTES</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">_u</span>)
390
- 270: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">new</span>
391
- 271: <span class="ruby-keyword kw">end</span>
392
- 272: <span class="ruby-keyword kw">end</span>
393
- 273: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
394
- 274: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
395
- 275: <span class="ruby-keyword kw">end</span>
396
- 276: <span class="ruby-keyword kw">end</span>
397
- 277:
398
- 278: <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-ivar">@@__ROUTES</span>)
399
- 279: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:session</span>] )
400
- 280: <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>)
401
- 281: <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>)
402
- 282: <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>)
403
- 283: <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>)
404
- 284: <span class="ruby-comment cmt"># app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
405
- 285: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">CommonLogger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>]) )
406
- 286:
407
- 287: <span class="ruby-comment cmt"># From rackup !!!</span>
408
- 288: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>]
409
- 289: <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>
410
- 290: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
411
- 291: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
412
- 292: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
413
- 293: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
414
- 294: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
415
- 295: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
416
- 296: <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>
417
- 297: <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>
418
- 298: <span class="ruby-keyword kw">else</span>
419
- 299: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
420
- 300: <span class="ruby-keyword kw">end</span>
421
- 301:
422
- 302: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>], <span class="ruby-value str">'w'</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;#{Process.pid}&quot;</span>) }
423
- 303: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) }
424
- 304: <span class="ruby-keyword kw">end</span>
425
- 305:
426
- 306: <span class="ruby-comment cmt"># Start database</span>
427
- 307: <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>
428
- 308: <span class="ruby-identifier">db_connect</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:db_config</span>], <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>] )
429
- 309: <span class="ruby-keyword kw">end</span>
430
- 310:
431
- 311: <span class="ruby-comment cmt"># Start server</span>
432
- 312: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>]
433
- 313: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
434
- 314: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{conf[:host]}:#{conf[:port]}&quot;</span>
435
- 315: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Mongrel</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
436
- 316: <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> }
437
- 317: }
438
- 318: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
439
- 319: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{conf[:host]}:#{conf[:port]}&quot;</span>
440
- 320: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">WEBrick</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
441
- 321: <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> }
442
- 322: }
443
- 323: <span class="ruby-keyword kw">end</span>
444
- 324: <span class="ruby-keyword kw">end</span>
382
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 263</span>
383
+ 263: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
384
+ 264: <span class="ruby-identifier">conf</span> = {
385
+ 265: <span class="ruby-identifier">:port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:port</span>]<span class="ruby-operator">||</span><span class="ruby-value">3000</span>,
386
+ 266: <span class="ruby-identifier">:host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:host</span>]<span class="ruby-operator">||</span><span class="ruby-value str">&quot;localhost&quot;</span>,
387
+ 267: <span class="ruby-identifier">:server</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:server</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">nil</span>,
388
+ 268: <span class="ruby-identifier">:log</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:log</span>]<span class="ruby-operator">||</span><span class="ruby-identifier">$stdout</span>,
389
+ 269: <span class="ruby-identifier">:session</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:session</span>]<span class="ruby-operator">||</span>{},
390
+ 270: <span class="ruby-identifier">:pid</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:pid</span>]<span class="ruby-operator">||</span><span class="ruby-node">&quot;#{$0}.pid&quot;</span>,
391
+ 271: <span class="ruby-identifier">:daemonize</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:daemonize</span>]<span class="ruby-operator">||</span><span class="ruby-keyword kw">false</span>,
392
+ 272: <span class="ruby-identifier">:db_config</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>[<span class="ruby-identifier">:db_config</span>]<span class="ruby-operator">||</span><span class="ruby-value str">&quot;database.yml&quot;</span>
393
+ 273: }
394
+ 274:
395
+ 275: <span class="ruby-comment cmt"># Check that mongrel exists </span>
396
+ 276: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
397
+ 277: <span class="ruby-keyword kw">begin</span>
398
+ 278: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
399
+ 279: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;mongrel&quot;</span>
400
+ 280: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
401
+ 281: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;!! could not load mongrel. Falling back to webrick.&quot;</span>
402
+ 282: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">&quot;webrick&quot;</span>
403
+ 283: <span class="ruby-keyword kw">end</span>
404
+ 284: <span class="ruby-keyword kw">end</span>
405
+ 285:
406
+ 286: <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>
407
+ 287: <span class="ruby-keyword kw">begin</span>
408
+ 288: <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>
409
+ 289: <span class="ruby-identifier">u</span>, <span class="ruby-identifier">m</span>, <span class="ruby-identifier">c</span> = <span class="ruby-identifier">eval</span> <span class="ruby-node">&quot;Capcode::#{k}.__urls__&quot;</span>
410
+ 290: <span class="ruby-identifier">u</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">_u</span><span class="ruby-operator">|</span>
411
+ 291: <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 `#{_u}' already define !&quot;</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@@__ROUTES</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">_u</span>)
412
+ 292: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">new</span>
413
+ 293: <span class="ruby-keyword kw">end</span>
414
+ 294: <span class="ruby-keyword kw">end</span>
415
+ 295: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
416
+ 296: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
417
+ 297: <span class="ruby-keyword kw">end</span>
418
+ 298: <span class="ruby-keyword kw">end</span>
419
+ 299:
420
+ 300: <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-ivar">@@__ROUTES</span>)
421
+ 301: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:session</span>] )
422
+ 302: <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>)
423
+ 303: <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>)
424
+ 304: <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>)
425
+ 305: <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>)
426
+ 306: <span class="ruby-comment cmt"># app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
427
+ 307: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">CommonLogger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>]) )
428
+ 308:
429
+ 309: <span class="ruby-comment cmt"># From rackup !!!</span>
430
+ 310: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>]
431
+ 311: <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>
432
+ 312: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
433
+ 313: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
434
+ 314: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
435
+ 315: <span class="ruby-comment cmt"># Dir.chdir &quot;/&quot;</span>
436
+ 316: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
437
+ 317: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">&quot;/dev/null&quot;</span>
438
+ 318: <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>
439
+ 319: <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>
440
+ 320: <span class="ruby-keyword kw">else</span>
441
+ 321: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
442
+ 322: <span class="ruby-keyword kw">end</span>
443
+ 323:
444
+ 324: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>], <span class="ruby-value str">'w'</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;#{Process.pid}&quot;</span>) }
445
+ 325: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) }
446
+ 326: <span class="ruby-keyword kw">end</span>
447
+ 327:
448
+ 328: <span class="ruby-comment cmt"># Start database</span>
449
+ 329: <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>
450
+ 330: <span class="ruby-identifier">db_connect</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:db_config</span>], <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>] )
451
+ 331: <span class="ruby-keyword kw">end</span>
452
+ 332:
453
+ 333: <span class="ruby-comment cmt"># Start server</span>
454
+ 334: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>]
455
+ 335: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;mongrel&quot;</span>
456
+ 336: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting Mongrel on #{conf[:host]}:#{conf[:port]}&quot;</span>
457
+ 337: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Mongrel</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
458
+ 338: <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> }
459
+ 339: }
460
+ 340: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;webrick&quot;</span>
461
+ 341: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;** Starting WEBrick on #{conf[:host]}:#{conf[:port]}&quot;</span>
462
+ 342: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">WEBrick</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
463
+ 343: <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> }
464
+ 344: }
465
+ 345: <span class="ruby-keyword kw">end</span>
466
+ 346: <span class="ruby-keyword kw">end</span>
445
467
  </pre>
446
468
  </div>
447
469
  </div>
@@ -1 +1 @@
1
- Mon, 16 Mar 2009 12:39:42 +0100
1
+ Wed, 29 Apr 2009 18:55:19 +0200
@@ -79,7 +79,7 @@ end</strong>
79
79
  <div id="README" class="page_shade">
80
80
  <div class="page">
81
81
  <div class="header">
82
- <div class="path">README / Mon Mar 16 12:31:45 +0100 2009</div>
82
+ <div class="path">README / Wed Apr 29 18:53:54 +0200 2009</div>
83
83
  </div>
84
84
 
85
85
  <h1><a href="../classes/Capcode.html">Capcode</a></h1>
@@ -96,6 +96,12 @@ Copyright (C) 2009 Gregoire Lejeune
96
96
  <a href="../classes/Capcode.html">Capcode</a> is a web microframework
97
97
  </p>
98
98
  <h2>FEATURES/PROBLEMS:</h2>
99
+ <h3>0.3.0</h3>
100
+ <ul>
101
+ <li>Work with Rack 1.0.0
102
+
103
+ </li>
104
+ </ul>
99
105
  <h3>0.2.0</h3>
100
106
  <ul>
101
107
  <li>Add models with DataMapper and couch_foo
@@ -79,7 +79,7 @@ end</strong>
79
79
  <div id="lib/capcode.rb" class="page_shade">
80
80
  <div class="page">
81
81
  <div class="header">
82
- <div class="path">lib/capcode.rb / Mon Mar 16 12:38:20 +0100 2009</div>
82
+ <div class="path">lib/capcode.rb / Wed Apr 29 18:52:03 +0200 2009</div>
83
83
  </div>
84
84
 
85
85
  <pre>
@@ -101,7 +101,7 @@ module Capcode
101
101
  status, headers, body = @app.call(env)
102
102
 
103
103
  if self.methods.include? "r#{status}"
104
- body = self.call "r#{status}", env['REQUEST_PATH']
104
+ body = self.send( "r#{status}", env['REQUEST_PATH'] )
105
105
  headers['Content-Length'] = body.length.to_s
106
106
  end
107
107
 
@@ -182,10 +182,32 @@ module Capcode
182
182
 
183
183
  r = case @env["REQUEST_METHOD"]
184
184
  when "GET"
185
- sc = @request.script_name
186
- sc = "/" if sc.size == 0
187
- regexp = Regexp.new( self.class.__urls__[0][sc] )
185
+ finalPath = nil
186
+ finalArgs = nil
187
+ finalNArgs = nil
188
+
189
+ aPath = @request.path.gsub( /^\//, "" ).split( "/" )
190
+ self.class.__urls__[0].each do |p, r|
191
+ xPath = p.gsub( /^\//, "" ).split( "/" )
192
+ if (xPath - aPath).size == 0
193
+ diffArgs = aPath - xPath
194
+ diffNArgs = diffArgs.size
195
+ if finalNArgs.nil? or finalNArgs > diffNArgs
196
+ finalPath = p
197
+ finalNArgs = diffNArgs
198
+ finalArgs = diffArgs
199
+ end
200
+ end
201
+
202
+ end
203
+
204
+ # TODO : correct above to use this :
205
+ #puts "finalPath = #{finalPath}"
206
+ #puts "finalNArgs = #{finalNArgs}"
207
+ #print "finalArgs = "; p finalArgs
208
+
188
209
  nargs = self.class.__urls__[1]
210
+ regexp = Regexp.new( self.class.__urls__[0][finalPath] )
189
211
 
190
212
  args = regexp.match( Rack::Utils.unescape(@request.path_info).gsub( /^\//, "" ) )
191
213
  if args.nil?
@@ -1,3 +1,3 @@
1
1
  module Capcode
2
- CAPCOD_VERION="0.2.0"
2
+ CAPCOD_VERION="0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Capcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Gr\xC3\xA9goire Lejeune"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-16 00:00:00 +01:00
12
+ date: 2009-04-29 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -38,27 +38,20 @@ files:
38
38
  - README
39
39
  - AUTHORS
40
40
  - setup.rb
41
- - doc/rdoc
42
- - doc/rdoc/classes
43
- - doc/rdoc/classes/Capcode
44
41
  - doc/rdoc/classes/Capcode/Helpers.html
45
42
  - doc/rdoc/classes/Capcode/HTTPError.html
46
43
  - doc/rdoc/classes/Capcode/ParameterError.html
47
44
  - doc/rdoc/classes/Capcode/RouteError.html
48
45
  - doc/rdoc/classes/Capcode.html
49
46
  - doc/rdoc/created.rid
50
- - doc/rdoc/files
51
47
  - doc/rdoc/files/AUTHORS.html
52
48
  - doc/rdoc/files/COPYING.html
53
- - doc/rdoc/files/lib
54
49
  - doc/rdoc/files/lib/capcode_rb.html
55
50
  - doc/rdoc/files/README.html
56
51
  - doc/rdoc/index.html
57
52
  - doc/rdoc/permalink.gif
58
53
  - doc/rdoc/rdoc-style.css
59
54
  - doc/rdoc/rubyfr.png
60
- - lib/capcode
61
- - lib/capcode/base
62
55
  - lib/capcode/base/couchdb.rb
63
56
  - lib/capcode/base/dm.rb
64
57
  - lib/capcode/core_ext.rb
@@ -74,6 +67,8 @@ files:
74
67
  - examples/session.rb
75
68
  has_rdoc: true
76
69
  homepage: http://algorithmique.net
70
+ licenses: []
71
+
77
72
  post_install_message: |-
78
73
  For more information about Capcode,
79
74
  see http://capcode.rubyforge.org
@@ -106,9 +101,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
101
  requirements: []
107
102
 
108
103
  rubyforge_project: capcode
109
- rubygems_version: 1.3.1
104
+ rubygems_version: 1.3.2
110
105
  signing_key:
111
- specification_version: 2
106
+ specification_version: 3
112
107
  summary: Capcode is a web microframework
113
108
  test_files: []
114
109