Capcode 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -0
- data/doc/rdoc/classes/Capcode.html +202 -201
- data/doc/rdoc/classes/Capcode/Configuration.html +65 -39
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README_rdoc.html +10 -1
- data/doc/rdoc/files/lib/capcode/configuration_rb.html +1 -1
- data/doc/rdoc/files/lib/capcode_rb.html +1 -1
- data/doc/rdoc/fr_method_index.html +4 -3
- data/lib/capcode.rb +1 -0
- data/lib/capcode/configuration.rb +6 -0
- data/lib/capcode/ext/rack/urlmap.rb +13 -4
- data/lib/capcode/version.rb +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -400,7 +400,7 @@ Return the Rack App.
|
|
400
400
|
</p>
|
401
401
|
<p>
|
402
402
|
Options : see <a
|
403
|
-
href="Capcode/Configuration.html#
|
403
|
+
href="Capcode/Configuration.html#M000024">Capcode::Configuration.set</a>
|
404
404
|
</p>
|
405
405
|
<p>
|
406
406
|
Options <a href="Capcode.html#M000012">set</a> here replace the ones <a
|
@@ -413,80 +413,81 @@ href="Capcode.html#M000012">set</a> globally
|
|
413
413
|
<span class="ruby-comment cmt"># File lib/capcode.rb, line 590</span>
|
414
414
|
590: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">application</span>( <span class="ruby-identifier">args</span> = {} )
|
415
415
|
591: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
|
416
|
-
592:
|
417
|
-
593:
|
418
|
-
594:
|
419
|
-
595:
|
420
|
-
596: <span class="ruby-value str">"
|
421
|
-
597: <span class="ruby-value str">"
|
422
|
-
598: <span class="ruby-value str">"
|
423
|
-
599: <span class="ruby-value str">"
|
424
|
-
600: <span class="ruby-value str">"
|
425
|
-
601: <span class="ruby-value str">"
|
426
|
-
602: <span class="ruby-value str">"
|
427
|
-
603: <span class="ruby-value str">"
|
428
|
-
604: <span class="ruby-value str">"
|
429
|
-
605:
|
430
|
-
606:
|
431
|
-
607:
|
432
|
-
608:
|
433
|
-
609:
|
434
|
-
610: <span class="ruby-identifier">hash_of_routes</span
|
435
|
-
611:
|
436
|
-
612: <span class="ruby-
|
437
|
-
613: <span class="ruby-
|
438
|
-
614:
|
439
|
-
615:
|
440
|
-
616:
|
441
|
-
617:
|
442
|
-
618:
|
443
|
-
619:
|
444
|
-
620:
|
445
|
-
621:
|
446
|
-
622:
|
447
|
-
623: <span class="ruby-
|
448
|
-
624:
|
449
|
-
625:
|
450
|
-
626: <span class="ruby-
|
451
|
-
627: <span class="ruby-
|
452
|
-
628:
|
453
|
-
629: <span class="ruby-identifier">
|
454
|
-
630: <span class="ruby-identifier">
|
455
|
-
631:
|
456
|
-
632: <span class="ruby-
|
457
|
-
633: <span class="ruby-
|
458
|
-
634: <span class="ruby-identifier">:
|
459
|
-
635:
|
460
|
-
636:
|
461
|
-
637: <span class="ruby-identifier">
|
462
|
-
638: <span class="ruby-identifier">app</span> = <span class="ruby-constant">
|
463
|
-
639: <span class="ruby-identifier">app</span> = <span class="ruby-constant">
|
464
|
-
640: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">
|
465
|
-
641: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">
|
466
|
-
642: <span class="ruby-
|
467
|
-
643:
|
468
|
-
644:
|
469
|
-
645:
|
470
|
-
646: <span class="ruby-identifier">
|
471
|
-
647: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">
|
472
|
-
648:
|
473
|
-
649:
|
474
|
-
650:
|
475
|
-
651:
|
476
|
-
652:
|
477
|
-
653:
|
478
|
-
654:
|
479
|
-
655: <span class="ruby-
|
480
|
-
656:
|
481
|
-
657:
|
482
|
-
658:
|
483
|
-
659:
|
484
|
-
660:
|
485
|
-
661: <span class="ruby-keyword kw">
|
486
|
-
662:
|
487
|
-
663:
|
488
|
-
664:
|
489
|
-
665:
|
416
|
+
592: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">print_debug</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
|
417
|
+
593:
|
418
|
+
594: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">clone</span>.<span class="ruby-identifier">delete_if</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
419
|
+
595: <span class="ruby-keyword kw">not</span>( <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">k</span>).<span class="ruby-identifier">to_s</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/Capcode/</span> ) <span class="ruby-keyword kw">or</span> [
|
420
|
+
596: <span class="ruby-value str">"Filter"</span>,
|
421
|
+
597: <span class="ruby-value str">"Helpers"</span>,
|
422
|
+
598: <span class="ruby-value str">"RouteError"</span>,
|
423
|
+
599: <span class="ruby-value str">"Views"</span>,
|
424
|
+
600: <span class="ruby-value str">"ParameterError"</span>,
|
425
|
+
601: <span class="ruby-value str">"HTTPError"</span>,
|
426
|
+
602: <span class="ruby-value str">"Configuration"</span>,
|
427
|
+
603: <span class="ruby-value str">"MissingLibrary"</span>,
|
428
|
+
604: <span class="ruby-value str">"Route"</span>,
|
429
|
+
605: <span class="ruby-value str">"RenderError"</span>
|
430
|
+
606: ].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>)
|
431
|
+
607: }.<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>
|
432
|
+
608: <span class="ruby-keyword kw">begin</span>
|
433
|
+
609: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">eval</span> <span class="ruby-node">"Capcode::#{k}.public_methods(true).include?( '__urls__' )"</span>
|
434
|
+
610: <span class="ruby-identifier">hash_of_routes</span>, <span class="ruby-identifier">max_captures_for_routes</span>, <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">eval</span> <span class="ruby-node">"Capcode::#{k}.__urls__"</span>
|
435
|
+
611: <span class="ruby-identifier">hash_of_routes</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">current_route_path</span><span class="ruby-operator">|</span>
|
436
|
+
612: <span class="ruby-comment cmt">#raise Capcode::RouteError, "Route `#{current_route_path}' already define !", caller if @@__ROUTES.keys.include?(current_route_path)</span>
|
437
|
+
613: <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">"Route `#{current_route_path}' already define !"</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">current_route_path</span>)
|
438
|
+
614: <span class="ruby-comment cmt"># Capcode.routes[current_route_path] = klass.new</span>
|
439
|
+
615: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>[<span class="ruby-identifier">current_route_path</span>] = <span class="ruby-identifier">klass</span>
|
440
|
+
616: <span class="ruby-keyword kw">end</span>
|
441
|
+
617: <span class="ruby-keyword kw">end</span>
|
442
|
+
618: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
443
|
+
619: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
|
444
|
+
620: <span class="ruby-keyword kw">end</span>
|
445
|
+
621: <span class="ruby-keyword kw">end</span>
|
446
|
+
622:
|
447
|
+
623: <span class="ruby-comment cmt"># Set Static directory</span>
|
448
|
+
624: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span> = (<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">chr</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"/"</span>)<span class="ruby-operator">?</span><span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>)<span class="ruby-operator">:</span><span class="ruby-value str">"/"</span><span class="ruby-operator">+</span><span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>).<span class="ruby-identifier">nil?</span>
|
449
|
+
625:
|
450
|
+
626: <span class="ruby-comment cmt"># Initialize Rack App</span>
|
451
|
+
627: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"** Map routes."</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
|
452
|
+
628: <span class="ruby-comment cmt"># app = Rack::URLMap.new(Capcode.routes)</span>
|
453
|
+
629: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Ext</span><span class="ruby-operator">::</span><span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">URLMap</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">routes</span>)
|
454
|
+
630: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Initialize static directory (#{Capcode.static}) in #{File.expand_path(Capcode::Configuration.get(:root))}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
|
455
|
+
631: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Static</span>.<span class="ruby-identifier">new</span>(
|
456
|
+
632: <span class="ruby-identifier">app</span>,
|
457
|
+
633: <span class="ruby-comment cmt">#:urls => [@@__STATIC_DIR], </span>
|
458
|
+
634: <span class="ruby-identifier">:urls</span> =<span class="ruby-operator">></span> [<span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">static</span>],
|
459
|
+
635: <span class="ruby-identifier">:root</span> =<span class="ruby-operator">></span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:root</span>))
|
460
|
+
636: ) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:static</span>).<span class="ruby-identifier">nil?</span>
|
461
|
+
637: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"** Initialize session"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
|
462
|
+
638: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:session</span>) )
|
463
|
+
639: <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>)
|
464
|
+
640: <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>)
|
465
|
+
641: <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>)
|
466
|
+
642: <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>)
|
467
|
+
643: <span class="ruby-comment cmt">#app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
|
468
|
+
644:
|
469
|
+
645: <span class="ruby-identifier">middlewares</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mw</span><span class="ruby-operator">|</span>
|
470
|
+
646: <span class="ruby-identifier">middleware</span>, <span class="ruby-identifier">args</span>, <span class="ruby-identifier">block</span> = <span class="ruby-identifier">mw</span>
|
471
|
+
647: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Load middleware #{middleware}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
|
472
|
+
648: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block</span>
|
473
|
+
649: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">middleware</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
474
|
+
650: <span class="ruby-keyword kw">else</span>
|
475
|
+
651: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">middleware</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span> )
|
476
|
+
652: <span class="ruby-keyword kw">end</span>
|
477
|
+
653: <span class="ruby-keyword kw">end</span>
|
478
|
+
654:
|
479
|
+
655: <span class="ruby-comment cmt"># Start database</span>
|
480
|
+
656: <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">"db_connect"</span>
|
481
|
+
657: <span class="ruby-identifier">db_connect</span>( <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:db_config</span>), <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:log</span>) )
|
482
|
+
658: <span class="ruby-keyword kw">end</span>
|
483
|
+
659:
|
484
|
+
660: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
485
|
+
661: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"** Execute block"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
|
486
|
+
662: <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> )
|
487
|
+
663: <span class="ruby-keyword kw">end</span>
|
488
|
+
664:
|
489
|
+
665: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">app</span>
|
490
|
+
666: <span class="ruby-keyword kw">end</span>
|
490
491
|
</pre>
|
491
492
|
</div>
|
492
493
|
</div>
|
@@ -760,7 +761,7 @@ Start your <a href="Capcode.html#M000010">application</a>.
|
|
760
761
|
</p>
|
761
762
|
<p>
|
762
763
|
Options : see <a
|
763
|
-
href="Capcode/Configuration.html#
|
764
|
+
href="Capcode/Configuration.html#M000024">Capcode::Configuration.set</a>
|
764
765
|
</p>
|
765
766
|
<p>
|
766
767
|
Options <a href="Capcode.html#M000012">set</a> here replace the ones <a
|
@@ -770,131 +771,131 @@ href="Capcode.html#M000012">set</a> globally
|
|
770
771
|
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
771
772
|
<div class="method-source-code" id="M000011-source">
|
772
773
|
<pre>
|
773
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
774
|
+
<span class="ruby-comment cmt"># File lib/capcode.rb, line 673</span>
|
775
|
+
673: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>( <span class="ruby-identifier">args</span> = {} )
|
776
|
+
674: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">configuration</span>(<span class="ruby-identifier">args</span>)
|
777
|
+
675:
|
778
|
+
676: <span class="ruby-comment cmt"># Parse options</span>
|
779
|
+
677: <span class="ruby-identifier">opts</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span>
|
780
|
+
678: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">"Usage: #{File.basename($0)} [options]"</span>
|
781
|
+
679: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">""</span>
|
782
|
+
680: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">"Specific options:"</span>
|
783
|
+
681:
|
784
|
+
682: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-C"</span>, <span class="ruby-value str">"--console"</span>, <span class="ruby-value str">"Run in console mode with IRB (default: false)"</span> ) {
|
785
|
+
683: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:console</span>, <span class="ruby-keyword kw">true</span>
|
786
|
+
684: }
|
787
|
+
685: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-h"</span>, <span class="ruby-value str">"--host HOSTNAME"</span>, <span class="ruby-node">"Host for web server to bind to (default: #{Capcode::Configuration.get(:host)})"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
|
788
|
+
686: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:host</span>, <span class="ruby-identifier">h</span>
|
789
|
+
687: }
|
790
|
+
688: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-p"</span>, <span class="ruby-value str">"--port NUM"</span>, <span class="ruby-node">"Port for web server (default: #{Capcode::Configuration.get(:port)})"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
|
791
|
+
689: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:port</span>, <span class="ruby-identifier">p</span>
|
792
|
+
690: }
|
793
|
+
691: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-d"</span>, <span class="ruby-value str">"--daemonize [true|false]"</span>, <span class="ruby-node">"Daemonize (default: #{Capcode::Configuration.get(:daemonize)})"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
|
794
|
+
692: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:daemonize</span>, <span class="ruby-identifier">d</span>
|
795
|
+
693: }
|
796
|
+
694: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-r"</span>, <span class="ruby-value str">"--root PATH"</span>, <span class="ruby-node">"Working directory (default: #{Capcode::Configuration.get(:root)})"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
|
797
|
+
695: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:root</span>, <span class="ruby-identifier">w</span>
|
798
|
+
696: }
|
799
|
+
697: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>( <span class="ruby-value str">"-s"</span>, <span class="ruby-value str">"--static PATH"</span>, <span class="ruby-node">"Static directory -- relative to the root directory (default: #{Capcode::Configuration.get(:static)})"</span> ) { <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
|
800
|
+
698: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:static</span>, <span class="ruby-identifier">r</span>
|
801
|
+
699: }
|
802
|
+
700:
|
803
|
+
701: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">""</span>
|
804
|
+
702: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-value str">"Common options:"</span>
|
805
|
+
703:
|
806
|
+
704: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-?"</span>, <span class="ruby-value str">"--help"</span>, <span class="ruby-value str">"Show this message"</span>) <span class="ruby-keyword kw">do</span>
|
807
|
+
705: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>
|
808
|
+
706: <span class="ruby-identifier">exit</span>
|
809
|
+
707: <span class="ruby-keyword kw">end</span>
|
810
|
+
708: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value str">"-v"</span>, <span class="ruby-value str">"--version"</span>, <span class="ruby-value str">"Show versions"</span>) <span class="ruby-keyword kw">do</span>
|
811
|
+
709: <span class="ruby-identifier">puts</span> <span class="ruby-node">"Capcode version #{Capcode::CAPCOD_VERION} (ruby v#{RUBY_VERSION})"</span>
|
812
|
+
710: <span class="ruby-identifier">exit</span>
|
813
|
+
711: <span class="ruby-keyword kw">end</span>
|
814
|
+
712: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>( <span class="ruby-value str">"-V"</span>, <span class="ruby-value str">"--verbose"</span>, <span class="ruby-value str">"Run in verbose mode"</span> ) <span class="ruby-keyword kw">do</span>
|
815
|
+
713: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:verbose</span>, <span class="ruby-keyword kw">true</span>
|
816
|
+
714: <span class="ruby-keyword kw">end</span>
|
817
|
+
715: <span class="ruby-keyword kw">end</span>
|
818
|
+
716:
|
819
|
+
717: <span class="ruby-keyword kw">begin</span>
|
820
|
+
718: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span> <span class="ruby-constant">ARGV</span>
|
821
|
+
719: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">ParseError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
822
|
+
720: <span class="ruby-identifier">puts</span> <span class="ruby-node">"!! #{ex.message}"</span>
|
823
|
+
721: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** use `#{File.basename($0)} --help` for more details..."</span>
|
824
|
+
722: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
|
825
|
+
723: <span class="ruby-keyword kw">end</span>
|
826
|
+
724:
|
827
|
+
725: <span class="ruby-comment cmt"># Run in the Working directory</span>
|
828
|
+
726: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Go on root directory (#{File.expand_path(Capcode::Configuration.get(:root))})"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:verbose</span>)
|
829
|
+
727: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:root</span>) ) <span class="ruby-keyword kw">do</span>
|
830
|
+
728:
|
831
|
+
729: <span class="ruby-comment cmt"># Check that mongrel exists </span>
|
832
|
+
730: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:server</span>).<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:server</span>) <span class="ruby-operator">==</span> <span class="ruby-value str">"mongrel"</span>
|
833
|
+
731: <span class="ruby-keyword kw">begin</span>
|
834
|
+
732: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
|
835
|
+
733: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:server</span>, <span class="ruby-identifier">:mongrel</span>
|
836
|
+
734: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
|
837
|
+
735: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"!! could not load mongrel. Falling back to webrick."</span>
|
838
|
+
736: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">set</span> <span class="ruby-identifier">:server</span>, <span class="ruby-identifier">:webrick</span>
|
839
|
+
737: <span class="ruby-keyword kw">end</span>
|
840
|
+
738: <span class="ruby-keyword kw">end</span>
|
841
|
+
739:
|
842
|
+
740: <span class="ruby-comment cmt"># From rackup !!!</span>
|
843
|
+
741: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:daemonize</span>)
|
844
|
+
742: <span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">/java/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-constant">RUBY_PLATFORM</span>).<span class="ruby-identifier">nil?</span>
|
845
|
+
743: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">RUBY_VERSION</span> <span class="ruby-operator"><</span> <span class="ruby-value str">"1.9"</span>
|
846
|
+
744: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
|
847
|
+
745: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
|
848
|
+
746: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
|
849
|
+
747: <span class="ruby-comment cmt"># Dir.chdir "/"</span>
|
850
|
+
748: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
|
851
|
+
749: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">"/dev/null"</span>
|
852
|
+
750: <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">"/dev/null"</span>, <span class="ruby-value str">"a"</span>
|
853
|
+
751: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">"/dev/null"</span>, <span class="ruby-value str">"a"</span>
|
854
|
+
752: <span class="ruby-keyword kw">else</span>
|
855
|
+
753: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
|
856
|
+
754: <span class="ruby-keyword kw">end</span>
|
857
|
+
755: <span class="ruby-keyword kw">else</span>
|
858
|
+
756: <span class="ruby-identifier">puts</span> <span class="ruby-node">"!! daemonize option unavailable on #{RUBY_PLATFORM} platform."</span>
|
859
|
+
757: <span class="ruby-keyword kw">end</span>
|
860
|
+
758:
|
861
|
+
759: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:pid</span>), <span class="ruby-value str">'w'</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">"#{Process.pid}"</span>) }
|
862
|
+
760: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:pid</span>)) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:pid</span>)) }
|
863
|
+
761: <span class="ruby-keyword kw">end</span>
|
864
|
+
762:
|
865
|
+
763: <span class="ruby-identifier">app</span> = <span class="ruby-keyword kw">nil</span>
|
866
|
+
764: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
867
|
+
765: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>) { <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> ) }
|
868
|
+
766: <span class="ruby-keyword kw">else</span>
|
869
|
+
767: <span class="ruby-identifier">app</span> = <span class="ruby-identifier">application</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>)
|
870
|
+
768: <span class="ruby-keyword kw">end</span>
|
871
|
+
769: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">CommonLogger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:log</span>)) )
|
872
|
+
770:
|
873
|
+
771: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:console</span>)
|
874
|
+
772: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"Run console..."</span>
|
875
|
+
773: <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">start</span>
|
876
|
+
774: <span class="ruby-identifier">exit</span>
|
877
|
+
775: <span class="ruby-keyword kw">end</span>
|
878
|
+
776:
|
879
|
+
777: <span class="ruby-comment cmt"># Start server</span>
|
880
|
+
778: <span class="ruby-keyword kw">case</span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:server</span>).<span class="ruby-identifier">to_s</span>
|
881
|
+
779: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"mongrel"</span>
|
882
|
+
780: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Starting Mongrel on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}"</span>
|
883
|
+
781: <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">></span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:port</span>), <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
|
884
|
+
782: <span class="ruby-identifier">trap</span> <span class="ruby-value str">"SIGINT"</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">stop</span> }
|
885
|
+
783: }
|
886
|
+
784: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"webrick"</span>
|
887
|
+
785: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Starting WEBrick on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}"</span>
|
888
|
+
786: <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">></span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:port</span>), <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
|
889
|
+
787: <span class="ruby-identifier">trap</span> <span class="ruby-value str">"SIGINT"</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">shutdown</span> }
|
890
|
+
788: }
|
891
|
+
789: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"thin"</span>
|
892
|
+
790: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Starting Thin on #{Capcode::Configuration.get(:host)}:#{Capcode::Configuration.get(:port)}"</span>
|
893
|
+
791: <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span><span class="ruby-operator">::</span><span class="ruby-constant">Thin</span>.<span class="ruby-identifier">run</span>( <span class="ruby-identifier">app</span>, {<span class="ruby-identifier">:Port</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:port</span>), <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">:host</span>)} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
|
894
|
+
792: <span class="ruby-identifier">trap</span> <span class="ruby-value str">"SIGINT"</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">server</span>.<span class="ruby-identifier">stop</span> }
|
895
|
+
793: }
|
896
|
+
794: <span class="ruby-keyword kw">end</span>
|
897
|
+
795: <span class="ruby-keyword kw">end</span>
|
898
|
+
796: <span class="ruby-keyword kw">end</span>
|
898
899
|
</pre>
|
899
900
|
</div>
|
900
901
|
</div>
|
@@ -86,9 +86,10 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
90
|
-
<a href="#
|
91
|
-
<a href="#M000023">
|
89
|
+
<a href="#M000025">get</a>
|
90
|
+
<a href="#M000026">options</a>
|
91
|
+
<a href="#M000023">print_debug</a>
|
92
|
+
<a href="#M000024">set</a>
|
92
93
|
</div>
|
93
94
|
</div>
|
94
95
|
|
@@ -110,51 +111,51 @@
|
|
110
111
|
<div id="methods">
|
111
112
|
<h3 class="section-bar">Public Class methods</h3>
|
112
113
|
|
113
|
-
<div id="method-
|
114
|
-
<a name="
|
114
|
+
<div id="method-M000025" class="method-detail">
|
115
|
+
<a name="M000025"></a>
|
115
116
|
|
116
117
|
<div class="method-heading">
|
117
|
-
<a href="#
|
118
|
+
<a href="#M000025" class="method-signature">
|
118
119
|
<span class="method-name">get</span><span class="method-args">( key = nil )</span>
|
119
120
|
</a>
|
120
121
|
</div>
|
121
122
|
|
122
123
|
<div class="method-description">
|
123
124
|
<p><a class="source-toggle" href="#"
|
124
|
-
onclick="toggleCode('
|
125
|
-
<div class="method-source-code" id="
|
125
|
+
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
126
|
+
<div class="method-source-code" id="M000025-source">
|
126
127
|
<pre>
|
127
|
-
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
128
|
+
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 67</span>
|
129
|
+
67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>( <span class="ruby-identifier">key</span> = <span class="ruby-keyword kw">nil</span> )
|
130
|
+
68: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">nil?</span>
|
131
|
+
69: <span class="ruby-identifier">config</span>
|
132
|
+
70: <span class="ruby-keyword kw">else</span>
|
133
|
+
71: <span class="ruby-identifier">config</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">nil</span>
|
134
|
+
72: <span class="ruby-keyword kw">end</span>
|
135
|
+
73: <span class="ruby-keyword kw">end</span>
|
135
136
|
</pre>
|
136
137
|
</div>
|
137
138
|
</div>
|
138
139
|
</div>
|
139
140
|
|
140
|
-
<div id="method-
|
141
|
-
<a name="
|
141
|
+
<div id="method-M000026" class="method-detail">
|
142
|
+
<a name="M000026"></a>
|
142
143
|
|
143
144
|
<div class="method-heading">
|
144
|
-
<a href="#
|
145
|
+
<a href="#M000026" class="method-signature">
|
145
146
|
<span class="method-name">options</span><span class="method-args">()</span>
|
146
147
|
</a>
|
147
148
|
</div>
|
148
149
|
|
149
150
|
<div class="method-description">
|
150
151
|
<p><a class="source-toggle" href="#"
|
151
|
-
onclick="toggleCode('
|
152
|
-
<div class="method-source-code" id="
|
152
|
+
onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
|
153
|
+
<div class="method-source-code" id="M000026-source">
|
153
154
|
<pre>
|
154
|
-
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line
|
155
|
-
|
156
|
-
|
157
|
-
|
155
|
+
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 75</span>
|
156
|
+
75: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options</span>
|
157
|
+
76: <span class="ruby-ivar">@options</span> <span class="ruby-operator">||=</span> {}
|
158
|
+
77: <span class="ruby-keyword kw">end</span>
|
158
159
|
</pre>
|
159
160
|
</div>
|
160
161
|
</div>
|
@@ -165,13 +166,38 @@
|
|
165
166
|
|
166
167
|
<div class="method-heading">
|
167
168
|
<a href="#M000023" class="method-signature">
|
169
|
+
<span class="method-name">print_debug</span><span class="method-args">()</span>
|
170
|
+
</a>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
<div class="method-description">
|
174
|
+
<p><a class="source-toggle" href="#"
|
175
|
+
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
176
|
+
<div class="method-source-code" id="M000023-source">
|
177
|
+
<pre>
|
178
|
+
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 28</span>
|
179
|
+
28: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_debug</span>
|
180
|
+
29: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Configuration</span>.<span class="ruby-identifier">config</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>
|
181
|
+
30: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** [CONFIG] : #{k} = #{v}"</span>
|
182
|
+
31: <span class="ruby-keyword kw">end</span>
|
183
|
+
32: <span class="ruby-keyword kw">end</span>
|
184
|
+
</pre>
|
185
|
+
</div>
|
186
|
+
</div>
|
187
|
+
</div>
|
188
|
+
|
189
|
+
<div id="method-M000024" class="method-detail">
|
190
|
+
<a name="M000024"></a>
|
191
|
+
|
192
|
+
<div class="method-heading">
|
193
|
+
<a href="#M000024" class="method-signature">
|
168
194
|
<span class="method-name">set</span><span class="method-args">( key, value, opts = {} )</span>
|
169
195
|
</a>
|
170
196
|
</div>
|
171
197
|
|
172
198
|
<div class="method-description">
|
173
199
|
<p>
|
174
|
-
Set global configuration <a href="Configuration.html#
|
200
|
+
Set global configuration <a href="Configuration.html#M000026">options</a>
|
175
201
|
</p>
|
176
202
|
<p>
|
177
203
|
Options :
|
@@ -213,12 +239,12 @@ This is also the working directory !
|
|
213
239
|
|
214
240
|
</li>
|
215
241
|
<li><tt>:auth</tt> = HTTP Basic Authentication <a
|
216
|
-
href="Configuration.html#
|
242
|
+
href="Configuration.html#M000026">options</a>
|
217
243
|
|
218
244
|
</li>
|
219
245
|
</ul>
|
220
246
|
<p>
|
221
|
-
It can exist specifics <a href="Configuration.html#
|
247
|
+
It can exist specifics <a href="Configuration.html#M000026">options</a>
|
222
248
|
depending on a renderer, a helper, …
|
223
249
|
</p>
|
224
250
|
<p>
|
@@ -231,18 +257,18 @@ Example :
|
|
231
257
|
end
|
232
258
|
</pre>
|
233
259
|
<p><a class="source-toggle" href="#"
|
234
|
-
onclick="toggleCode('
|
235
|
-
<div class="method-source-code" id="
|
260
|
+
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
261
|
+
<div class="method-source-code" id="M000024-source">
|
236
262
|
<pre>
|
237
|
-
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
263
|
+
<span class="ruby-comment cmt"># File lib/capcode/configuration.rb, line 58</span>
|
264
|
+
58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set</span>( <span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">opts</span> = {} )
|
265
|
+
59: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">value</span>
|
266
|
+
60: <span class="ruby-identifier">opts</span> = <span class="ruby-identifier">value</span>
|
267
|
+
61: <span class="ruby-identifier">value</span> = <span class="ruby-keyword kw">nil</span>
|
268
|
+
62: <span class="ruby-keyword kw">end</span>
|
269
|
+
63: <span class="ruby-identifier">config</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
|
270
|
+
64: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">opts</span>
|
271
|
+
65: <span class="ruby-keyword kw">end</span>
|
246
272
|
</pre>
|
247
273
|
</div>
|
248
274
|
</div>
|
data/doc/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Tue, 01 Jun 2010 20:13:22 +0200
|
@@ -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>Tue Jun 01 18:08:07 +0200 2010</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -91,6 +91,15 @@ 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.6</h3>
|
95
|
+
<ul>
|
96
|
+
<li>More debug trace
|
97
|
+
|
98
|
+
</li>
|
99
|
+
<li>Bug correction in the custom version of Rack::URLmap
|
100
|
+
|
101
|
+
</li>
|
102
|
+
</ul>
|
94
103
|
<h3>0.9.5</h3>
|
95
104
|
<ul>
|
96
105
|
<li>Major bug correction
|
@@ -28,21 +28,22 @@
|
|
28
28
|
<a href="classes/Capcode.html#M000013">before_filter (Capcode)</a><br />
|
29
29
|
<a href="classes/Capcode/Helpers.html#M000020">content_for (Capcode::Helpers)</a><br />
|
30
30
|
<a href="classes/Capcode.html#M000003">env (Capcode)</a><br />
|
31
|
-
<a href="classes/Capcode/Configuration.html#
|
31
|
+
<a href="classes/Capcode/Configuration.html#M000025">get (Capcode::Configuration)</a><br />
|
32
32
|
<a href="classes/Capcode.html#M000009">http_authentication (Capcode)</a><br />
|
33
33
|
<a href="classes/Capcode/Helpers/Authorization.html#M000022">http_authentication (Capcode::Helpers::Authorization)</a><br />
|
34
34
|
<a href="classes/Capcode/Helpers.html#M000017">json (Capcode::Helpers)</a><br />
|
35
35
|
<a href="classes/Capcode.html#M000007">map (Capcode)</a><br />
|
36
|
-
<a href="classes/Capcode/Configuration.html#
|
36
|
+
<a href="classes/Capcode/Configuration.html#M000026">options (Capcode::Configuration)</a><br />
|
37
37
|
<a href="classes/Capcode.html#M000002">params (Capcode)</a><br />
|
38
|
+
<a href="classes/Capcode/Configuration.html#M000023">print_debug (Capcode::Configuration)</a><br />
|
38
39
|
<a href="classes/Capcode/Helpers.html#M000018">redirect (Capcode::Helpers)</a><br />
|
39
40
|
<a href="classes/Capcode/Helpers.html#M000016">render (Capcode::Helpers)</a><br />
|
40
41
|
<a href="classes/Capcode.html#M000005">request (Capcode)</a><br />
|
41
42
|
<a href="classes/Capcode.html#M000006">response (Capcode)</a><br />
|
42
43
|
<a href="classes/Capcode.html#M000011">run (Capcode)</a><br />
|
43
44
|
<a href="classes/Capcode.html#M000004">session (Capcode)</a><br />
|
45
|
+
<a href="classes/Capcode/Configuration.html#M000024">set (Capcode::Configuration)</a><br />
|
44
46
|
<a href="classes/Capcode.html#M000012">set (Capcode)</a><br />
|
45
|
-
<a href="classes/Capcode/Configuration.html#M000023">set (Capcode::Configuration)</a><br />
|
46
47
|
<a href="classes/Capcode/Helpers.html#M000021">static (Capcode::Helpers)</a><br />
|
47
48
|
<a href="classes/Capcode.html#M000008">use (Capcode)</a><br />
|
48
49
|
</div>
|
data/lib/capcode.rb
CHANGED
@@ -589,6 +589,7 @@ module Capcode
|
|
589
589
|
# Options set here replace the ones set globally
|
590
590
|
def application( args = {} )
|
591
591
|
Capcode::Configuration.configuration(args)
|
592
|
+
Capcode::Configuration.print_debug if Capcode::Configuration.get(:verbose)
|
592
593
|
|
593
594
|
Capcode.constants.clone.delete_if {|k|
|
594
595
|
not( Capcode.const_get(k).to_s =~ /Capcode/ ) or [
|
@@ -46,10 +46,19 @@ module Capcode
|
|
46
46
|
next unless path =~ match && rest = $1
|
47
47
|
next unless rest.empty? || rest[0] == ?/
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
# ----------------- CHANGE IS HERE --------------------
|
50
|
+
if app.kind_of?(Class)
|
51
|
+
return app.new.call(
|
52
|
+
env.merge(
|
53
|
+
'SCRIPT_NAME' => (script_name + location),
|
54
|
+
'PATH_INFO' => rest))
|
55
|
+
else
|
56
|
+
return app.call(
|
57
|
+
env.merge(
|
58
|
+
'SCRIPT_NAME' => (script_name + location),
|
59
|
+
'PATH_INFO' => rest))
|
60
|
+
end
|
61
|
+
# ----------------- CHANGE IS HERE --------------------
|
53
62
|
}
|
54
63
|
[404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"}, ["Not Found: #{path}"]]
|
55
64
|
end
|
data/lib/capcode/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Capcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 6
|
10
|
+
version: 0.9.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Gr\xC3\xA9goire Lejeune"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-06-01 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|