SinatraHelpers

Description

This is a ruby gem with a bunch of helpers to make Sinatra more useful.

Installation

gem install kelredd-sinatra-helpers

Usage

require 'sinatra_helpers'

A Generator

I’ve written a generator for new Sinatra apps. Please note: I’ve written this generator suited for my needs and paradigms in writing Sinatra apps. It is written for me and comes AS IS. Use if you wish, but know that it conforms to what I like using in Sinatra apps, including:

* Most, if not all, of the helpers in this gem
* Bundler for gem configurations
* Capistrano deployment scheme
* Source control with Git
* Erb (with generators from useful: http://github.com/kelredd/useful/tree/master/lib/useful/erb_helpers/)
* an App directory structure similar to Rails'
* Default layout that I like
* Rack::Cache using my configuration (see admin/production.ru)
* Rack::Flash
* Rack::Less (http://github.com/kelredd/rack-less)
* Rack::Sprockets (http://github.com/kelredd/rack-sprockets)
* Unit testing with Test::Unit
* Test suite using leftright, rack-test, webrat, etc...

If you don’t like/want to use something that this generates, don’t use the generator, or back out some generated code manually. Ok, enough about that. On to usage:

$ sinatra path/to/app
# will create the app structure in path/to/app

Environment Tests

Have environment tests like development? and production? available in your app code

Erb Helpers

Helpful view template helpers for partial rendering and html generation. See github.com/kelredd/useful/tree/master/lib/useful/erb_helpers/ for more info.

ActiveRecord

Provides a Rails like way for configuring an activerecord database. Here’s the steps to set it up:

  1. Configure this gem in your bundle

    gem 'kelredd-sinatra-helpers', :require => "sinatra_helpers"
    
  2. Configure active record in your bundle

    gem 'activerecord'
    
  3. Create your db config yaml file at ‘config/database.yml’

  4. Somewhere in your app initialization script, do

    require 'sinatra_helpers/active_record'
    

License

Copyright © 2010 Kelly Redding ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.