Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.
/ hello-sinatra Public archive

A barebones Sinatra application template using Slim, Compass, and MiniTest::Spec

License

Notifications You must be signed in to change notification settings

elasticdog/hello-sinatra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello Sinatra

Hello Sinatra is a barebones, classic-style Sinatra application that utilizes Ruby 1.9.x, Bundler for managing dependencies, Slim for templates, Compass (Sass) for CSS, and MiniTest::Spec for tests.

It is meant to be a blank slate that will give you a head start when developing your own application with this specific technology stack.

Getting Started

Open up your favorite terminal emulator and...

$ git clone git://github.com/elasticdog/hello-sinatra.git
$ cd hello-sinatra/
$ bundle install
$ ruby my_app.rb

That will launch the app using Thin at http://localhost.com:4567/, so open up a browser and bask in all the "Hello world!" glory. You can press Ctrl-C in the terminal to shut things down and get back to the command prompt.

To run the included tests:

$ rake test                 # run tests normally
$ rake test TESTOPTS="-v"   # run in verbose mode

Getting Fancy

Assuming you want add a bit more functionality than "Hello world!", here's how things are organized...

hello-sinatra/
├── spec/
│   ├── my_app_spec.rb
│   └── spec_helper.rb
├── views/
│   ├── stylesheets/
│   │   └── style.scss
│   ├── index.slim
│   └── layout.slim
├── .gitignore
├── Gemfile
├── Gemfile.lock
├── Guardfile
├── LICENSE
├── README.md
├── Rakefile
├── config.ru
└── my_app.rb

Make your application changes in my_app.rb, template changes under the views/ directory, stylesheet changes under views/stylesheets/, and test changes under the spec/ directory. Create a top-level lib/ directory for any additional Ruby modules you want to include, and a public/ directory for static files.

Automation

When developing a new Sinatra app, you don't want to be stuck manually reloading WEBrick and running rake test every time you make a change. Luckily, there are ways to automate reloading the appropriate services whenever you save your app.

To automatically reload your development server, there are a couple of possibilities...if you're on OS X, the Pow project makes this process incredibly straight forward (more so when adding the powder gem on top as a command-line wrapper); or you can use the shotgun gem to fork and reload the server on every request.

$ shotgun config.ru

To automatically run your tests, you can use the guard gem along with the included Guardfile. This is similar to using ZenTest/autotest, but guard gives you a bit more flexibility.

$ guard

There are a couple of recepies defined in the Guardfile, feel free to add your own!

Contribute

Have ideas on how to make Hello Sinatra better? Great! Just fork the project, create a new branch, make your changes, push them back, and send a pull request.

License

Copyright © 2011, Aaron Bull Schaefer. Hello Sinatra is distributed under the MIT License.

About

A barebones Sinatra application template using Slim, Compass, and MiniTest::Spec

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published