sake is a tool for system-wide rake tasks. It was created by Chris Wanstrath and is now maintained by postmodern. It provides a handy way to distribute generally-useful rake tasks. The advantage of sake over, say, a script in ~/bin is that 1) you have a predictable interface and 2) its easy to distribute tasks with sake -i http://any-url (in theory).
Ben Schwarz has written a great sake task for installing a ssh-public-key on a remote server. You can install it with sake -i http://github.com/benschwarz/sake-tasks/tree/master%2Fssh%2Fssh.sake?raw=true . (If you haven’t seen highline before, check it out. It’s a nice abstraction and clean alternative to using gets and puts.)
A sake task for installing remote git repos
Based on Ben’s task I’ve created a task for installing remote git repos.
The above task will do two things:
- Create the bare repository on a foreign server
- Optionally create a local working copy
There’s a bug in the above authentication code, did you catch it? For authentication, it will use your ssh keys if it finds it otherwise it will ask you for a password. However, if your ssh keys aren’t valid then it simply fails. Ideally it would ask you for a password and retry in this case.
I’m not too concerned about this however; if you’re creating a git repo remotely, you probably want to clone it and you also probably have your ssh keys setup to do so. (I probably shouldn’t be checking for a password at all.)
I believe sake is a great idea, but there is some rough edges in the current implementation.
Current Gem has a bug
Today, if you gem install sake there is a bug such that sake wont even run. Your best bet is to clone drnic’s repo sake >= 1.0.16 and install from there.
My guess is that this is because sake’s creator recently put out a request for someone to take over the project and the person who took it over hasn’t upgraded the rubyforge gem.
Another bug that seems to be specific to this version of sake, when I run sake -i the task names and namespaces are created but the ~/.sake file contains no code.
Again, this just seems to be a minor bug with the current version and as such I see it as temporary. I’m planning on working on a patch on for this, though I’m not sure I’ll fix it before someone else.
The built-in way to do sake task development is to write a little bit, then sake -i your file, then write a little bit more etc. This gets old fast. Because of that drnic has written a great project for sake task development. In that project you run sake testrun taskname.
drnic’s project is handy and makes sake task development a snap. However, I think this fact could slow the adoption of sake; it’s a barrier to entry if you have to install a second project just to develop the first.
Even so …
I still think that the idea of sake is solid. There is definitely a need for easily distributable, reusable, system-wide rake tasks. Despite its current shortcomings, sake is definitely worth a look.