Project

version

0.09
No commit activity in last 3 years
No release in over 3 years
simple version-number encapsulation
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 12
~> 3
 Project Readme

Version¶ ↑

Description¶ ↑

Version is a simple wrapper around the concept of version-numbering schemes.

Features¶ ↑

  • Rake::VersionTask provides tasks for simple version bumping

  • Version smartly handles several versioning schemes, abstracting the details

Examples¶ ↑

Screencast¶ ↑

For a quick introduction, watch the screencast of my presentation at the Atlanta Ruby Users’ Group.

Rake Tasks¶ ↑

Version comes with a Rake::VersionTask that lets you manage version numbering automatically. Place the following in a Rakefile:

require 'rake/version_task'
Rake::VersionTask.new

You’re all set up.

$ rake version:create VERSION=0.1.0 # => 0.1.0

Now ‘rake -T version` will tell you what all you can do.

$ version [master *$%]$ rake -T version
rake version                    # Print the current version number (0.1.0)
rake version:bump               # Bump to 0.1.1
rake version:bump:major         # Bump to 1.0.0
rake version:bump:minor         # Bump to 0.2.0
rake version:bump:pre           # Bump to 0.1.1a
rake version:bump:pre:major     # Bump to 1.0.0a
rake version:bump:pre:minor     # Bump to 0.2.0a
rake version:bump:pre:revision  # Bump to 0.1.1a
rake version:bump:revision      # Bump to 0.1.1
rake version:create             # Creates a version file with an optional VERSION parameter

$ rake version                      # => 0.1.0
$ rake version:bump                 # => 0.1.1
$ rake version:bump:minor           # => 0.2.0
$ rake version:bump:revision        # => 0.2.1
$ rake version:bump:pre             # => 0.2.2a
$ rake version:bump                 # => 0.2.2
$ rake version:bump:major           # => 1.0.0
$ rake version:bump:minor           # => 1.1.0
$ cat VERSION                       # => 1.1.0

The VersionTask can automatically manage git tagging for you, too.

Rake::VersionTask.new do |task|
  task.with_git_tag = true
end

And if you want the VersionTask to automatically emit updated gemspecs on version-bumps, use the with_gemspec flag.

spec = Gem::Specification.new do |s|
  ...
end

Rake::VersionTask.new do |task|
  task.with_gemspec = spec
end

Version also supports a .yml VERSION file. See the VersionTask rdoc for details.

Library Versioning¶ ↑

Version lets you automatically keep an in-class VERSION constant in sync with the contents of the version file on disk. Version also provides a class-level current method which lets you get the current version without setting a class-level constant.

require 'version'

Version.current # => 1.0.1

class Foo
  is_versioned
end

Foo::VERSION # => 1.0.1

The Version.current and Class::is_versioned methods both take a filename parameter if you use a different location for the VERSION file. See the Version.current rdoc for details.

Manipulation in Code¶ ↑

All the above functionality is performed behind-the-scenes by the Version library. It’s simple to use, but I’ll be surprised if there’s much point beyond doing the legwork for the Rake task and class versioning.

v = "1.2.0".to_version
v.to_s                       # => 1.2.0
v.bump!                      # => 1.2.1
v.bump!(:major)              # => 2.0.0
v.bump!(:minor, false, true) # => 2.1
v.major = 3                  # => 3.0
v.to_a                       # => ['3', '0']

Install¶ ↑

[sudo] gem install version