[Rubygems-developers] Overhaul of specification.rb

Gavin Sinclair gsinclair at soyabean.com.au
Sun Aug 15 08:12:41 EDT 2004


On Sunday, August 15, 2004, 4:43:00 AM, Chad wrote:


> On Aug 11, 2004, at 10:07 AM, Gavin Sinclair wrote:

>> On Wednesday, August 11, 2004, 10:02:21 PM, Chad wrote:
>>
>>
>>> On Aug 9, 2004, at 9:40 PM, Gavin Sinclair wrote:
>>
>>>    1) Error:
>>> test_to_ruby_and_back(TestLegacyRubySpecification):
>>> LoadError:
>>> Could not find RubyGem dev-utils (> 0.0.0)
>>
>>>      /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:50:in `require_gem'
>>>      /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:33:in `require_gem'
>>>      test_specification.rb:236:in `test_to_ruby_and_back'
>>
>>> Gavin, did you perhaps forget to cvs add something?
>>
>> No, that require_gem shouldn't have been there (any longer).  D'oh!!
>> Fixed now.
>>

> Looks like there's one more problem that I noticed while trying to 
> implement some other things:  Your alias for #test_suite_file works 
> when you're building a gem, but it doesn't work when you want to run
> tests on pre-existing gem files.  I suppose this is because YAML 
> doesn't touch your attributes, but instead just populates the instance
> variables of the Gem::Specification object.  So, for example, you can
> load the YAML and get a Gem::Specification object that has 
> "@test_suite_file" set properly, but calling "spec.test_suite_file" 
> doesn't work because "@test_files" is nil.  I'll try to get to this 
> later, but if anyone wants to take a crack at it before then, be my 
> guess.  I have my regular busy Saturday lined up unfortunately.

I'm guessing it's past your busy Saturday by now.  I'm trying to get
the 'library_stubs' attribute implemented, and running out of time for
the weekend, so I haven't been able to look at this.

I had a thought earlier about this problem though, the general problem
of Gem::Specification objects being created in two different ways
(Ruby and YAML).  A general solution would be this:

  class Specification

    #
    # Return a Gem::Specification loaded from the given YAML data,
    # after normalizing the attributes.
    #
    def self.from_yaml(string)
      spec = YAML.load(data)
      from_spec(spec)
    end

    #
    # Construct a Gem::Specification from the given Gem::Specification
    # object, normalizing the attributes.
    #
    def self.from_spec(spec)
      # ...
    end

I've gotta go now, so I can't implement from_spec just yet :)  Having
thought about it though, I don't think it's straightforward.  Hmmmm...

Well, I'll look into it more later, but I guess the obvious immediate
solution to the test_files problem is this (untested):

    def test_suite_file
      warn_deprecated(:test_suite_file, :test_files)
      (@test_files ||= [@test_suite_file]).first
    end

Perhaps a more general solution would have to be an explicit
conversion using the 'specification_version' attribute.

Cheers,
Gavin



More information about the Rubygems-developers mailing list