The Stunningly Easy Way to Live On The Edge Of DataMapper
DataMapper is organized into sub-projects, much like Merb, and that tends to confuse even the people working on it….until recently. Michael Ivey, an active contributer to the Merb project, and our very own Dan Kubb have collaborated on a set of Sake tasks to help automate and streamline checking out, packaging, installing, uninstalling, updating, repackaging, and reinstalling the DataMapper and Merb projects.
If you like to live life on the edge, this is the happiest way to do it.
Step 0 – The Setup
A couple of very basic requirements before we begin. First, you’ll need to have an up-to-date installation of Rubygems, the Ruby package management system. The most recent version is 1.1.1. To check what version you have do:
1 gem --version
If you aren’t on 1.1.1, update by running
1 sudo gem update --system
Next, you’ll need git. It’s the source code management tool DataMapper uses. Its installation is left up to the reader, but here’s a few good resources to go to for help:
- Git – Fast Version Control System – Homepage
- Installing GIT on MAC OSX 10.5 Leopard
- Git On Windows
- Installing Git on Ubuntu
After that, you’ll need to gem uninstall any of the “dm-*” projects you already have installed. This includes ‘data_objects’ and its associated adapters.
Next, you’ll need a few of the base dependencies. To install them, run
sudo gem install addressable english rspec
Once that’s done, do the following:
1 mkdir -p ~/src 2 cd ~/src
Step 1 – Have Some Sake
No, not the wonderful alcoholic beverage, the system-wide rake tasks library by PJ Hyett and Chris Wanstrath of Err. The Blog. Ivey’s and dkubb’s automated installation and reinstallation scripts are written as sake tasks, so you’ll need it installed on your machine.
1 sudo gem install sake
Once you’re done, you should be able to see sake in your path by executing which sake and see where gem installed it.
Step 2 – Install the Tasks
Now that you’re all setup with sake and the src directory, it’s time to install the sake tasks. They can be found at http://github.com/dkubb/dm-dev/ and are very easily installed by doing:
1 sake -i http://datamapper.org/dm-dev.sake
The tasks that get installed are available for perusal by issuing sake -T
$ sake -T sake dm:clone # Clone a copy of the DataMapper repository and dependencies sake dm:gems:refresh # Pull fresh copies of DataMapper and refresh all the gems sake dm:gems:wipe # Uninstall all RubyGems related to DataMapper sake dm:install # Install dm-core, dm-more and do sake dm:install:core # Install dm-core sake dm:install:do # Install do drivers sake dm:install:do:data_objects # Install data_objects sake dm:install:do:mysql # Install do_mysql sake dm:install:do:postgres # Install do_postgres sake dm:install:do:sqlite3 # Install do_sqlite3 sake dm:install:more # Install dm-more sake dm:install:more:merb_datamapper # Install merb_datamapper sake dm:sake:refresh # Remove and reinstall DataMapper sake recipes sake dm:update # Update your local DataMapper. Run from inside the top-level dm dir
Step 3 – Live a little
Change directories into the src directory and run sake dm:clone. You’ll see git cloning DataMapper Core, DataMapper More, and DataObjects from their respective repositories on GitHub. When that’s done, cd dm and have a look around.
When your ready, return to ~/src/dm and issue sake dm:install.
All Together Now
When executed together, these 3 steps amount to 7 lines at the command line. Talk about stunningly easy.
1 mkdir -p ~/src 2 cd ~/src 3 sudo gem install sake 4 sake -i http://datamapper.org/dm-dev.sake 5 sake dm:clone 6 cd dm 7 sake dm:install
Changes happen to DataMapper and it’s buddies all the time. To refresh your installation of DataMapper and DataObjects, return to ~/src/dm and issue:
1 sake dm:gems:refresh
It will uninstall your local gems, pull down fresh changes from github, and reinstall the gems again.
On a side note, checkout http://merbivore.com/merb-dev.sake for the original merb related sake tasks by Michael Ivey wrote that these came from.