print gem VERSION from ruby program

R

R.. Kumar

jeweler maintains a file VERSION in the base directory.
My program in bin has an option,
prog --version.

Currently. I have a constant VERSION in prog.rb. This is never in synch
with the VERSION file, it should be.

Is there any way of either updating the constant whenever I do a jeweler
version:bump. Or else, my program inside lib/ should be able to get to
the VERSION file. However, note that File.open("../VERSION") fails since
it tries to check in the parent of the dir where user currently is
running the app from.

thx, rkumar
 
R

Roger Pack

, note that File.open("../VERSION") fails since
it tries to check in the parent of the dir where user currently is
running the app from.

File.open(File.dirname(__FILE__) + "/../VERSION")
 
R

R.. Kumar

Roger Pack wrote:

Roger,

How do you post an announcement [ANN] to rubyforge.org and this forum.
Do you use post_news of rubyforge command ?

Is there something in rake ?

Thx.
 
R

Roger Pack

Rein said:
Roger, you shouldn't depend on files outside of the lib/ dir when
bundling your library as a gem. This was a problem for Rack for a while
as some tools will move the lib dir out and break your relative path.

Good point. For bundling sake I'd therefore suggest moving the file
VERSION into your lib dir. Though, in reality, it's probably the tools
that should bundle the whole gem not just its lib dir...at least if they
want to be totally gem compatible.
-r
 
R

Roger Pack

R.. Kumar said:
Roger Pack wrote:

Roger,

How do you post an announcement [ANN] to rubyforge.org and this forum.
Do you use post_news of rubyforge command ?

I've never posted an announcement to rubyforge.org
Anybody?
-r
 
T

Tom Copeland

R.. Kumar said:
Roger Pack wrote:
=20
Roger,
=20
How do you post an announcement [ANN] to rubyforge.org and this = forum.=20
Do you use post_news of rubyforge command ?
=20
I've never posted an announcement to rubyforge.org
Anybody?

Yup, the rubyforge gem has a option for that:

$ rubyforge --help | grep post_news
post_news(group_id, summary, details)
rubyforge post_news codeforpeople.com "new release" "this release =
is great!"
rubyforge post_news 1024 traits "new release" "this release is =
great!"

Yours,

Tom
 
I

Intransition

Good point. For bundling sake I'd therefore suggest moving the file
VERSION into your lib dir. =A0Though, in reality, it's probably the tools
that should bundle the whole gem not just its lib dir...at least if they
want to be totally gem compatible.

Easy solution:

cd lib/foo
ln -s ../../VERSION version.yml

Or .txt as the case may be.
 
G

Gabriel Horner

Roger said:
VERSION into your lib dir. Though, in reality, it's probably the tools
that should bundle the whole gem not just its lib dir...at least if they
want to be totally gem compatible.

Disagree for two reasons. First, keeping VERSION out of lib/ breaks
library namespacing conventions i.e. lib/name.rb and lib/name/.
Versioning is part of library so why should it be different?
Second, this goes against the emerging ruby packaging standard (RPS),
http://chneukirchen.github.com/rps/. RPS clearly calls for all library
code to reside in lib/. As a community, I think we should embrace this
emerging spec seeing it is the only serious attempt at standardizing
ruby packages.

Gabriel
 
R

R.. Kumar

Thomas said:
Easy solution:

cd lib/foo
ln -s ../../VERSION version.yml

Or .txt as the case may be.

Actually, I thought of this earlier. The mistake I made was of trying to
read the file using require or load and of course got the error.
Then, i wondered whether the link would be portable -- if someone forks,
or updates the gem it won't work. But i suppose that's not too important
?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top