Referring to version numbers in a gem

So do Rails, ActiveRecord, Rack, NokoGiri, Cucumber, among others.
http://stackoverflow.com/questions/7532285/which-format-should-the-version-constant-of-my-project-have

Steve Klabnick recommends the same. He also recommends putting that
library’s VERSION constant into a version.rb.
http://timelessrepo.com/making-ruby-gems

Which likewise is the approach Rails uses.

http://guides.rubyonrails.org/initialization.html#railties-lib-rails-version-rb

On Nov 11, 2011, at 20:20 , Chad P. wrote:

Using a constant could prove problematic. As I said in an earlier
response:

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.

According to my stats, I’ve got 526 releases that all use this pattern
and I’ve never once had a problem with using the VERSION constant.
“could prove problematic” sounds like urban legend to me more than a
real issue.

On Sat, Nov 12, 2011 at 05:25:21PM +0900, Ryan D. wrote:

According to my stats, I’ve got 526 releases that all use this pattern
and I’ve never once had a problem with using the VERSION constant.
“could prove problematic” sounds like urban legend to me more than a
real issue.

“Urban legend” is not something that actually happened to me and that I
saw someone else comment about on this list a few days later. “Urban
legend” is something that one can only say “I have a friend who has a
friend who said he heard about this.” Unfortunately, it was quite a
while ago, and I don’t recall the specifics of the situation. I’ll try
to track down the event.

Keep the data where ever you want, Rubygems has tossed the FHS out the
window so it doesn’t really matter.

The common way that has sprouted up, popularized by Bundler, is rather
ass
backwards from the developers point of view. So flip it:

module MyShit
  VERSION = File.read(File.dirname(__FILE__)+'/../VERSION').strip
end

Now that’s a rather simplistic approach, I can show you much better, but
it
conveys the idea.

Of course, it all sort of begs the question of why Ruby itself isn’t
version aware and could just tell us the version of a library, without
developer’s having to manually insert it.

On Nov 12, 5:31pm, Intransition [email protected] wrote:

Now that’s a rather simplistic approach, I can show you much better, but it
conveys the idea.

What do you think is backwards? You obviously don’t think it’s
backwards to have a constant of Whatever::VERSION. And you obviously
don’t think it’s backwards to have the version contained in a separate
file.

Why not make it actually simple instead of just simplistic?

module MyShit
VERSION = ‘whatever you were trying to store in a separate file
for no obvious reason goes here’
end

Da: Intransition [mailto:[email protected]]
Inviato: domenica 13 novembre 2011 04:01
A: ruby-talk ML; [email protected]
Cc: ruby-talk ML; [email protected]
Oggetto: Re: referring to version numbers in a gem

@yossef

As a developer/project-manager it’s more desirable to keep all the
project’s
metadata in a single source, and up at the toplevel of the project.

The constant is added only b/c that’s become the expected norm, and Ruby
lacks any standard protocol for accessing library metadata.

What I do more specifically is more advanced. All my projects has a
standard
metadata file that I interface to the code.


Caselle da 1GB, trasmetti allegati fino a 3GB e in piu’ IMAP, POP3 e
SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
Conto Arancio al 4,20%. Soldi sempre disponibili, zero spese, aprilo in
due minuti!
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=11920&d=29-12

@yossef

As a developer/project-manager it’s more desirable to keep all the
project’s metadata in a single source, and up at the toplevel of the
project.

The constant is added only b/c that’s become the expected norm, and Ruby
lacks any standard protocol for accessing library metadata.

What I do more specifically is more advanced. All my projects has a
standard metadata file that I interface to the code.

-----Messaggio originale-----
Da: Chad P. [mailto:[email protected]]
Inviato: venerd 11 novembre 2011 21:28
A: ruby-talk ML
Oggetto: referring to version numbers in a gem

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 P. [ original content licensed OWL: http://owl.apotheon.org ]

Caselle da 1GB, trasmetti allegati fino a 3GB e in piu’ IMAP, POP3 e
SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:

Riccione Hotel 3 stelle in centro: Pacchetto Capodanno mezza pensione,
animazione bimbi, zona relax, parcheggio. Scopri l’offerta solo per
oggi…

Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=11982&d=29-12