On Sat, Nov 12, 2011 at 05:53:46AM +0900, Jeremy B. wrote:
The trick with both of these schemes is to keep the internal version
information in sync with the gem version. How you do that depends on
how you build your gem, but generally speaking, you have two fairly
The first is to define your constant in a minimal version.rb file and
then load that to get the version when building your gem. The other is
to generate the version.rb file based on some other specification of the
version when you build the gem.
Do you have any specific examples in mind for how to accomplish each of
those approaches – something fairly standard or well-defined – so I
would not have to reinvent a wheel someone else has probably already
Of course, you could also manually define your version in multiple
places. That’s crazy talk though as far as I’m concerned.
As things currently stand, I find myself specifying the version in the
s.version = 'N.N.N'
. . . and in the library:
@version = Gem::Version.new 'N.N.N'
def self.version; @version; end
Then, in the executable, I just call
Foo.version when I want version
information. It seems like I’m missing some easy way to get the version
information into the gemspec (or out of the gemspec), to eliminate that
I’m using the Gem::Version thing for now in part because I’ve seen cases
where for some reason a VERSION constant conflicts with something else
the Ruby environment. I haven’t seen it in quite a while, but I don’t
want to have to deal with that kind of issue.