Ramaze - A Ruby Web Framework

Ramaze

Ramaze was used for a small web application we had to build for a college assignment (soundtape.git). It was a great experience, and for sure, if need arises, i'll use it again for any project i can squeeze it in. This post tries to be a small overview of the framework with some working examples and general overview, also keep in mind that this is my personal view and opinion on the framework. Feel free to send in corrections of any kind.

Ramaze is a small web framework built on Ruby, now split in two parts, Innate and Ramaze.

Innate is the core of Ramaze, all basic functionality stays in Innate while Ramaze takes on a higher level of enhancements. In this scenario, you get two frameworks, Innate, a small framework with basic functionality, yet useful and nice to work with for small and quick web apps. On the other hand, you get Ramaze, which includes Innate, of course, but is also a full featured web development framework.

Ramaze aims to be highly modular, with only one direct dependency, Rack. The indirect dependencies come from the use of helpers included in Ramaze.

It's very common to ask "what is the Ramaze way of solving or implementing issue/functionality X". One thing i found is that, there is no Ramaze way, there's your way, it's completely freestyle, your style. Ramaze is completely decoupled of technologies that don't fit the scope of a web framework, while developing with Ramaze you can choose to use any of the available:

Just plug your favorite technologies and start working on your app.

With Ramaze you can build a small application in only one file (or more), or you can go for the MVC (Model-View-Controller) pattern and build the application with an organized structure using all the facilities Ramaze provides. For the MVC part, Ramaze provides a script that already builds the needed directory structure for you, this does not mean you have to use it, or bind to the structure it gives you. Keep in mind that Ramaze always provides you means to configure things your way, and the directory structure for your project is no exception.

For the sake of demonstration i created two examples, checkout the links below. The example is a simple twitter search application, nothing fancy, but helps running away from the usual "Hello World" example. There's a single file demo and structured demo, to run it, you just need feedzirra and then, ruby start.rb.

Single file example

Structured example

Ramaze functionality is extended by the use of helpers. In Innate you will only find the basic set, while in Ramaze there is a significant amount of helpers to aid in many tasks related to web application development. Check out both repositories to get an idea of what's available:

For configuration Ramaze offers a very nice DSL to describe options for your application. In the DSL you not only specif y the options, but also a small description and a default value, keeping the configuration sane and self documented. Here's a small example:

require 'rubygems'
require 'ramaze'

class MyApp
  include Ramaze::Optioned
  
  options.dsl do
    o "Application name", :name, "Ramaze DSL Demo"
    
    o "Application version",
      :version, "0.5 Alpha"
    
    sub(:db) {
      o "Database name",
        :name, "default"
        
      o "Credential login name",
        :login, "oz"
      
      o "Credential password",
        :password, "123456"
      
      o "Database host",
        :host, "localhost"
    }
  end
end

puts MyApp.options.name #=> Ramaze DSL Demo
puts MyApp.options.version #=> 0.5 Alpha
puts MyApp.options.db.name #=> default
puts MyApp.options.db.login #=> oz
puts MyApp.options.db.password #=> 123456
puts MyApp.options.db.host #=> localhost

Ramaze tries to keep itself small, documented and thoroughly tested, the code is easy to read and follow and the specs help in understanding the workings. I hope this little intro leads you into taking Ramaze for a spin. I'm not very experienced in Ruby, building a small web app was my first real take on it, and i must say, Ruby is a must and using Ramaze as the web framework was the cherry at the top of the cake.

I can't finish this post without giving a word about the community. During this Ramaze experience i found that the community is simply friendly, helpful and knowledgeable, if you ever pop on IRC (#ramaze) you will just feel welcome, and if some Ramaze issue is stopping you, it will get solved.

Some useful external links:

Comments

Nice writeup! Thank you also

Nice writeup! Thank you also for the linkage. A couple points: Perhaps you can make github repos or gists or something for your examples. Having zip files adds that extra step of work which may be an obstacle to some looking at the code. Also, perhaps you should use http://webchat.freenode.net/?channels=ramaze as the link to the freenode web-based chat instead of the Java applet version, which is old.

Thank you, changed the links

Thank you, changed the links according to your tips. It sure makes more sense this way.