Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Making Sinatra swing.
Ruby

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
lib
spec
.gitignore
LICENSE
README.rdoc
README.rdoc.erb
Rakefile
big_band.gemspec

README.rdoc

Note: This is in some early stage, so use on your own risk. Commits welcome.

BigBand

BigBand is a collection of Sinatra extensions and offers better sinatra integration for common tools like Rake, YARD and Monk.

Usage

Using all BigBand features:

require "big_band"  
class Example < BigBand
  # Yay, BigBand!
end

Or for the lazy folks (read: you would don't subclass Sinatra::Base on your own):

require "sinatra"
require "big_band"
# Yay, BigBand!

Using just your favorite BigBand features:

require "big_band"
class Example < Sinatra::Base
  register BigBand::SomeFeature
  # Yay, BigBand::SomeFeature!
end

Or, if you like a more handy syntax:

require "big_band"
class Example < BigBand :SomeFeature, MyStuff::Extension, :development => :DevelopmentOnlyFeature
  # Yay, BigBand::SomeFeature!
  # Yay, MyStuff::Extension!
  # Yay, BigBand::DevelopmentOnlyFeature, if this is development mode!
end

Loading all but one feature:

require "big_band"
class Example < BigBand :except => :SomeFeature
  # Yay, all but BigBand::SomeFeature!
end

Or just your favorite feature without you subclassing Sinatra::Base manually:

require "sinatra"
require "big_band/some_feature"
Sinatra::Application.register BigBand::SomeFeature
# Yay, BigBand::SomeFeature!

Extensions

AdvancedRoutes

AdvancedRoutes makes routes first class objects in Sinatra:

require "sinatra"
require "big_band"

admin_route = get "/admin" do
  administrate_stuff
end

before do
  # Let's deactivate the route if we have no password file.
  if File.exists? "admin_password"
    admin_route.activate
  else
    admin_route.deactivate 
  end
end

first_route = get "/:name" do
  # stuff
end

other_route = get "/foo_:name" do
  # other stuff
end

# Unfortunatly first_route will catch all the requests other_route would
# have gotten, since it has been defined first. But wait, we can fix this!
other_route.promote

BasicExtensions

Basic Sinatra extension (mainly extending Sinatra's standard methods, like set or register). Also it features a more advanced path guessing than Sinatra::Base. Normally you do not have to register this module manually, as the other extensions will do so if necessary.

Compass

Integrates the Compass stylesheet framework with Sinatra.

Usage without doing something:

require "big_band"
class Foo < BigBand; end

If you create a directory called views/stylesheets and place your sass files in there, there you go. Just call stylesheet(name) form your view to get the correct stylesheet tag. The URL for your stylesheets will be /stylesheets/:name.css.

Of course you can use any other setup. Say, you want to store your stylesheets in views/css and want the URL to be /css/:name.css:

class Foo < BigBand
  get_compass("css")
end

But what about more complex setups?

class Foo < BigBand
  set :compass, :sass_dir => "/foo/bar/blah"
  get_compass("/foo/:name.css") do
    compass :one_stylesheet
  end
end

Note that already generated routes will be deactivated by calling get_compass again.

MoreServer

Adds more servers to Sinatra::Base#run! (currently unicorn and rainbows).

MoreHelpers

Adds more helper methods (coming soon).

Sass

BigBand::Sass extends SassScript with more functions like min or max.

Example:

.someClass
  width = max(!default_width - 10px, 200px)

This can be used without BigBand or even Sinatra.

Reloader

Advanced reloader for sinatra. Reloads only files that have changed and automatically detects orphaned routes that have to be removed. Files defining routes will be added to the reload list per default. Avoid reloading with dont_reload. Add other files to the reload list with also_reload.

Usage:

require "big_band"
class Foo < Sinatra::Base
  configure(:development) do
    register BigBand::Reloader
    also_reload "app/models/*.rb"
    dont_reload "lib/**/*.rb"
  end
end

WebInspector

Documentation

Running specs

rake spec

Generating documentation

rake doc

LICENSE

(MIT/BSD-style license, compatible with Ruby license and GPL)

copyright (c) 2009 Konstantin Haase.  All rights reserved.

Developed by: Konstantin Haase
              http://github.com/rkh/big_band

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal with 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:
  1. Redistributions of source code must retain the above copyright notice,
     this list of conditions and the following disclaimers.
  2. Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimers in the
     documentation and/or other materials provided with the distribution.
  3. Neither the name of Konstantin Haase, nor the names of other contributors
     may be used to endorse or promote products derived from this Software without
     specific prior written permission.

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
CONTRIBUTORS 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
WITH THE SOFTWARE.
Something went wrong with that request. Please try again.