As the release note says, RubyGems 1.2.0 now supports two levels of gem dependencies, runtime and developer. If you don’t use add_development_dependency
to specify a dependency, RubyGems treats it as a runtime dep.
Google, in its questionable wisdom, tells me that there’s not much interest in this feature. Echoe is already using it, which is simultaneously unsurprising and reassuring.
Perhaps I shouldn’t find the lack of widespread acclaim strange. I suppose Ruby developers don’t hack other people’s code, they just use it. GitHub will change this, perhaps already is changing this. Case in point: I cloned a project today just to see how it works, with no intention of actually using it. The project’s tests failed because I didn’t have three dependencies: one runtime, two developer.
Super. Let’s add some RubyGems 1.2.0 typed dependencies (17 Awesome Points go to anyone who can figure out the project based on this snippet).
spec = Gem::Specification.new do |s|
...
s.add_runtime_dependency 'right_aws'
s.add_development_dependency 'Shoulda'
s.add_development_dependency 'mocha'
...
end
Now, build the gem using whatever means have been provided, and install it with its developer dependencies.
… Wait, what? The release announcement doesn’t tell me how to do trigger the developer dependencies. Google is no help, either. And good luck finding RDocs for RubyGems.
After I started grumbling, but before diving into the rubygems source, I remembered to run gem help install
. There I found this beautiful, kissable tip:
--development Install any additional development
dependencies
Here’s the information you came for: To install a gem with developer dependencies, use gem install --development
Developer dependencies should also be useful with a rake setup
task, as Assaf Arkin advises having for all public projects. Somebody’s going to have to dive into the source code to figure out how to make that work.
So now I have added some niceness to a project I cloned from GitHub. It’s not much more work to fork the project, commit my changes, and shoot off a pull request. All for a project I’m not really going to use. Long live GitHub.