Nitro (web framework)
Nitro is a Ruby-based web application framework. Created by George Moschovitis, Nitro is written in Ruby and uses Ruby syntax and Ruby concepts. Nitro feautures a powerful template system, with a configurable pipeline of transformation steps. It is licensed under a 3-clause BSD license.
A key philosophy of Nitro is that it does not dictate how a web application should be structured. It is possible to mainly use templates with embedded code, as is typical with PHP or ASP. One can equally use a model-view-controller approach, as found in for instance Ruby on Rails, or expand even further with a custom architectural pattern.
Nitro features support for Ajax, XML, web services and syndication while staying standards compliant.
One of its key distinctions from other similar frameworks is its use of Og as the object-relational database mapping layer. Og can create database tables based on Ruby classes, or it can be easily adapted to use an existing database schema.
Og
The persistence framework developed together with Nitro is named Og, short for ObjectGraph. It is an object-relational mapping (ORM) system that allows for storage and retrieval of Ruby objects from a backend store. This can be an RDBMS, but this does not necessarily have to be so. A backend adapter has been developed that stores objects in individual YAML files on the filesystem.
Og will infer the database structure from the definition of classes that are managed by it. Database tables will be created by Og as necessary. This is different from the ActiveRecord approach used in Rails where the developer is responsible for creating the database tables. Og currently does not attempt to adapt the database schema to changing class definitions, in this case the developer must either manually adapt the schema, or remove the affected tables and let Og recreate them.
Og can also be made to work with an existing (legacy) schema, by supplying hints as to which column is used to store a particular property.
Examples
Hello world
require "nitro"
class MyController
def index; "Hello from nitro!"; end
end
Nitro.start MyController
Select day
This example demonstrates morphers, one of the available transformations for templates. This will result in a dropdown list containing the numbers 1 to 31, with the current day selected.
<select name="day">
<option for="day in 1..31" selected_if="day == Time.now.day">#{day}</option>
</select>