[ANN] KirbyRecord 0.0.0

I am proud(?) to announce the first actual release of KirbyRecord. KirbyRecord is an ORM layer for the very cool pure ruby database, KirbyBase. KirbyRecord was initialized inspired in design by ActiveRecord, but as you can see I've stolen ideas from Og as well now.
Here are its features:

1) Like KirbyBase, its written in pure ruby, and fits in a single file.
2) You can let it be run by the database, or you can define the database with it
3) I wrote lots of comments that look ok after running rdoc

Lets do some examples, I don't think this whole writting a feature list will work

class Author < KirbyRecord::Base
             has_many :books
end

Just like ActiveRecord you say? Well you'd be wrong, for behold!

a = Author.find(:first) { |r| r.name == "Stephen King" }
b = Book.new( :title => "The Shining" ) # pretending I wrote the boilerplate for Book
a.books << b # Egads! What madness is this?

Incidently as you may have noticed it now does plurals, sort of (tacks an s on the end) and you don;t have to use those silly get_ and set_ prefixes like in the proof-of-concept

Maybe you don't want to make the database before hand with calls to KirbyBase#create_table and such. Well have no fear, KirbyRecord now knows how to make a database from your class definitions. Its a little more typing than with the KirbyBase interface, but you can almost pretend that you now have magical objects that persist from session to session, and all you had to do was write column instead of attr_accessor

class Author < KirbyRecord::Base
       column :name, :String
       col_belongs_to :publisher
       has_many :books
end

class Publisher < KirbyRecord::Base
     column :name, :String
     has_many :books
end

class Book < KirbyRecord::Base
     column :title, :String
     column :author_id, :Integer
     belongs_to :author # just to demonstrate the utility of col_belongs_to
     column :isbn, :Integer, 0 # Look ma, defaults! I could have also done default :isbn => 0 to set
                                                # a default for a field that wasn't declared with column or didn't have
                                                # a default yet
end

This column stuff is cool but one warning, KirbyRecord always gets its methods from the db, if theres already a table with the name of your class it doesn't even look at the columns you declared (except for the default values). On the other hand if the table doesn't exist, KirbyRecord will create it for you after you use an object for the first time.

There are more examples of all this stuff in the comments (which you can run rdoc on in the file). I hope someone finds a use for this stuff, and gets back with feedback.

kirbyrecord.rb (10.8 KB)

Logan-
     This looks like a lot of fun! Very nice that its all ruby. Keep it coming.
Thanks-
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster

509-577-7732
ezra@yakima-herald.com

ยทยทยท

On Sep 15, 2005, at 3:52 PM, Logan Capaldo wrote:

I am proud(?) to announce the first actual release of KirbyRecord. KirbyRecord is an ORM layer for the very cool pure ruby database, KirbyBase. KirbyRecord was initialized inspired in design by ActiveRecord, but as you can see I've stolen ideas from Og as well now.
Here are its features:
<snip sweetness>
This column stuff is cool but one warning, KirbyRecord always gets its methods from the db, if theres already a table with the name of your class it doesn't even look at the columns you declared (except for the default values). On the other hand if the table doesn't exist, KirbyRecord will create it for you after you use an object for the first time.

There are more examples of all this stuff in the comments (which you can run rdoc on in the file). I hope someone finds a use for this stuff, and gets back with feedback.

<kirbyrecord.rb>

Logan Capaldo wrote:

I am proud(?) to announce the first actual release of KirbyRecord. KirbyRecord is an ORM layer for the very cool pure ruby database, KirbyBase. KirbyRecord was initialized inspired in design by ActiveRecord, but as you can see I've stolen ideas from Og as well now.

Nice job, Logan!

Jamey