[Rubygems-developers] bug in latest_specs

Ryan Davis ryand-ruby at zenspider.com
Wed Sep 5 04:38:15 EDT 2007


This is the latest version I've been monkeypatching with:

class Gem::SourceIndex
   alias :dead_latest_specs :latest_specs
   def latest_specs
     result, latest = Hash.new { |h,k| h[k] = [] }, {}

     each do |full_name, spec|
       name = spec.name
       curr = spec.version
       prev = latest[name] || curr

       next unless curr >= prev

       if curr > prev then
         result[name].clear
         latest[name] = curr
       end

       result[name] << spec
     end

     result
   end
end

Seems to work well, tho it returns a different structure than before.  
It seems to work pretty well. I'm pretty sure that latest_specs is  
only used sparingly within (if at all) and other than that, I think  
I'm the only external client of this method (at least, of the actual  
values of the hash).


More information about the Rubygems-developers mailing list