Ambition
Plain Jane Ruby
Imagine if instead of writing SQL, you could write Ruby. Instead of writing LDAP, you could write Ruby. Instead of learning some esoteric API, you just stick to one you know and love.
Imagine Ambition.
>> LDAP::User.select { |m| m.name == 'jon' && m.age == 21 }.to_s => "(&(name=jon)(age=21))" >> SQL::User.select { |m| m.name == 'jon' && m.age == 21 }.to_s => "SELECT * FROM users WHERE users.name = 'jon' AND users.age = 21"
It started with SQL, but it’s become so much more.
The Elevator Pitch
Ambition is a framework for writing adapters. Adapters are RubyGems which depend on the
ambition
gem and are named something along the lines of ambitious-activerecord
. They typically
use Ambition to turn plain jane Ruby into some sort of domain specific query which can be executed.
Anyone can write and release an adapter. This site describes how to write adapters using Ambition and also hosts a few.
The Community
We’ve got a hoppin’ community over at the Google Group. Feel free to jump in with any questions, ideas, or top 5 favorite bands discussions.
The initial blog posts were this and that.
Most of what they describe has become the ambitious-activerecord
gem.
Ambitious Adapters
Adapters are gems named ambitious-something
, where something corresponds to the data
store they are adapting. They can be required in code via ambition/adapters/something
.
To install and test the ActiveRecord adapter:
$ gem install ambitious-activerecord $ irb >> require 'rubygems' >> require 'ambition/adapters/active_record'
Adapters typically inject themselves into their target automatically, so that should be all you need.
There are a few adapters in development or released currently:
- ActiveRecord
- ActiveLDAP
- XPath
- CouchDB
- DataMapper
For information on authoring adapters, hit up the adapters page.
Development
Development discussion happens in the Google Group. Stay up to date by following Chris’ git repository:
git clone git://github.com/defunkt/ambition