# File: README [ "README", "AUTHORS", "COPYING", "lib/capcode.rb", nil].each do Capcode.view_html Capcode::Views.view_html Capcode::Helpers.view_html Capcode::HTTPError.view_html Capcode::RenderError.view_html Capcode::RouteError.view_html Capcode::ParameterError.view_html end |
Copyright (C) 2009 Gregoire Lejeune
Capcode is a web microframework
# file: sample.rb require 'rubygems' require 'capcode' module Capcode class Hello < Route '/hello' def get "Hello World #{Time.now} !" end end end Capcode.run( )
require 'rubygems' require 'capcode' require 'capcode/base/dm' # or require 'capcode/base/couchdb' class Story < Capcode::Base include Capcode::Resource property :id, Integer, :serial => true # only with DataMapper ! property :title, String property :body, String property :date, String end
See examples/blog-dm.rb and/or examples/blog-couchdb.rb for complete examples.
# file: sample.rb require 'rubygems' require 'capcode' module Capcode class Hello < Route '/hello' def get @t = Time.now render :time end end end module Capcode::Views def time "Hello world #{@t}" end end Capcode.run( )
# file: sample.rb require 'rubygems' require 'capcode' module Capcode class Hello < Route '/hello' def get @t = Time.now render :time end end end module Capcode::Helpers def bold( &b ) "<b>"+yield+"</b>" end end module Capcode::Views def time "Hello world " + bold { @t } end end Capcode.run( )
# file: sample.rb require 'rubygems' require 'capcode' require 'capcode/render/markaby' module Capcode class Hello < Route '/hello' def get @t = Time.now render :markaby => :time end end end module Capcode::Views def time # We use Markaby in Capcode::Views.time html do body do p { text "Hello World " b @t } end end end end Capcode.run( )
# file: sample.rb require 'rubygems' require 'capcode' require 'capcode/render/haml' Capcode::Helpers.haml_path = "./my_haml_views" module Capcode class Hello < Route '/hello' def get @t = Time.now render :haml => :time end end end Capcode.run( ) # ./my_haml_views/time.haml %html %body %p Hello World = @t
# file: sample.rb require 'rubygems' require 'capcode' require 'capcode/render/json' module Capcode class Hello < Route '/hello' def get @t = Time.now render :json => { :time => @t } end end end Capcode.run( )
sudo gem install capcode
Capcode is freely distributable according to the terms of the GNU General Public License.
This program is distributed without any warranty. See the file ‘COPYING’ for details.