Friday, March 12, 2010

Announce: couch_docs 1.1

‹prev | My Chain | next›

With directory watcher successfully watching for changes, I am ready to publish couch_docs version 1.1!

The couch_docs gem provides a mechanism for dumping CouchDB documents and design documents to the file system and pushing them from the file system to the CouchDB server. Regular documents are stored on the file system as .json documents. Design documents are mapped onto the file system as directories (keys) and .js files (values)—for example: _design/recipes/count_by_month/map.js.

New in 1.1 is the ability to use !code macros (just like in couchapp) in the design documents stored on the file system. This is a nice way of keeping design documents DRY.

There are more options supported by the couch-docs script that comes with the couch_docs gem:
cstrom@whitefall:~/repos/couch_docs$ couch-docs --help
Usage: couch-docs push|dump [OPTIONS] couchdb_url [target_dir]

If a target_dir is not specified, the current working directory will be used.

Push options:
-R, --destructive Drop the couchdb_uri (if it exists) and create a new database
-w, --watch Watch the directory for changes, uploading when detected

Dump options:
-d, --design Only dump design documents
-D, --data Only dump data documents

Common options:
-v, --version Show version
-h, --help Show this message
The other big new features in 1.1 was a last minute addition—the previously mentioned directory watcher. This will let me test out changes quickly without needing to copy & paste changes in Futon temporary design documents.

I document the complete list of changes that I have made in History.txt:
== 1.1.0 / 2010-03-13

* Better command line experience.
* Default to current directory.
* Print help without args / better format (optparse).
* Support the !code macro from couchapp.
* Support a flag (-d) to only work on design docs.
* Can create the DB if it doesn't already exist
* Command line can be used to watch for local changes to be pushed immediately to the CouchDB server.
I also update the RDoc for the project.

With that, it is time to push to gemcutter / rubygems. First I need gemcutter on this machine:
cstrom@whitefall:~/repos/couch_docs$ gem install gemcutter
WARNING: Installing to ~/.gem since /var/lib/gems/1.8 and
/var/lib/gems/1.8/bin aren't both writable.


Thanks for installing Gemcutter! You can now run:

gem push merged into RubyGems 1.3.6
gem owner merged into RubyGems 1.3.6
gem webhook register urls to be pinged when gems are pushed
gem yank remove a specific version of a gem from


Successfully installed gemcutter-0.5.0
1 gem installed
Then I build the gem:
cstrom@whitefall:~/repos/couch_docs$ gem build couch_docs.gemspec
Successfully built RubyGem
Name: couch_docs
Version: 1.1.0
File: couch_docs-1.1.0.gem
And, finally, push the gem to gemcutter (now rubygems):
cstrom@whitefall:~/repos/couch_docs$ gem push couch_docs-1.1.0.gem
Enter your Gemcutter credentials. Don't have an account yet? Create one at
Signed in. Your api key has been stored in ~/.gem/credentials
Pushing gem to Gemcutter...
Successfully registered gem: couch_docs (1.1.0)
Just like that I have an updated gem:

That was easy.

Day #40

No comments:

Post a Comment