On Fri, Nov 11, 2011 at 2:28 PM, Chad Perrin <code / apotheon.net> wrote:

> How do I specify and access a gem's version number within the code of the
> gem itself?  For example:
>
> 1. I write a library.
> 2. I write a command line utility that uses that library.
> 3. The utility uses OptionParser, with a --version option.
> 4. I package the things up inside a gem.
>
> What's the best way to specify the version number and give the code
> executed when the --version argument is supplied the ability to access
> that version number?
>
> --
> Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]
>


Just use your git hash:

# assumes file is in root/lib/gem_name.rb
module GemName
  VERSION = `git --git-dir="#{File.dirname __FILE__}/../.git" rev-parse
origin/master`
end



;)~