Using version constants with Jeweler
There were two motivations for this:
- Allowing the use of a Version module (ie Jeweler::Version) in your project which contains your version information
- This lets users of your library be able to check the version of your library they are using
- Not require an extra file, VERSION, in your project root
One side effect of this is that you can’t use the Jeweler rake tasks for bumping the version, since it doesn’t know specifically where the version is coming form, and wouldn’t know how to regenerate that file with the new version information.
I’ll give two examples of using this new functionality. First, we’ll just set it directly on the gemspec, and second, we’ll use a version constant.
Okay, let’s assume you’re project is called ‘trogdor’. Your
Rakefile is going to look something like this initially:
All you really need to do is just set
gemspec.version. We’ll use 0.1.0 for an initial release.
For the second usage, we’ll move this version to its own file. Let’s make
Then we need to update
Rakefile to require this, and set
Now that we know how to set the version, how does this affect version bumping and releasing? Not much really, except that you can’t use the
version:bump rake tasks. Now you’ll do something like this
- Make awesome code
lib/trogdor/version.rbto reflect the new version
- Do the usual
And that is all there is to it.