Home > sinatra-hello-world

sinatra-hello-world

Sinatra-hello-world is a project mainly written in Ruby, it's free.

A Hello World style application demonstrating the Sinatra Ruby framework

h2. Introduction

This here application is a glorified Hello World using the "Sinatra":http://sinatra.rubyforge.org/ Ruby web framework. If you're thinking that a hello world example doesn't need a test suite, logging, configuration for multiple web servers and code that will restart it if it runs too hot, you'd be right.

h2. Running

Much of the code included in this example application is concerned with configuration for deploying with various other ruby tools.

h3. Sinatra

Sinatra comes with it's own web server.

./app.rb

h3. Thin

Alternatively you can use an instance of "Thin":http://code.macournoyer.com/thin/.

thin -C configs/config.yml -R configs/config.ru start
thin -C configs/config.yml -R configs/config.ru stop

h3. God

If you're feeling particularly fancy then you can keep the Thin server up and running with "God":http://god.rubyforge.org/.

First start the god daemon:

sudo god
sudo status

Then load your configuration and start the monitor:

sudo god load thin-sinatra-hello-world
sudo god monitor thin-sinatra-hello-world

Then run a few commands to demonstrate everything is in running order.

sudo status
sudo god start thin-sinatra-hello-world
sudo god stop thin-sinatra-hello-world

h2. Testing

So far you run a few very simple tests, either with unittest or with "RSpec":http://rspec.info/.

To run the unit tests simply run:

rake

To run the RSpec tests run:

rake spec