sinatra-gen
github.com/quirkey/sinatra-gen
DESCRIPTION:
sinatra-gen generates a common file structure and basic app files for a web app utilizing the sinatra framework. For more information on sinatra, check out sinatrarb.com
!! NOW WITH SUPPORT FOR SINATRA 0.9 (02/10/09)
SYNOPSIS:
sinatra-gen has a bunch of different options (based loosley on merb-gen) to try to not lock the user into any specific frameworks/dev practices.
Run:
sinatra-gen [appname] [actions] [options]
e.g.
sinatra-gen mysinatrapp get:/ post:/:id --vendor --init --test=shoulda --views=haml
Actions
!! NEW as of 0.2.0 (12/23/08)
For even faster app development you specify actions to include in your app when generating. Actions are written out as
http_method:path
And are seperated by spaces. For example:
get:/ post:/:id put:/update/*
Will be added you your app as:
get '/' do
end
post '/:id' do
end
put '/update/*' do
end
It will also generate test skeletons in the test framework of your choosing.
Options
(can also be obtained by running sinatra-gen with no arguments):
-v, –version Show the sinatra-gen version number and quit. -d, –vendor Extract the latest sinatra to vendor/sinatra –tiny Only create the minimal files. –init Initialize a git repository –cap Adds config directory with basic capistrano deploy.rb –scripts Install the rubigen scripts (script/generate, script/destroy) –git /path/to/git Specify a different path for ‘git’ –test=test_framework Specify your testing framework (unit (default)/rspec/spec/shoulda/bacon) –views=view_framework Specify your view framework (erb (default)/haml/builder)
The –tiny option will create no directories. Just an app.rb, a Rakefile, and a config.ru (Rackup file)
ERB Helpers:
Miss some of the erb helpers from ActionView? I’ve included some helpers that can help:
-
image Creates an img tag, very similar to rails’ image_tag.
image src, ={}
EX:
image 'your_image.jpg', :title => "Your Image" # => <img src='images/your_image.jpg' title='Your Image' />
-
link_css Creates a css link tag for a css file in the public/css directory, very similar to rails’ stylesheet_link_tag
link_css srcs, ={}
EX:
# link to a single stylesheet link_css 'app' # => <link rel="stylesheet" href="/css/app.css" type="text/css" media="screen" title="no title" charset="utf-8"> # link to multiple stylesheets link_css "app, print"
-
link_js Creates a script tag for a javascript file in the public/js directory, similar to rails’ javascript_include_tag
link_js srcs, ={}
EX:
# link to a single js file link_js 'app' # link to multiple js files link_js 'jquery,app'
-
link Creates an anchor tag, similar to rails’ link_to
link content, ={}
EX:
# link to google link "Google", "http://google.com"
-
tag Creates an opening and closing html tag, similar to rails’ content_tag
tag name, content, ={}
EX:
# create a header tag tag :h1, "Shizam", :title => "Shizam" # => <h1 title="Shizam">Shizam</h1>
-
single_tag Creates a single closing html tag, like img tags and link tags
single_tag name,
EX:
# create an img tag single_tag :img, :src => "my_img.jpg" # => <img src="my_img.jpg" />
ACKNOWLEDGEMENTS:
Big props to the Sinatra developers (github.com/bmizerany/sinatra/). Also, thanks to Dr. Nic (github.com/drnic) for the Rubigen and Newgem libraries
REQUIREMENTS:
To use the –vendor option, git must be installed. To run the app without using the vendor option, the sinatra gem must be installed. If you want to use the erb helpers, activesupport must be installed.
INSTALL:
sudo gem install sinatra-gen
#or to install the ones with erb helpers
sudo gem install vanntastic-sinatra-gen -s http://gems.github.com
You can also install directly from github:
sudo gem install quirkey-sinatra-gen -s http://gems.github.com