Hello everyone,
new versions of Nitro and Og were just released.
Downloads: http://rubyforge.org/projects/nitro
Mailing list: http://rubyforge.org/mailman/listinfo/nitro-general
Homepage: http://nitro.rubyforge.org
Og reloaded part 2: Another superb release introducing a balanced
mix of innovative new features, common but useful stuff and bug
fixes.
Some notable changes:
* Og polymorphic relations. A groundbreaking feature made possible by
Og's unique design and Ruby's power. Let's use an example to explain
the concept:
class Comment
...
belongs_to Object # polymorphic marker
end
class User
...
has_many Comment
end
class Article
...
has_many Comment
end
u = User.new
u.comments << User::Comment('Hello')
a = Article.new
a.comments << Article::Comment('Wow!')
User::Comment and Article::Comment where automatically created by Og
and are serialized in different tables (also automatically created by
Og). This is the next step in DRY!
* Og now supports inheritance using the well known Single
Table Inheritance pattern. Thanks to Og's advanced design the pattern
is fully encapsulated:
class Document
...
schema_inheritance
end
class Article < Document
..
end
class Photo < Document
..
end
Document.all # => includes Articles and Photos
Article.all # => only Articles
User.documents # => Articles and Photos
User.documents(:type => Photo) # => only photos.
Btw, this feature is orthogonal to the polymorphic relations feature
just described, giving the developer great flexibility.
* Added SUPERB support for auto reloading, the new system can detect
source changes everywhere! Based on original code by Michael Neumann.
* Introduced the concept of Flash, a temporal store where objects that
should be kept alive for the next request are saved.
* Recoded the Blog example to use the Elements system for shading
instead of XSLT. The new code runs easier under Windows (so the
no_xsl_blog example is now removed). Here comes an example:
<Page>
<Box>
Please login as an author by entering the blog password.
<br />
The password is: <b>#{Blog.password}</b>.
</Box>
<Error>#@error</Error>
...
</Page>
The <Page> tag is supported by the Page Ruby class to do the
programmatic rendering of templates or logic code:
class Page
def render
...
end
end
This system can be used to create a library of useful components to
abstract common tasks.
* The updated Blog example demonstrates how easy it is to
write webservices using Nitro and the experimental Service feature. The
code is so short, so lets paste it here:
module BloggerApi
SBlog = Struct.new(:url, :blogid, :blogName)
def blogger__getUsersBlogs(appkey, username, password)
Blog.all.collect { |b| SBlog.new('http://www.gmosx.com', b.oid,
b.title) }
end
end
module MetaWeblogApi
def metaWeblog__newPost(blogid, username, password, content, publish)
entry = BlogEntry.new(content['title'], content['description'])
entry.blog = Blog[blogid]
entry.save
entry.oid
end
end
module MovableTypeApi
SCategory = Struct.new(:categoryId, :categoryName)
def mt__getCategoryList(blogid, username, password)
blog = Blog[blogid]
blog.categories.collect { |c| SCategory.new(c.oid, c.title) }
end
def mt__setPostCategories(postid, username, password, categories)
cid = categories.first['categoryId']
BlogEntry.update(postid, "category_oid=#{cid}")
true
end
end
class ApiController < Nitro::XmlRpcService
include BloggerApi
include MovableTypeApi
include MetaWeblogApi
end
That's all!
* Integrated an SQLite3 patch by Ghislain Mary.
* Integrated PostgreSQL binary data patch by Michael Neumann.
* Fixed all reported bugs.
Nitro is an efficient, yet simple engine for developing professional
Web Applications using the Ruby language. Nitro aims to provide a
robust infrastructure for scalable web applications that can be
distributed over a server cluster. However, Nitro can also power simple
web applications for deployment on intranets or even personal
computers. Nitro integrates the powerful Og Object-Relational mapping
library.
Nitro is a multiparadigm application framework and will integrate ideas
from Rails, Wee, PHP, JSP and .NET
Nitro integrates the Og (ObjectGraph) object-relational mapping
library. Og provides transparent serialization of object graphs to an
RDBMS backend. Unlike other similar libraries Og maps standard Ruby
objects to SQL tables and not vice versa. Og provides a meta language
to describe the relations between objects, a flexible and intuitive API
for querying the database, raw access to the SQL language if needed
(for example to fine tune the automatically generated SQL tables, or
for custom queries), suports deserialization to Ruby objects or tuples,
automatically generates join tables for many_to_many relations and
provides a collection of usefull Mixins to synthesize common Entities.
Og is a combination of the best features of Active Record and the
former O-R mapping library included in Nitro (NDB). Adapters for
PostgreSQL, MySQL, SQLite and Oracle are included along with an
experimental In-Memory/Filesystem adapter.
I hope this software will be useful for you, and I would love to
receive your suggestions, ideas and bug reports.
have fun,
George Moschovitis