Capcode 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +4 -0
- data/doc/rdoc/classes/Capcode.html +99 -95
- data/doc/rdoc/classes/Capcode/Helpers.html +20 -35
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +10 -1
- data/doc/rdoc/files/lib/capcode_rb.html +1 -1
- data/doc/rdoc_iphone/classes/Capcode.html +175 -0
- data/doc/rdoc_iphone/classes/Capcode/HTTPError.html +21 -0
- data/doc/rdoc_iphone/classes/Capcode/Helpers.html +153 -0
- data/doc/rdoc_iphone/classes/Capcode/RenderError.html +21 -0
- data/doc/rdoc_iphone/classes/Capcode/Views.html +21 -0
- data/doc/rdoc_iphone/classes_index.html +10 -0
- data/doc/rdoc_iphone/created.rid +1 -0
- data/doc/rdoc_iphone/files/AUTHORS.html +11 -0
- data/doc/rdoc_iphone/files/COPYING.html +435 -0
- data/doc/rdoc_iphone/files/README.html +325 -0
- data/doc/rdoc_iphone/files/lib/capcode_rb.html +435 -0
- data/doc/rdoc_iphone/files_index.html +7 -0
- data/doc/rdoc_iphone/index.html +51 -0
- data/doc/rdoc_iphone/iui/backButton.png +0 -0
- data/doc/rdoc_iphone/iui/blueButton.png +0 -0
- data/doc/rdoc_iphone/iui/cancel.png +0 -0
- data/doc/rdoc_iphone/iui/grayButton.png +0 -0
- data/doc/rdoc_iphone/iui/iui-logo-touch-icon.png +0 -0
- data/doc/rdoc_iphone/iui/iui.css +386 -0
- data/doc/rdoc_iphone/iui/iui.js +442 -0
- data/doc/rdoc_iphone/iui/iuix.css +1 -0
- data/doc/rdoc_iphone/iui/iuix.js +1 -0
- data/doc/rdoc_iphone/iui/listArrow.png +0 -0
- data/doc/rdoc_iphone/iui/listArrowSel.png +0 -0
- data/doc/rdoc_iphone/iui/listGroup.png +0 -0
- data/doc/rdoc_iphone/iui/loading.gif +0 -0
- data/doc/rdoc_iphone/iui/pinstripes.png +0 -0
- data/doc/rdoc_iphone/iui/selection.png +0 -0
- data/doc/rdoc_iphone/iui/thumb.png +0 -0
- data/doc/rdoc_iphone/iui/toggle.png +0 -0
- data/doc/rdoc_iphone/iui/toggleOn.png +0 -0
- data/doc/rdoc_iphone/iui/toolButton.png +0 -0
- data/doc/rdoc_iphone/iui/toolbar.png +0 -0
- data/doc/rdoc_iphone/iui/whiteButton.png +0 -0
- data/doc/rdoc_iphone/rdoc-style.css +0 -0
- data/examples/blog-couchdb.rb +4 -0
- data/examples/blog-dm.rb +2 -0
- data/examples/my_blog.db +0 -0
- data/lib/capcode.rb +5 -1
- data/lib/capcode/base/couchdb.rb +4 -0
- data/lib/capcode/base/dm.rb +2 -1
- data/lib/capcode/version.rb +1 -1
- metadata +37 -2
data/README
CHANGED
@@ -10,6 +10,10 @@ Capcode is a web microframework
|
|
10
10
|
|
11
11
|
== FEATURES/PROBLEMS:
|
12
12
|
|
13
|
+
=== 0.7.1
|
14
|
+
* You need to include Capcode::Resource in your models !!!!
|
15
|
+
* Add option --version
|
16
|
+
|
13
17
|
=== 0.7.0
|
14
18
|
* You no more need to include Capcode::Resource in your models
|
15
19
|
* Capcode.run now accept a block. The content of the block is executed just before the server start.
|
@@ -446,104 +446,108 @@ main.rb)
|
|
446
446
|
433: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span>
|
447
447
|
434: <span class="ruby-identifier">exit</span>
|
448
448
|
435: <span class="ruby-keyword kw">end</span>
|
449
|
-
436:
|
450
|
-
437:
|
451
|
-
438:
|
452
|
-
439: <span class="ruby-
|
453
|
-
440: <span class="ruby-keyword kw">
|
454
|
-
441:
|
455
|
-
442:
|
456
|
-
443: <span class="ruby-identifier">
|
457
|
-
444: <span class="ruby-keyword kw">
|
458
|
-
445:
|
459
|
-
446:
|
460
|
-
447:
|
461
|
-
448:
|
462
|
-
449:
|
463
|
-
450:
|
464
|
-
451:
|
465
|
-
452: <span class="ruby-
|
466
|
-
453:
|
467
|
-
454:
|
468
|
-
455:
|
469
|
-
456:
|
470
|
-
457:
|
471
|
-
458: <span class="ruby-identifier">
|
472
|
-
459:
|
473
|
-
460:
|
474
|
-
461:
|
475
|
-
462:
|
476
|
-
463: <span class="ruby-keyword kw">
|
477
|
-
464:
|
478
|
-
465:
|
479
|
-
466:
|
480
|
-
467:
|
481
|
-
468:
|
482
|
-
469: <span class="ruby-
|
483
|
-
470:
|
484
|
-
471:
|
485
|
-
472:
|
486
|
-
473:
|
487
|
-
474:
|
488
|
-
475:
|
489
|
-
476:
|
490
|
-
477:
|
491
|
-
478: <span class="ruby-
|
492
|
-
479:
|
493
|
-
480: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">
|
494
|
-
481: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">
|
495
|
-
482:
|
496
|
-
483: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">
|
497
|
-
484:
|
498
|
-
485: <span class="ruby-
|
499
|
-
486:
|
500
|
-
487:
|
501
|
-
488:
|
502
|
-
489:
|
503
|
-
490:
|
504
|
-
491:
|
505
|
-
492: <span class="ruby-
|
506
|
-
493: <span class="ruby-constant">
|
507
|
-
494: <span class="ruby-
|
508
|
-
495: <span class="ruby-
|
509
|
-
496:
|
510
|
-
497: <span class="ruby-constant">
|
511
|
-
498:
|
512
|
-
499:
|
513
|
-
500: <span class="ruby-
|
514
|
-
501:
|
515
|
-
502:
|
449
|
+
436: <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">"--version"</span>, <span class="ruby-value str">"Show versions"</span>) <span class="ruby-keyword kw">do</span>
|
450
|
+
437: <span class="ruby-identifier">puts</span> <span class="ruby-node">"Capcode version #{Capcode::CAPCOD_VERION} (ruby v#{RUBY_VERSION})"</span>
|
451
|
+
438: <span class="ruby-identifier">exit</span>
|
452
|
+
439: <span class="ruby-keyword kw">end</span>
|
453
|
+
440: <span class="ruby-keyword kw">end</span>
|
454
|
+
441:
|
455
|
+
442: <span class="ruby-keyword kw">begin</span>
|
456
|
+
443: <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">parse!</span> <span class="ruby-constant">ARGV</span>
|
457
|
+
444: <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>
|
458
|
+
445: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"!! #{ex.message}"</span>
|
459
|
+
446: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** use `#{File.basename($0)} --help` for more details..."</span>
|
460
|
+
447: <span class="ruby-identifier">exit</span> <span class="ruby-value">1</span>
|
461
|
+
448: <span class="ruby-keyword kw">end</span>
|
462
|
+
449:
|
463
|
+
450: <span class="ruby-comment cmt"># Run in the Working directory</span>
|
464
|
+
451: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:working_directory</span>] ) <span class="ruby-keyword kw">do</span>
|
465
|
+
452: <span class="ruby-comment cmt"># Set root directory for helpers</span>
|
466
|
+
453: <span class="ruby-constant">Capcode</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">root</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>] )
|
467
|
+
454:
|
468
|
+
455: <span class="ruby-comment cmt"># Check that mongrel exists </span>
|
469
|
+
456: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">"mongrel"</span>
|
470
|
+
457: <span class="ruby-keyword kw">begin</span>
|
471
|
+
458: <span class="ruby-identifier">require</span> <span class="ruby-value str">'mongrel'</span>
|
472
|
+
459: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">"mongrel"</span>
|
473
|
+
460: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">LoadError</span>
|
474
|
+
461: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"!! could not load mongrel. Falling back to webrick."</span>
|
475
|
+
462: <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>] = <span class="ruby-value str">"webrick"</span>
|
476
|
+
463: <span class="ruby-keyword kw">end</span>
|
477
|
+
464: <span class="ruby-keyword kw">end</span>
|
478
|
+
465:
|
479
|
+
466: <span class="ruby-constant">Capcode</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
|
480
|
+
467: <span class="ruby-keyword kw">begin</span>
|
481
|
+
468: <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>
|
482
|
+
469: <span class="ruby-identifier">u</span>, <span class="ruby-identifier">m</span>, <span class="ruby-identifier">c</span> = <span class="ruby-identifier">eval</span> <span class="ruby-node">"Capcode::#{k}.__urls__"</span>
|
483
|
+
470: <span class="ruby-identifier">u</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">_u</span><span class="ruby-operator">|</span>
|
484
|
+
471: <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 `#{_u}' already define !"</span>, <span class="ruby-identifier">caller</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@@__ROUTES</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">_u</span>)
|
485
|
+
472: <span class="ruby-ivar">@@__ROUTES</span>[<span class="ruby-identifier">_u</span>] = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">new</span>
|
486
|
+
473: <span class="ruby-keyword kw">end</span>
|
487
|
+
474: <span class="ruby-keyword kw">end</span>
|
488
|
+
475: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
489
|
+
476: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
|
490
|
+
477: <span class="ruby-keyword kw">end</span>
|
491
|
+
478: <span class="ruby-keyword kw">end</span>
|
492
|
+
479:
|
493
|
+
480: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">URLMap</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@@__ROUTES</span>)
|
494
|
+
481: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:session</span>] )
|
495
|
+
482: <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>, <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:root</span>])
|
496
|
+
483: <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>)
|
497
|
+
484: <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>)
|
498
|
+
485: <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>)
|
499
|
+
486: <span class="ruby-comment cmt"># app = Rack::Reloader.new(app) ## -- NE RELOAD QUE capcode.rb -- So !!!</span>
|
500
|
+
487: <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">CommonLogger</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">app</span>, <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>]) )
|
501
|
+
488:
|
502
|
+
489: <span class="ruby-comment cmt"># From rackup !!!</span>
|
503
|
+
490: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:daemonize</span>]
|
504
|
+
491: <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>
|
505
|
+
492: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
|
506
|
+
493: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">setsid</span>
|
507
|
+
494: <span class="ruby-identifier">exit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">fork</span>
|
508
|
+
495: <span class="ruby-comment cmt"># Dir.chdir "/"</span>
|
509
|
+
496: <span class="ruby-constant">File</span>.<span class="ruby-identifier">umask</span> <span class="ruby-value">0000</span>
|
510
|
+
497: <span class="ruby-constant">STDIN</span>.<span class="ruby-identifier">reopen</span> <span class="ruby-value str">"/dev/null"</span>
|
511
|
+
498: <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>
|
512
|
+
499: <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>
|
513
|
+
500: <span class="ruby-keyword kw">else</span>
|
514
|
+
501: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">daemon</span>
|
515
|
+
502: <span class="ruby-keyword kw">end</span>
|
516
516
|
503:
|
517
|
-
504:
|
518
|
-
505:
|
519
|
-
506:
|
520
|
-
507:
|
521
|
-
508:
|
522
|
-
509: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">
|
523
|
-
510: <span class="ruby-
|
517
|
+
504: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>], <span class="ruby-value str">'w'</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">"#{Process.pid}"</span>) }
|
518
|
+
505: <span class="ruby-identifier">at_exit</span> { <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:pid</span>]) }
|
519
|
+
506: <span class="ruby-keyword kw">end</span>
|
520
|
+
507:
|
521
|
+
508: <span class="ruby-comment cmt"># Start database</span>
|
522
|
+
509: <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>
|
523
|
+
510: <span class="ruby-identifier">db_connect</span>( <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:db_config</span>], <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:log</span>] )
|
524
524
|
511: <span class="ruby-keyword kw">end</span>
|
525
525
|
512:
|
526
|
-
513: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">
|
527
|
-
514: <span class="ruby-
|
528
|
-
515:
|
529
|
-
516:
|
530
|
-
517: <span class="ruby-keyword kw">
|
531
|
-
518:
|
532
|
-
519:
|
533
|
-
520:
|
534
|
-
521: <span class="ruby-keyword kw">
|
535
|
-
522:
|
536
|
-
523:
|
537
|
-
524:
|
538
|
-
525:
|
539
|
-
526:
|
540
|
-
527: <span class="ruby-identifier">
|
541
|
-
528:
|
542
|
-
529:
|
543
|
-
530:
|
544
|
-
531:
|
545
|
-
532:
|
546
|
-
533:
|
526
|
+
513: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
527
|
+
514: <span class="ruby-keyword kw">yield</span>( <span class="ruby-keyword kw">self</span> )
|
528
|
+
515: <span class="ruby-keyword kw">end</span>
|
529
|
+
516:
|
530
|
+
517: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:console</span>]
|
531
|
+
518: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"Run console..."</span>
|
532
|
+
519: <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">start</span>
|
533
|
+
520: <span class="ruby-identifier">exit</span>
|
534
|
+
521: <span class="ruby-keyword kw">end</span>
|
535
|
+
522:
|
536
|
+
523: <span class="ruby-comment cmt"># Start server</span>
|
537
|
+
524: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:server</span>]
|
538
|
+
525: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"mongrel"</span>
|
539
|
+
526: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Starting Mongrel on #{conf[:host]}:#{conf[:port]}"</span>
|
540
|
+
527: <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-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:Host</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
|
541
|
+
528: <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> }
|
542
|
+
529: }
|
543
|
+
530: <span class="ruby-keyword kw">when</span> <span class="ruby-value str">"webrick"</span>
|
544
|
+
531: <span class="ruby-identifier">puts</span> <span class="ruby-node">"** Starting WEBrick on #{conf[:host]}:#{conf[:port]}"</span>
|
545
|
+
532: <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-identifier">conf</span>[<span class="ruby-identifier">:port</span>], <span class="ruby-identifier">:BindAddress</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">conf</span>[<span class="ruby-identifier">:host</span>]} ) { <span class="ruby-operator">|</span><span class="ruby-identifier">server</span><span class="ruby-operator">|</span>
|
546
|
+
533: <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> }
|
547
|
+
534: }
|
548
|
+
535: <span class="ruby-keyword kw">end</span>
|
549
|
+
536: <span class="ruby-keyword kw">end</span>
|
550
|
+
537: <span class="ruby-keyword kw">end</span>
|
547
551
|
</pre>
|
548
552
|
</div>
|
549
553
|
</div>
|
@@ -103,26 +103,11 @@ controllers
|
|
103
103
|
</ul>
|
104
104
|
|
105
105
|
<h2 class="ruled">Methods</h2>
|
106
|
-
<h4 class="ruled">Public Class method:
|
107
|
-
<strong><a name="M000009">root=(p)</a></strong> <a href="#M000009"><img src="../../permalink.gif" border="0" title="Permalink to Public Class method: root=" /></a></h4>
|
108
|
-
|
109
|
-
|
110
|
-
<div class="sourcecode">
|
111
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000009_source')" id="l_M000009_source">show source</a> ]</p>
|
112
|
-
<div id="M000009_source" class="dyn-source">
|
113
|
-
<pre>
|
114
|
-
<span class="ruby-comment cmt"># File lib/capcode.rb, line 35</span>
|
115
|
-
35: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">root=</span>(<span class="ruby-identifier">p</span>)
|
116
|
-
36: <span class="ruby-ivar">@@__ROOT_DIRECTORY</span>=<span class="ruby-identifier">p</span>
|
117
|
-
37: <span class="ruby-keyword kw">end</span>
|
118
|
-
</pre>
|
119
|
-
</div>
|
120
|
-
</div>
|
121
106
|
<h4 class="ruled">Public Instance method:
|
122
|
-
<strong><a name="
|
107
|
+
<strong><a name="M000012">URL( klass, *a )</a></strong> <a href="#M000012"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: URL" /></a></h4>
|
123
108
|
|
124
109
|
<p>
|
125
|
-
Builds an <a href="Helpers.html#
|
110
|
+
Builds an <a href="Helpers.html#M000012">URL</a> route to a controller or a
|
126
111
|
path
|
127
112
|
</p>
|
128
113
|
<p>
|
@@ -143,8 +128,8 @@ then
|
|
143
128
|
</pre>
|
144
129
|
|
145
130
|
<div class="sourcecode">
|
146
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
147
|
-
<div id="
|
131
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000012_source')" id="l_M000012_source">show source</a> ]</p>
|
132
|
+
<div id="M000012_source" class="dyn-source">
|
148
133
|
<pre>
|
149
134
|
<span class="ruby-comment cmt"># File lib/capcode.rb, line 128</span>
|
150
135
|
128: <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> )
|
@@ -165,16 +150,16 @@ then
|
|
165
150
|
</div>
|
166
151
|
</div>
|
167
152
|
<h4 class="ruled">Public Instance method:
|
168
|
-
<strong><a name="
|
153
|
+
<strong><a name="M000013">content_for( x ) {|| ...}</a></strong> <a href="#M000013"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: content_for" /></a></h4>
|
169
154
|
|
170
155
|
<p>
|
171
|
-
Calling <a href="Helpers.html#
|
156
|
+
Calling <a href="Helpers.html#M000013">content_for</a> stores a block of
|
172
157
|
markup in an identifier.
|
173
158
|
</p>
|
174
159
|
|
175
160
|
<div class="sourcecode">
|
176
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
177
|
-
<div id="
|
161
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000013_source')" id="l_M000013_source">show source</a> ]</p>
|
162
|
+
<div id="M000013_source" class="dyn-source">
|
178
163
|
<pre>
|
179
164
|
<span class="ruby-comment cmt"># File lib/capcode.rb, line 144</span>
|
180
165
|
144: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_for</span>( <span class="ruby-identifier">x</span> )
|
@@ -186,7 +171,7 @@ markup in an identifier.
|
|
186
171
|
</div>
|
187
172
|
</div>
|
188
173
|
<h4 class="ruled">Public Instance method:
|
189
|
-
<strong><a name="
|
174
|
+
<strong><a name="M000010">json( d )</a></strong> <a href="#M000010"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: json" /></a></h4>
|
190
175
|
|
191
176
|
<p>
|
192
177
|
Help you to return a JSON response
|
@@ -202,8 +187,8 @@ Help you to return a JSON response
|
|
202
187
|
</pre>
|
203
188
|
|
204
189
|
<div class="sourcecode">
|
205
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
206
|
-
<div id="
|
190
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000010_source')" id="l_M000010_source">show source</a> ]</p>
|
191
|
+
<div id="M000010_source" class="dyn-source">
|
207
192
|
<pre>
|
208
193
|
<span class="ruby-comment cmt"># File lib/capcode.rb, line 92</span>
|
209
194
|
92: <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>
|
@@ -215,10 +200,10 @@ Help you to return a JSON response
|
|
215
200
|
</div>
|
216
201
|
</div>
|
217
202
|
<h4 class="ruled">Public Instance method:
|
218
|
-
<strong><a name="
|
203
|
+
<strong><a name="M000011">redirect( klass, *a )</a></strong> <a href="#M000011"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: redirect" /></a></h4>
|
219
204
|
|
220
205
|
<p>
|
221
|
-
Send a <a href="Helpers.html#
|
206
|
+
Send a <a href="Helpers.html#M000011">redirect</a> response
|
222
207
|
</p>
|
223
208
|
<pre>
|
224
209
|
module Capcode
|
@@ -235,8 +220,8 @@ Send a <a href="Helpers.html#M000012">redirect</a> response
|
|
235
220
|
</pre>
|
236
221
|
|
237
222
|
<div class="sourcecode">
|
238
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
239
|
-
<div id="
|
223
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000011_source')" id="l_M000011_source">show source</a> ]</p>
|
224
|
+
<div id="M000011_source" class="dyn-source">
|
240
225
|
<pre>
|
241
226
|
<span class="ruby-comment cmt"># File lib/capcode.rb, line 111</span>
|
242
227
|
111: <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> )
|
@@ -246,13 +231,13 @@ Send a <a href="Helpers.html#M000012">redirect</a> response
|
|
246
231
|
</div>
|
247
232
|
</div>
|
248
233
|
<h4 class="ruled">Public Instance method:
|
249
|
-
<strong><a name="
|
234
|
+
<strong><a name="M000009">render( h )</a></strong> <a href="#M000009"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: render" /></a></h4>
|
250
235
|
|
251
236
|
<p>
|
252
237
|
Render a view
|
253
238
|
</p>
|
254
239
|
<p>
|
255
|
-
<a href="Helpers.html#
|
240
|
+
<a href="Helpers.html#M000009">render</a>‘s parameter can be a Hash
|
256
241
|
or a string. Passing a string is equivalent to do
|
257
242
|
</p>
|
258
243
|
<pre>
|
@@ -277,7 +262,7 @@ exist in haml_path
|
|
277
262
|
<li>:text => "my text"
|
278
263
|
|
279
264
|
</li>
|
280
|
-
<li>:<a href="Helpers.html#
|
265
|
+
<li>:<a href="Helpers.html#M000010">json</a> => MyObject : this suppose
|
281
266
|
that‘s MyObject respond to .to_json
|
282
267
|
|
283
268
|
</li>
|
@@ -290,8 +275,8 @@ If you want to use a specific layout, you can specify it with option
|
|
290
275
|
</pre>
|
291
276
|
|
292
277
|
<div class="sourcecode">
|
293
|
-
<p class="source-link">[ <a href="javascript:toggleSource('
|
294
|
-
<div id="
|
278
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000009_source')" id="l_M000009_source">show source</a> ]</p>
|
279
|
+
<div id="M000009_source" class="dyn-source">
|
295
280
|
<pre>
|
296
281
|
<span class="ruby-comment cmt"># File lib/capcode.rb, line 54</span>
|
297
282
|
54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>( <span class="ruby-identifier">h</span> )
|
data/doc/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Thu, 02 Jul 2009 17:58:19 +0200
|
data/doc/rdoc/files/README.html
CHANGED
@@ -81,7 +81,7 @@ end</strong>
|
|
81
81
|
<div id="README" class="page_shade">
|
82
82
|
<div class="page">
|
83
83
|
<div class="header">
|
84
|
-
<div class="path">README /
|
84
|
+
<div class="path">README / Thu Jul 02 17:56:23 +0200 2009</div>
|
85
85
|
</div>
|
86
86
|
|
87
87
|
<h1><a href="../classes/Capcode.html">Capcode</a></h1>
|
@@ -98,6 +98,15 @@ Copyright (C) 2009 Gregoire Lejeune
|
|
98
98
|
<a href="../classes/Capcode.html">Capcode</a> is a web microframework
|
99
99
|
</p>
|
100
100
|
<h2>FEATURES/PROBLEMS:</h2>
|
101
|
+
<h3>0.7.1</h3>
|
102
|
+
<ul>
|
103
|
+
<li>You need to include Capcode::Resource in your models !!!!
|
104
|
+
|
105
|
+
</li>
|
106
|
+
<li>Add option —version
|
107
|
+
|
108
|
+
</li>
|
109
|
+
</ul>
|
101
110
|
<h3>0.7.0</h3>
|
102
111
|
<ul>
|
103
112
|
<li>You no more need to include Capcode::Resource in your models
|
@@ -81,7 +81,7 @@ end</strong>
|
|
81
81
|
<div id="lib/capcode.rb" class="page_shade">
|
82
82
|
<div class="page">
|
83
83
|
<div class="header">
|
84
|
-
<div class="path">lib/capcode.rb /
|
84
|
+
<div class="path">lib/capcode.rb / Thu Jul 02 17:56:13 +0200 2009</div>
|
85
85
|
</div>
|
86
86
|
|
87
87
|
<pre>
|
@@ -0,0 +1,175 @@
|
|
1
|
+
|
2
|
+
<!-- BEGIN: BODY -->
|
3
|
+
|
4
|
+
<div id="Capcode" title="Module: Capcode" class="panel">
|
5
|
+
|
6
|
+
|
7
|
+
<h2>Includes</h2>
|
8
|
+
<ul>
|
9
|
+
<li>Rack</li>
|
10
|
+
<li>Capcode::Helpers</li>
|
11
|
+
<li>Capcode::Views</li>
|
12
|
+
</ul>
|
13
|
+
|
14
|
+
|
15
|
+
<h2 class="ruled">Methods</h2>
|
16
|
+
<ul>
|
17
|
+
<li>
|
18
|
+
Public Class method:
|
19
|
+
<b>Route(*u)</b>
|
20
|
+
</li>
|
21
|
+
<li>
|
22
|
+
<p>
|
23
|
+
Add routes to a controller class
|
24
|
+
</p>
|
25
|
+
<pre>
|
26
|
+
module Capcode
|
27
|
+
class Hello < Route '/hello/(.*)', '/hello/([^#]*)#(.*)'
|
28
|
+
def get( arg1, arg2 )
|
29
|
+
...
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
</pre>
|
34
|
+
<p>
|
35
|
+
In the <tt>get</tt> method, you will receive the maximum of parameters
|
36
|
+
declared by the routes. In this example, you will receive 2 parameters. So
|
37
|
+
if you go to <tt>/hello/world#friend</tt> then <tt>arg1</tt> will be set to
|
38
|
+
<tt>world</tt> and <tt>arg2</tt> will be set to <tt>friend</tt>. Now if you
|
39
|
+
go to <tt>/hello/you</tt>, then <tt>arg1</tt> will be set to <tt>you</tt>
|
40
|
+
and <tt>arg2</tt> will be set to <tt>nil</tt>
|
41
|
+
</p>
|
42
|
+
<p>
|
43
|
+
If the regexp in the route does not match, all arguments will be
|
44
|
+
<tt>nil</tt>
|
45
|
+
</p>
|
46
|
+
</li>
|
47
|
+
</ul>
|
48
|
+
<ul>
|
49
|
+
<li>
|
50
|
+
Public Class method:
|
51
|
+
<b>env()</b>
|
52
|
+
</li>
|
53
|
+
<li>
|
54
|
+
<p>
|
55
|
+
Hash containing all the environment variables
|
56
|
+
</p>
|
57
|
+
</li>
|
58
|
+
</ul>
|
59
|
+
<ul>
|
60
|
+
<li>
|
61
|
+
Public Class method:
|
62
|
+
<b>map( r ) {|| ...}</b>
|
63
|
+
</li>
|
64
|
+
<li>
|
65
|
+
<p>
|
66
|
+
This method help you to <a href="Capcode.html#M000007">map</a> and URL to a
|
67
|
+
Rack or What you want Helper
|
68
|
+
</p>
|
69
|
+
<pre>
|
70
|
+
Capcode.map( "/file" ) do
|
71
|
+
Rack::File.new( "." )
|
72
|
+
end
|
73
|
+
</pre>
|
74
|
+
</li>
|
75
|
+
</ul>
|
76
|
+
<ul>
|
77
|
+
<li>
|
78
|
+
Public Class method:
|
79
|
+
<b>params()</b>
|
80
|
+
</li>
|
81
|
+
<li>
|
82
|
+
<p>
|
83
|
+
Hash containing all the <a href="Capcode.html#M000005">request</a>
|
84
|
+
parameters (GET or POST)
|
85
|
+
</p>
|
86
|
+
</li>
|
87
|
+
</ul>
|
88
|
+
<ul>
|
89
|
+
<li>
|
90
|
+
Public Class method:
|
91
|
+
<b>request()</b>
|
92
|
+
</li>
|
93
|
+
<li>
|
94
|
+
<p>
|
95
|
+
Return the Rack::Request object
|
96
|
+
</p>
|
97
|
+
</li>
|
98
|
+
</ul>
|
99
|
+
<ul>
|
100
|
+
<li>
|
101
|
+
Public Class method:
|
102
|
+
<b>response()</b>
|
103
|
+
</li>
|
104
|
+
<li>
|
105
|
+
<p>
|
106
|
+
Return the Rack::Response object
|
107
|
+
</p>
|
108
|
+
</li>
|
109
|
+
</ul>
|
110
|
+
<ul>
|
111
|
+
<li>
|
112
|
+
Public Class method:
|
113
|
+
<b>run( args = {} ) {|self| ...}</b>
|
114
|
+
</li>
|
115
|
+
<li>
|
116
|
+
<p>
|
117
|
+
Start your application.
|
118
|
+
</p>
|
119
|
+
<p>
|
120
|
+
Options :
|
121
|
+
</p>
|
122
|
+
<ul>
|
123
|
+
<li><tt>:port</tt> = Listen port
|
124
|
+
|
125
|
+
</li>
|
126
|
+
<li><tt>:host</tt> = Listen host
|
127
|
+
|
128
|
+
</li>
|
129
|
+
<li><tt>:server</tt> = Server type (webrick or mongrel)
|
130
|
+
|
131
|
+
</li>
|
132
|
+
<li><tt>:log</tt> = Output logfile (default: STDOUT)
|
133
|
+
|
134
|
+
</li>
|
135
|
+
<li><tt>:<a href="Capcode.html#M000004">session</a></tt> = Session parameters.
|
136
|
+
See Rack::Session for more informations
|
137
|
+
|
138
|
+
</li>
|
139
|
+
<li><tt>:pid</tt> = PID file (default: $0.pid)
|
140
|
+
|
141
|
+
</li>
|
142
|
+
<li><tt>:daemonize</tt> = Daemonize application (default: false)
|
143
|
+
|
144
|
+
</li>
|
145
|
+
<li><tt>:db_config</tt> = database configuration file (default: database.yml)
|
146
|
+
|
147
|
+
</li>
|
148
|
+
<li><tt>:root</tt> = root directory (default: "." — relative to
|
149
|
+
the working directory)
|
150
|
+
|
151
|
+
</li>
|
152
|
+
<li><tt>:working_directory</tt> = Working directory (default: directory of the
|
153
|
+
main.rb)
|
154
|
+
|
155
|
+
</li>
|
156
|
+
</ul>
|
157
|
+
</li>
|
158
|
+
</ul>
|
159
|
+
<ul>
|
160
|
+
<li>
|
161
|
+
Public Class method:
|
162
|
+
<b>session()</b>
|
163
|
+
</li>
|
164
|
+
<li>
|
165
|
+
<p>
|
166
|
+
Hash <a href="Capcode.html#M000004">session</a>
|
167
|
+
</p>
|
168
|
+
</li>
|
169
|
+
</ul>
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
</div>
|
174
|
+
|
175
|
+
<!-- BEGIN: BODY -->
|