--huq684BweRXVnRxX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Nov 12, 2011 at 05:53:46AM +0900, Jeremy Bopp 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
> decent options.
> 
> 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
figured out?


> 
> 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
gemspec file:

    s.version = 'N.N.N'

. . . and in the library:

    module Foo
      @version = Gem::Version.new 'N.N.N'
      def self.version; @version; end
    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
duplication, somehow.

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 in
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.

-- 
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]

--huq684BweRXVnRxX
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAk69kkIACgkQ9mn/Pj01uKUvvACgitMRstXW0UdBxl1C9bJhCxZx
pU4An3rX+mPND+AWLo1DGjgO2DF1jHDM
tr
-----END PGP SIGNATURE-----

--huq684BweRXVnRxX--