--27844531-POCO-38270576
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

Chad Fowler:
> On Wed, 24 Dec 2003, Curt Hibbs wrote:
>> Phil Tomson wrote:
>>> Something like:
>>>   # let's see if they've already got rexml:
>>> begin
>>>   require 'rexml'
>>> rescue MissingPackage # or whatever it's really called
>>>   # it's really not here, so go look for one to download
>>> else
>>>   # it is here already, maybe check out the version somehow
>>>   # otherwise everything should be OK
>>> end
>> This is too simple. RubyGems should also check that the proper
>> version is installed.

I haven't made a RubyGem, yet, but why not treat:

  dependencies: { :rexml => { :at_least => '2.7.2' } }

as a translation to:

  dependencies.each do |lib, tests|
    begin
      has_gem(lib => tests)
    rescue RubyGems::NotInstalledError
      begin
        require lookup_lib(lib)
        tests.each { |test, version| test_version(test, version) }
      rescue LoadError, RubyGems::VersionError
        download_gem(lib, version)
      end
    end
  end

lookup_lib would be something like:

  def lookup_lib(lib)
    RubyGems::KNOWN_LIBS[lib] or lib
  end

Where KNOWN_LIBS might look like:

  RubyGems::KNOWN_LIBS['rexml'] = 'rexml/document'

One of the things that should be encouraged is perhaps creating a
VERSION constant as a VersionTuple (see the attached file).

This would mean that you *don't* have to enter manual-installation-
entry stuff. It would be a bit more complex for things that require
an external library (e.g., compiled RubyGems, such as libxml or
libxslt), but the pattern is the same.

-austin
--
austin ziegler    * austin / halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.12.25
                                         * 20.29.36


--27844531-POCO-38270576
Content-Type: application/octet-stream; name="version_tuple.rb"
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename="version_tuple.rb"

Y2xhc3MgVmVyc2lvblR1cGxlCiAgaW5jbHVkZSBDb21wYXJhYmxlCgogIGRlZiBpbml0aWFsaXpl
KCp2ZXJzaW9uKQogICAgQHZlcnNpb24gPSB2ZXJzaW9uCiAgZW5kCgogIGRlZiB0b19zdHIKICAg
IEB2ZXJzaW9uLmpvaW4oJy4nKQogIGVuZAoKICBkZWYgdG9f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