gmosx.ninja

Nitro and Og 0.40.0

After a long (loooong) time, I released a new version of Nitro + Og. This is the biggest release yet! Tons of new wonderful features, code refactoring, bug fixes, documentation improvements and so much more.

Special thanks for this release fly to Jonas Pfeniger, Jonathan/Fabian Buch and Michael Fellinger.

Most notable changes:

Fully transparent Og managed objects. No need to use the special property notation. Just use the standard attr_accessor macro:

class User
    attr_accessor :name, String, :sql => ‘VARCHAR(32)
    attr_accessor :password, String
    attr_accessor :age, :login_count, Fixnum
    belongs_to :group
    has_many :comments
    joins_many :categories
end

Og automatically detects and manages this class! The Og adapter model was re-engineered from scratch. The new adapter code is better refactored. It is now extremely easy to write new adapters for various RDBMS systems.

Og build mode. This avoids multiple sql queries when you are ‘building’ (ie attaching related objects) a new object.

You can now easily lookup Og entities by name:

u = User[1] # classic

or

u = User[’gmosx’] # this works as well!

For the new method to work you need to annotate the attribute to use for named lookups:

class User
    attr_accessor :name, String, :key => true
    ..
end

Og set attribute, a nice helper to set only some attributes.

b = Book[1]
b.set_attribute :title => ‘Hello’ # updates only title in the DB
b.instance_attribute_set ‘@title’, ‘Hello’ # Ruby style
b.set_attributes :title => ‘1′, :hits => 3

Much more intelligent dispatcher now handles nested controllers and many ‘edge’ cases. For example:

Server.map = {
    ‘/’ => SiteController,
    ‘/users’ => UserController,
    ‘/users/categories’ => UserCategoryController,
    ‘/users/comments’ => UserCommentController
    …
}

Introduced the notion of Controls as extensions of the Elements feature. The auto administration part was recoded to utilize the Controls system. Ooh, and the admin screens now display validation errors.

Introduced Console/Script adapter. This is a new adapter that allows you to programmatically send http requests to Nitro. You can send GET/POST/etc request to any action you like with any request parameters.

This adapter is used in the console mode. You can access it through the $app variable. You can also use this adapter to perform sophisticated testing, our specialized automation scripts.

New and improved nitro command. Among many new features the new command supports:

Easy setup of clusters:

nitro –cluster 3

if the default port is 9000 starts 3 instances of the application listening on 9000, 9001, 9002. This command is smart enough to also name the instances for easy identification when you give ‘ps aux’.

Useful for Mongrel/FastCGI deployment.

Automatic start of state servers. You need a ’state’ server if tou use Mongrel/Nitro to keep the distributed session and global variables and any other common data you want to use.

Output cache cleanup. Just start the console

nitro console

and give:

$cache.cleanup

More flexible elements namespace selection, you can easier have multiple skins in your web app, per controller, per controller group etc. A low level example:

class MyController
    ann :self, :elements => CustomSkin
end

More flexible configuration system. See the updated examples for the details.

Further improvements in the form builder. Among other things, it now works better with flash parameters and handle errors.

Greatly improved the Mongrel adapter. In fact nitro+mongrel running behind apache is now the reference deployment method. We have removed the unsupported SCGI adapter, please use Mongrel instead.

The StaticInclude compiler now handles recursive includes.

Brand new automatic administration part.The new implementation is much simpler, elegant and easier to extend.

Many more bug fixes and smaller improvements.