diff options
author | Andre Arko <andre@arko.net> | 2011-07-12 17:33:56 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2011-07-12 17:33:56 -0700 |
commit | 22551eb58dca35e89c9904a19f6381b1d81d83d3 (patch) | |
tree | 7b068e8c2452f8a665bb1e68bfa3ece9e6f4c436 /lib | |
parent | f22a270c357c1a02cb193e082352d17f8b196e62 (diff) | |
parent | 56b12067e5def52d21032391d7dde061183038dc (diff) | |
download | bundler-22551eb58dca35e89c9904a19f6381b1d81d83d3.tar.gz |
Merge pull request #1282 from cmeiklejohn/bundler
---
RubyGems expects that SpecSet acts like an array, presumably because when working outside of bundler the set is an Array.
For example, when trying to generate_index, this causes the following error:
undefined method `<< for #<Bundler::SpecSet:0x7ff9eb37b558>
/home/cmeiklejohn/.rvm/rubies/ree-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/specification.rb:307:in `add_spec
/home/cmeiklejohn/.rvm/rubies/ree-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/specification.rb:322:in `add_specs
/home/cmeiklejohn/.rvm/rubies/ree-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/specification.rb:321:in `each
/home/cmeiklejohn/.rvm/rubies/ree-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/specification.rb:321:in `add_specs
/home/cmeiklejohn/.rvm/rubies/ree-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/indexer.rb:129:in `build_indicies
/home/cmeiklejohn/.rvm/rubies/ree-1.8.7-head/lib/ruby/site_ruby/1.8/rubygems/indexer.rb:456:in `generate_index
Also, when examining the rubygems code, it assume it can call add, << and remove on the SpecSet. See (add_spec and remove_spec).
This patch uses Forwardable to delegate the expected methods down to the inner array within SpecSet.
Also, is 1-0-stable the correct place to be making this fix, or should I be making the fix on master?
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/spec_set.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 901888a1..3149c752 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -1,21 +1,18 @@ require 'tsort' +require 'forwardable' module Bundler class SpecSet + extend Forwardable include TSort, Enumerable + def_delegators :@specs, :<<, :length, :add, :remove + def_delegators :sorted, :each + def initialize(specs) @specs = specs.sort_by { |s| s.name } end - def each - sorted.each { |s| yield s } - end - - def length - @specs.length - end - def for(dependencies, skip = [], check = false, match_current_platform = false) handled, deps, specs = {}, dependencies.dup, [] skip << 'bundler' @@ -68,6 +65,10 @@ module Bundler value end + def sort! + self + end + def to_a sorted.dup end |