Capcode 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -222,21 +222,21 @@ then
222
222
  onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
223
223
  <div class="method-source-code" id="M000018-source">
224
224
  <pre>
225
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 185</span>
226
- 185: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">URL</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
227
- 186: <span class="ruby-identifier">path</span> = <span class="ruby-keyword kw">nil</span>
228
- 187: <span class="ruby-identifier">a</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">delete_if</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> }
229
- 188:
230
- 189: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span>
231
- 190: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
232
- 191: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">p</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">klass</span>
233
- 192: <span class="ruby-keyword kw">end</span>
234
- 193: <span class="ruby-keyword kw">else</span>
235
- 194: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">klass</span>
236
- 195: <span class="ruby-keyword kw">end</span>
237
- 196:
238
- 197: (<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'RACK_BASE_URI'</span>]<span class="ruby-operator">||</span><span class="ruby-value str">''</span>)<span class="ruby-operator">+</span><span class="ruby-identifier">path</span><span class="ruby-operator">+</span>((<span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">&gt;</span><span class="ruby-value">0</span>)<span class="ruby-operator">?</span>(<span class="ruby-value str">&quot;/&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">a</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;/&quot;</span>))<span class="ruby-operator">:</span>(<span class="ruby-value str">&quot;&quot;</span>))
239
- 198: <span class="ruby-keyword kw">end</span>
225
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 195</span>
226
+ 195: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">URL</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
227
+ 196: <span class="ruby-identifier">path</span> = <span class="ruby-keyword kw">nil</span>
228
+ 197: <span class="ruby-identifier">a</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">delete_if</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">nil?</span> }
229
+ 198:
230
+ 199: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Class</span>
231
+ 200: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
232
+ 201: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">p</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">klass</span>
233
+ 202: <span class="ruby-keyword kw">end</span>
234
+ 203: <span class="ruby-keyword kw">else</span>
235
+ 204: <span class="ruby-identifier">path</span> = <span class="ruby-identifier">klass</span>
236
+ 205: <span class="ruby-keyword kw">end</span>
237
+ 206:
238
+ 207: (<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'RACK_BASE_URI'</span>]<span class="ruby-operator">||</span><span class="ruby-value str">''</span>)<span class="ruby-operator">+</span><span class="ruby-identifier">path</span><span class="ruby-operator">+</span>((<span class="ruby-identifier">a</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">&gt;</span><span class="ruby-value">0</span>)<span class="ruby-operator">?</span>(<span class="ruby-value str">&quot;/&quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">a</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;/&quot;</span>))<span class="ruby-operator">:</span>(<span class="ruby-value str">&quot;&quot;</span>))
239
+ 208: <span class="ruby-keyword kw">end</span>
240
240
  </pre>
241
241
  </div>
242
242
  </div>
@@ -292,13 +292,13 @@ markup in an identifier.
292
292
  onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
293
293
  <div class="method-source-code" id="M000019-source">
294
294
  <pre>
295
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 232</span>
296
- 232: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_for</span>( <span class="ruby-identifier">x</span> )
297
- 233: <span class="ruby-comment cmt">#if @@__ARGS__.map{|_| _.to_s }.include?(x.to_s)</span>
298
- 234: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">_</span>.<span class="ruby-identifier">to_s</span> }.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">x</span>.<span class="ruby-identifier">to_s</span>)
299
- 235: <span class="ruby-keyword kw">yield</span>
300
- 236: <span class="ruby-keyword kw">end</span>
301
- 237: <span class="ruby-keyword kw">end</span>
295
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 242</span>
296
+ 242: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_for</span>( <span class="ruby-identifier">x</span> )
297
+ 243: <span class="ruby-comment cmt">#if @@__ARGS__.map{|_| _.to_s }.include?(x.to_s)</span>
298
+ 244: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">_</span>.<span class="ruby-identifier">to_s</span> }.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">x</span>.<span class="ruby-identifier">to_s</span>)
299
+ 245: <span class="ruby-keyword kw">yield</span>
300
+ 246: <span class="ruby-keyword kw">end</span>
301
+ 247: <span class="ruby-keyword kw">end</span>
302
302
  </pre>
303
303
  </div>
304
304
  </div>
@@ -335,12 +335,12 @@ href="Helpers.html#M000016">json</a> =&gt; o )</tt>
335
335
  onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
336
336
  <div class="method-source-code" id="M000016-source">
337
337
  <pre>
338
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 128</span>
339
- 128: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">json</span>( <span class="ruby-identifier">d</span> ) <span class="ruby-comment cmt">## DELETE THIS IN 1.0.0</span>
340
- 129: <span class="ruby-identifier">warn</span>( <span class="ruby-value str">&quot;json is deprecated and will be removed in version 1.0, please use `render( :json =&gt; ... )'&quot;</span> )
341
- 130: <span class="ruby-ivar">@response</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-value str">'application/json'</span>
342
- 131: <span class="ruby-identifier">d</span>.<span class="ruby-identifier">to_json</span>
343
- 132: <span class="ruby-keyword kw">end</span>
338
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 138</span>
339
+ 138: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">json</span>( <span class="ruby-identifier">d</span> ) <span class="ruby-comment cmt">## DELETE THIS IN 1.0.0</span>
340
+ 139: <span class="ruby-identifier">warn</span>( <span class="ruby-value str">&quot;json is deprecated and will be removed in version 1.0, please use `render( :json =&gt; ... )'&quot;</span> )
341
+ 140: <span class="ruby-ivar">@response</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-value str">'application/json'</span>
342
+ 141: <span class="ruby-identifier">d</span>.<span class="ruby-identifier">to_json</span>
343
+ 142: <span class="ruby-keyword kw">end</span>
344
344
  </pre>
345
345
  </div>
346
346
  </div>
@@ -399,17 +399,17 @@ href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection">en
399
399
  onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
400
400
  <div class="method-source-code" id="M000017-source">
401
401
  <pre>
402
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 161</span>
403
- 161: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">redirect</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
404
- 162: <span class="ruby-identifier">httpCode</span> = <span class="ruby-value">302</span>
405
- 163:
406
- 164: <span class="ruby-keyword kw">if</span>( <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Fixnum</span> )
407
- 165: <span class="ruby-identifier">httpCode</span> = <span class="ruby-identifier">klass</span>
408
- 166: <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">shift</span>
409
- 167: <span class="ruby-keyword kw">end</span>
410
- 168:
411
- 169: [<span class="ruby-identifier">httpCode</span>, {<span class="ruby-value str">'Location'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">URL</span>(<span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span>)}, <span class="ruby-value str">''</span>]
412
- 170: <span class="ruby-keyword kw">end</span>
402
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 171</span>
403
+ 171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">redirect</span>( <span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span> )
404
+ 172: <span class="ruby-identifier">httpCode</span> = <span class="ruby-value">302</span>
405
+ 173:
406
+ 174: <span class="ruby-keyword kw">if</span>( <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Fixnum</span> )
407
+ 175: <span class="ruby-identifier">httpCode</span> = <span class="ruby-identifier">klass</span>
408
+ 176: <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">shift</span>
409
+ 177: <span class="ruby-keyword kw">end</span>
410
+ 178:
411
+ 179: [<span class="ruby-identifier">httpCode</span>, {<span class="ruby-value str">'Location'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">URL</span>(<span class="ruby-identifier">klass</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">a</span>)}, <span class="ruby-value str">''</span>]
412
+ 180: <span class="ruby-keyword kw">end</span>
413
413
  </pre>
414
414
  </div>
415
415
  </div>
@@ -505,38 +505,48 @@ If you use the WebDav renderer, you can use the option
505
505
  81: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Hash</span>
506
506
  82: <span class="ruby-identifier">render_type</span> = <span class="ruby-keyword kw">nil</span>
507
507
  83:
508
- 84: <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
509
- 85: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">&quot;render_#{key.to_s}&quot;</span>)
510
- 86: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span>
511
- 87: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">&quot;Can't use multiple renderer (`#{render_type}' and `#{key}') !&quot;</span>, <span class="ruby-identifier">caller</span>
512
- 88: <span class="ruby-keyword kw">end</span>
513
- 89: <span class="ruby-identifier">render_type</span> = <span class="ruby-identifier">key</span>
514
- 90: <span class="ruby-keyword kw">end</span>
515
- 91: <span class="ruby-keyword kw">end</span>
516
- 92:
517
- 93: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span>
518
- 94: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-value str">&quot;Renderer type not specified!&quot;</span>, <span class="ruby-identifier">caller</span>
519
- 95: <span class="ruby-keyword kw">end</span>
520
- 96:
521
- 97: <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">&quot;render_#{render_type.to_s}&quot;</span>)
522
- 98: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">&quot;#{render_type} renderer not present ! please require 'capcode/render/#{render_type}'&quot;</span>, <span class="ruby-identifier">caller</span>
523
- 99: <span class="ruby-keyword kw">end</span>
524
- 100:
525
- 101: <span class="ruby-identifier">render_name</span> = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">render_type</span>)
526
- 102: <span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:content_type</span>)
527
- 103: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">content_type</span>.<span class="ruby-identifier">nil?</span>
528
- 104: <span class="ruby-ivar">@response</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">content_type</span>
529
- 105: <span class="ruby-keyword kw">end</span>
530
- 106:
531
- 107: <span class="ruby-keyword kw">begin</span>
532
- 108: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>( <span class="ruby-node">&quot;render_#{render_type.to_s}&quot;</span>, <span class="ruby-identifier">render_name</span>, <span class="ruby-identifier">hash</span> )
533
- 109: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
534
- 110: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">&quot;Error rendering `#{render_type.to_s}' : #{e.message}&quot;</span>, <span class="ruby-identifier">caller</span>
535
- 111: <span class="ruby-keyword kw">end</span>
536
- 112: <span class="ruby-keyword kw">else</span>
537
- 113: <span class="ruby-identifier">render</span>( <span class="ruby-identifier">:text</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">hash</span> )
538
- 114: <span class="ruby-keyword kw">end</span>
539
- 115: <span class="ruby-keyword kw">end</span>
508
+ 84: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span>
509
+ 85: <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
510
+ 86: <span class="ruby-keyword kw">begin</span>
511
+ 87: <span class="ruby-identifier">gem</span> <span class="ruby-node">&quot;capcode-render-#{key.to_s}&quot;</span>
512
+ 88: <span class="ruby-identifier">require</span> <span class="ruby-node">&quot;capcode/render/#{key.to_s}&quot;</span>
513
+ 89: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">LoadError</span>
514
+ 90: <span class="ruby-keyword kw">nil</span>
515
+ 91: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
516
+ 92: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">&quot;Hum... The #{key} renderer is malformated! Please try to install a new version or use an other renderer!&quot;</span>, <span class="ruby-identifier">caller</span>
517
+ 93: <span class="ruby-keyword kw">end</span>
518
+ 94:
519
+ 95: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">&quot;render_#{key.to_s}&quot;</span>)
520
+ 96: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span>
521
+ 97: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">&quot;Can't use multiple renderer (`#{render_type}' and `#{key}') !&quot;</span>, <span class="ruby-identifier">caller</span>
522
+ 98: <span class="ruby-keyword kw">end</span>
523
+ 99: <span class="ruby-identifier">render_type</span> = <span class="ruby-identifier">key</span>
524
+ 100: <span class="ruby-keyword kw">end</span>
525
+ 101: <span class="ruby-keyword kw">end</span>
526
+ 102:
527
+ 103: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">render_type</span>.<span class="ruby-identifier">nil?</span>
528
+ 104: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-value str">&quot;Renderer type not specified!&quot;</span>, <span class="ruby-identifier">caller</span>
529
+ 105: <span class="ruby-keyword kw">end</span>
530
+ 106: <span class="ruby-keyword kw">end</span>
531
+ 107: <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">&quot;render_#{render_type.to_s}&quot;</span>)
532
+ 108: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">&quot;#{render_type} renderer not present ! please require 'capcode/render/#{render_type}'&quot;</span>, <span class="ruby-identifier">caller</span>
533
+ 109: <span class="ruby-keyword kw">end</span>
534
+ 110:
535
+ 111: <span class="ruby-identifier">render_name</span> = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">render_type</span>)
536
+ 112: <span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:content_type</span>)
537
+ 113: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">content_type</span>.<span class="ruby-identifier">nil?</span>
538
+ 114: <span class="ruby-ivar">@response</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-identifier">content_type</span>
539
+ 115: <span class="ruby-keyword kw">end</span>
540
+ 116:
541
+ 117: <span class="ruby-keyword kw">begin</span>
542
+ 118: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>( <span class="ruby-node">&quot;render_#{render_type.to_s}&quot;</span>, <span class="ruby-identifier">render_name</span>, <span class="ruby-identifier">hash</span> )
543
+ 119: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
544
+ 120: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">RenderError</span>, <span class="ruby-node">&quot;Error rendering `#{render_type.to_s}' : #{e.message}&quot;</span>, <span class="ruby-identifier">caller</span>
545
+ 121: <span class="ruby-keyword kw">end</span>
546
+ 122: <span class="ruby-keyword kw">else</span>
547
+ 123: <span class="ruby-identifier">render</span>( <span class="ruby-identifier">:text</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">hash</span> )
548
+ 124: <span class="ruby-keyword kw">end</span>
549
+ 125: <span class="ruby-keyword kw">end</span>
540
550
  </pre>
541
551
  </div>
542
552
  </div>
@@ -570,13 +580,13 @@ the <a href="Helpers.html#M000020">static</a> directory on the server
570
580
  onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
571
581
  <div class="method-source-code" id="M000020-source">
572
582
  <pre>
573
- <span class="ruby-comment cmt"># File lib/capcode.rb, line 243</span>
574
- 243: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">static</span>
575
- 244: {
576
- 245: <span class="ruby-identifier">:uri</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>,
577
- 246: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;.&quot;</span>, <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span> ) )
578
- 247: }
579
- 248: <span class="ruby-keyword kw">end</span>
583
+ <span class="ruby-comment cmt"># File lib/capcode.rb, line 253</span>
584
+ 253: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">static</span>
585
+ 254: {
586
+ 255: <span class="ruby-identifier">:uri</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>,
587
+ 256: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;.&quot;</span>, <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span> ) )
588
+ 257: }
589
+ 258: <span class="ruby-keyword kw">end</span>
580
590
  </pre>
581
591
  </div>
582
592
  </div>
@@ -1 +1 @@
1
- Thu, 07 Jan 2010 00:27:00 +0100
1
+ Wed, 27 Jan 2010 20:49:26 +0100
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Thu Jan 07 00:23:27 +0100 2010</td>
59
+ <td>Wed Jan 27 14:01:28 +0100 2010</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -91,6 +91,16 @@ href="http://www.algorithmique.net/capcode">www.algorithmique.net/capcode</a>/
91
91
  <a href="../classes/Capcode.html">Capcode</a> is a web microframework
92
92
  </p>
93
93
  <h2>FEATURES/PROBLEMS:</h2>
94
+ <h3>0.9.1</h3>
95
+ <ul>
96
+ <li>You don&#8216;t need to require the renderers. This will be done by <a
97
+ href="../classes/Capcode.html">Capcode</a> at use time.
98
+
99
+ </li>
100
+ <li>Major bug correction for jRuby
101
+
102
+ </li>
103
+ </ul>
94
104
  <h3>0.9.0</h3>
95
105
  <ul>
96
106
  <li><b>IMPORTANT</b>
@@ -513,12 +523,13 @@ for complete examples.
513
523
  # file: sample.rb
514
524
  require 'rubygems'
515
525
  require 'capcode'
516
- require 'capcode/render/markaby'
517
526
 
518
527
  module Capcode
519
528
  class Hello &lt; Route '/hello'
520
529
  def get
521
530
  @t = Time.now
531
+
532
+ # This implies that capcode-render-markaby is installed !
522
533
  render :markaby =&gt; :time
523
534
  end
524
535
  end
@@ -545,13 +556,15 @@ for complete examples.
545
556
  # file: sample.rb
546
557
  require 'rubygems'
547
558
  require 'capcode'
548
- require 'capcode/render/haml'
549
- Capcode::Helpers.haml_path = &quot;./my_haml_views&quot;
550
559
 
551
560
  module Capcode
561
+ set :haml, &quot;./my_haml_views&quot;
562
+
552
563
  class Hello &lt; Route '/hello'
553
564
  def get
554
565
  @t = Time.now
566
+
567
+ # This implies that capcode-render-haml is installed !
555
568
  render :haml =&gt; :time
556
569
  end
557
570
  end
@@ -571,12 +584,13 @@ for complete examples.
571
584
  # file: sample.rb
572
585
  require 'rubygems'
573
586
  require 'capcode'
574
- require 'capcode/render/json'
575
587
 
576
588
  module Capcode
577
589
  class Hello &lt; Route '/hello'
578
590
  def get
579
591
  @t = Time.now
592
+
593
+ # This implies that capcode-render-json is installed !
580
594
  render :json =&gt; { :time =&gt; @t }
581
595
  end
582
596
  end
@@ -589,13 +603,13 @@ for complete examples.
589
603
  # file: sample.rb
590
604
  require 'rubygems'
591
605
  require 'capcode'
592
- require 'capcode/render/webdav'
593
606
 
594
607
  module Capcode
595
608
 
596
609
  # !!! Render file from /Users/greg/temp !!!
597
610
  class WebDav &lt; Route '/temp'
598
611
  def get
612
+ # This implies that capcode-render-webdav is installed !
599
613
  render :webdav =&gt; &quot;/Users/greg/temp&quot;
600
614
  end
601
615
 
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Tue Jan 05 17:03:42 +0100 2010</td>
59
+ <td>Wed Jan 27 14:00:59 +0100 2010</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -113,7 +113,7 @@ Please read the README.rdoc file !
113
113
  <div class="name-list">
114
114
  <table summary="aliases">
115
115
  <tr class="top-aligned-row context-row">
116
- <td class="context-item-name">"<<"</td>
116
+ <td class="context-item-name"><<</td>
117
117
  <td>-&gt;</td>
118
118
  <td class="context-item-value">write</td>
119
119
  </tr>
@@ -1,7 +1,6 @@
1
1
  $:.unshift( "../lib" )
2
2
  require 'capcode'
3
3
  require 'rubygems'
4
- require 'capcode/render/markaby'
5
4
  require 'graphviz'
6
5
  require 'base64'
7
6
 
@@ -40,8 +39,8 @@ module Capcode
40
39
 
41
40
  class Inline < Route '/inline/(.*)'
42
41
  def get(path)
43
- @image = Base64.b64encode(hello(path))
44
-
42
+ @image = Base64.encode64(hello(path))
43
+
45
44
  render :markaby => :inline
46
45
  end
47
46
  end
@@ -1,7 +1,6 @@
1
1
  $:.unshift( "../lib" )
2
2
  require 'capcode'
3
3
  require 'rubygems'
4
- require 'capcode/render/markaby'
5
4
 
6
5
  module Capcode
7
6
  class Index < Route '/'
@@ -1,10 +1,6 @@
1
1
  $:.unshift( "../lib" )
2
2
  require 'capcode'
3
3
  require 'rubygems'
4
- require 'capcode/render/markaby'
5
- require 'capcode/render/haml'
6
- require 'capcode/render/json'
7
- require 'capcode/render/erb'
8
4
 
9
5
  module Capcode
10
6
  module Helpers
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'capcode'
3
- require 'capcode/render/erb'
4
3
  require 'faye'
5
4
 
6
5
  module Capcode
@@ -1,8 +1,6 @@
1
1
  $:.unshift( "../lib" )
2
2
  require 'capcode'
3
3
  require 'rubygems'
4
- require 'capcode/render/markaby'
5
- require 'capcode/render/static'
6
4
  require 'fileutils'
7
5
 
8
6
  module Capcode
@@ -4,7 +4,7 @@ require 'rubygems'
4
4
  require 'rack'
5
5
  require 'json' ## DELETE THIS IN 1.0.0
6
6
  require 'logger'
7
- Logger.class_eval { alias :write :"<<" } unless Logger.instance_methods.include? "write"
7
+ Logger.class_eval { alias :write :<< } unless Logger.instance_methods.include? "write"
8
8
  require 'optparse'
9
9
  require 'irb'
10
10
  require 'mime/types'
@@ -81,19 +81,29 @@ module Capcode
81
81
  if hash.class == Hash
82
82
  render_type = nil
83
83
 
84
- hash.keys.each do |key|
85
- if self.respond_to?("render_#{key.to_s}")
86
- unless render_type.nil?
87
- raise Capcode::RenderError, "Can't use multiple renderer (`#{render_type}' and `#{key}') !", caller
84
+ if render_type.nil?
85
+ hash.keys.each do |key|
86
+ begin
87
+ gem "capcode-render-#{key.to_s}"
88
+ require "capcode/render/#{key.to_s}"
89
+ rescue Gem::LoadError
90
+ nil
91
+ rescue LoadError
92
+ raise Capcode::RenderError, "Hum... The #{key} renderer is malformated! Please try to install a new version or use an other renderer!", caller
93
+ end
94
+
95
+ if self.respond_to?("render_#{key.to_s}")
96
+ unless render_type.nil?
97
+ raise Capcode::RenderError, "Can't use multiple renderer (`#{render_type}' and `#{key}') !", caller
98
+ end
99
+ render_type = key
88
100
  end
89
- render_type = key
101
+ end
102
+
103
+ if render_type.nil?
104
+ raise Capcode::RenderError, "Renderer type not specified!", caller
90
105
  end
91
106
  end
92
-
93
- if render_type.nil?
94
- raise Capcode::RenderError, "Renderer type not specified!", caller
95
- end
96
-
97
107
  unless self.respond_to?("render_#{render_type.to_s}")
98
108
  raise Capcode::RenderError, "#{render_type} renderer not present ! please require 'capcode/render/#{render_type}'", caller
99
109
  end
@@ -12,6 +12,11 @@ class Regexp
12
12
  end
13
13
  c
14
14
  end
15
+
16
+ # From http://facets.rubyforge.org/apidoc/api/core/classes/Regexp.html
17
+ def arity #:nodoc:
18
+ self.source.scan( /(?!\\)[(](?!\?[#=:!>-imx])/ ).length
19
+ end
15
20
  end
16
21
 
17
22
  class Hash
@@ -1,3 +1,3 @@
1
1
  module Capcode
2
- CAPCOD_VERION="0.9.0"
2
+ CAPCOD_VERION="0.9.1"
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.9.0
4
+ version: 0.9.1
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: 2010-01-07 00:00:00 +01:00
12
+ date: 2010-01-27 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -113,7 +113,7 @@ licenses: []
113
113
  post_install_message: "\n\
114
114
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\
115
115
  !! !!\n\
116
- !! THIS VERSION IS A MAJOR ENHANCEMENT !!\n\
116
+ !! 0.9.0 WAS A MAJOR ENHANCEMENT !!\n\
117
117
  !! ----------------------------------- !!\n\
118
118
  !! !!\n\
119
119
  !! YOU MUST UNINSTALL ALL PREVIOUS !!\n\