Capcode 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -5
- data/doc/rdoc/classes/Capcode.html +394 -394
- data/doc/rdoc/classes/Capcode/Helpers.html +88 -78
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README_rdoc.html +20 -6
- data/doc/rdoc/files/lib/capcode_rb.html +2 -2
- data/examples/render-image.rb +2 -3
- data/examples/rest.rb +0 -1
- data/examples/sample.rb +0 -4
- data/examples/soapbox/soapbox.rb +0 -1
- data/examples/upload.rb +0 -2
- data/lib/capcode.rb +21 -11
- data/lib/capcode/core_ext.rb +5 -0
- data/lib/capcode/version.rb +1 -1
- metadata +3 -3
@@ -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
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
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">></span><span class="ruby-value">0</span>)<span class="ruby-operator">?</span>(<span class="ruby-value str">"/"</span><span class="ruby-operator">+</span><span class="ruby-identifier">a</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"/"</span>))<span class="ruby-operator">:</span>(<span class="ruby-value str">""</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
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
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> => 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
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
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">"json is deprecated and will be removed in version 1.0, please use `render( :json => ... )'"</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
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
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">></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-
|
509
|
-
85: <span class="ruby-
|
510
|
-
86: <span class="ruby-keyword kw">
|
511
|
-
87: <span class="ruby-identifier">
|
512
|
-
88:
|
513
|
-
89: <span class="ruby-
|
514
|
-
90:
|
515
|
-
91:
|
516
|
-
92:
|
517
|
-
93:
|
518
|
-
94:
|
519
|
-
95:
|
520
|
-
96:
|
521
|
-
97:
|
522
|
-
98:
|
523
|
-
99:
|
524
|
-
100:
|
525
|
-
101:
|
526
|
-
102:
|
527
|
-
103:
|
528
|
-
104:
|
529
|
-
105:
|
530
|
-
106:
|
531
|
-
107: <span class="ruby-keyword kw">
|
532
|
-
108: <span class="ruby-
|
533
|
-
109: <span class="ruby-keyword kw">
|
534
|
-
110:
|
535
|
-
111: <span class="ruby-
|
536
|
-
112:
|
537
|
-
113: <span class="ruby-
|
538
|
-
114:
|
539
|
-
115:
|
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">"capcode-render-#{key.to_s}"</span>
|
512
|
+
88: <span class="ruby-identifier">require</span> <span class="ruby-node">"capcode/render/#{key.to_s}"</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">"Hum... The #{key} renderer is malformated! Please try to install a new version or use an other renderer!"</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">"render_#{key.to_s}"</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">"Can't use multiple renderer (`#{render_type}' and `#{key}') !"</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">"Renderer type not specified!"</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">"render_#{render_type.to_s}"</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">"#{render_type} renderer not present ! please require 'capcode/render/#{render_type}'"</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">"render_#{render_type.to_s}"</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">></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">"Error rendering `#{render_type.to_s}' : #{e.message}"</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">></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
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
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">></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">></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">"."</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>
|
data/doc/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
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>
|
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‘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 < 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 => :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 = "./my_haml_views"
|
550
559
|
|
551
560
|
module Capcode
|
561
|
+
set :haml, "./my_haml_views"
|
562
|
+
|
552
563
|
class Hello < 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 => :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 < 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 => { :time => @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 < Route '/temp'
|
598
611
|
def get
|
612
|
+
# This implies that capcode-render-webdav is installed !
|
599
613
|
render :webdav => "/Users/greg/temp"
|
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>
|
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"
|
116
|
+
<td class="context-item-name"><<</td>
|
117
117
|
<td>-></td>
|
118
118
|
<td class="context-item-value">write</td>
|
119
119
|
</tr>
|
data/examples/render-image.rb
CHANGED
@@ -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.
|
44
|
-
|
42
|
+
@image = Base64.encode64(hello(path))
|
43
|
+
|
45
44
|
render :markaby => :inline
|
46
45
|
end
|
47
46
|
end
|
data/examples/rest.rb
CHANGED
data/examples/sample.rb
CHANGED
data/examples/soapbox/soapbox.rb
CHANGED
data/examples/upload.rb
CHANGED
data/lib/capcode.rb
CHANGED
@@ -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
|
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
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
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
|
-
|
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
|
data/lib/capcode/core_ext.rb
CHANGED
data/lib/capcode/version.rb
CHANGED
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.
|
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-
|
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
|
-
!!
|
116
|
+
!! 0.9.0 WAS A MAJOR ENHANCEMENT !!\n\
|
117
117
|
!! ----------------------------------- !!\n\
|
118
118
|
!! !!\n\
|
119
119
|
!! YOU MUST UNINSTALL ALL PREVIOUS !!\n\
|