From: "Wayne E. Seguin" Date: 2007-07-11T00:13:53+09:00 Subject: Re: Getting Gem Version from Within a Gem --Apple-Mail-15--385203793 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Jul 10, 2007, at 11:05 , Frew Schmidt wrote: > I am the author of the application in question. I tested your > suggestion by doing a > >>> puts GemConstName::Version::STRING > > to see if it would have the variable defined by the gem system as > defined in my gemspec, but it didn't work. Is there something I > need to > do to make this work? > > Thanks for your help! Frew, why yes there is!!! Thank you for clarifying the question. Tis simple! In lib/gem_name/version.rb place code like: ================================= module GemName module Version # A method for comparing versions of required modules. It expects two # arrays as parameters, and returns true if the first is no more than the # second. def self.check(expected, actual) #:nodoc: good = false if actual[0] > expected[0] good = true elsif actual[0] == expected[0] if actual[1] > expected[1] good = true elsif actual[1] == expected[1] && actual[2] >= expected[2] good = true end end good end MAJOR = 0 MINOR = 1 TINY = 2 STRING = [MAJOR, MINOR, TINY].join(".") SSH_REQUIRED = [1,0,10] SFTP_REQUIRED = [1,1,0] end end ================================= Then require the version file in one of the main entry point files: require "lib/gem_name/version" Hope this helps! Gems are so much fun to develop. -- Wayne E. Seguin Sr. Systems Architect & Systems Admin wayneseguin@gmail.com --Apple-Mail-15--385203793--