Saturday, March 12, 2011

Installing Sinatra (on Windows, using pik)

1. Install Sinatra

Using pik, I can install a gem such as Sinatra for all Ruby versions installed in a single command. I have 4 versions of Ruby installed in my Vista.

C:\>pik gem install sinatra
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

Successfully installed tilt-1.2.2
Successfully installed sinatra-1.2.0
2 gems installed
Installing ri documentation for tilt-1.2.2...
Installing ri documentation for sinatra-1.2.0...
Installing RDoc documentation for tilt-1.2.2...
Installing RDoc documentation for sinatra-1.2.0...

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

Successfully installed tilt-1.2.2
Successfully installed sinatra-1.2.0
2 gems installed
Installing ri documentation for tilt-1.2.2...
Installing ri documentation for sinatra-1.2.0...
Installing RDoc documentation for tilt-1.2.2...
Installing RDoc documentation for sinatra-1.2.0...

ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

Successfully installed tilt-1.2.2
Successfully installed sinatra-1.2.0
2 gems installed
Installing ri documentation for tilt-1.2.2...
Installing ri documentation for sinatra-1.2.0...
Updating class cache with 285 classes...
Installing RDoc documentation for tilt-1.2.2...
Installing RDoc documentation for sinatra-1.2.0...

ruby 1.9.2p136 (2010-12-25) [i386-mingw32]

Successfully installed tilt-1.2.2
Successfully installed sinatra-1.2.0
2 gems installed
Installing ri documentation for tilt-1.2.2...
Installing ri documentation for sinatra-1.2.0...
Installing RDoc documentation for tilt-1.2.2...
Installing RDoc documentation for sinatra-1.2.0...

2. Create a Sinatra app
# myapp01.rb
require 'sinatra'

get '/' do
  'Hello world!'
end

3. Run it.
C:\works\ruby\sinatra>ruby myapp01.rb
== Sinatra/1.2.0 has taken the stage on 4567 for development with backup from WEBrick
[2011-03-12 22:33:15] INFO  WEBrick 1.3.1
[2011-03-12 22:33:15] INFO  ruby 1.9.2 (2010-12-25) [i386-mingw32]
[2011-03-12 22:33:15] INFO  WEBrick::HTTPServer#start: pid=5164 port=4567

4. Result.






5. Resouces
Sinatra: http://www.sinatrarb.com/intro
pik: https://github.com/vertiginous/pik

No comments:

Post a Comment