diff options
author | Andre Arko <andre@arko.net> | 2015-02-06 15:28:49 +1100 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2015-02-09 15:45:13 +1100 |
commit | 9263e08636d25e2573776b17416e6fabd403026b (patch) | |
tree | 01eb0b08fd2e3f627827e6e115817ce05db34057 /lib/bundler/source | |
parent | d7900f1b67934521fd2cf17ba43ebb2a1b94edae (diff) | |
download | bundler-9263e08636d25e2573776b17416e6fabd403026b.tar.gz |
LocalRubygems source for local gem specs
This class (and only this class) knows about gems that are installed
locally or present in vendor/cache. Because we now have multiple source
objects, it's much more efficient to only load the installed and cached
specs into one of those sources rather than all Rubygems sources.
Diffstat (limited to 'lib/bundler/source')
-rw-r--r-- | lib/bundler/source/local_rubygems.rb | 16 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 13 |
2 files changed, 20 insertions, 9 deletions
diff --git a/lib/bundler/source/local_rubygems.rb b/lib/bundler/source/local_rubygems.rb new file mode 100644 index 00000000..40f072f3 --- /dev/null +++ b/lib/bundler/source/local_rubygems.rb @@ -0,0 +1,16 @@ +module Bundler + class Source + class LocalRubygems < Rubygems + + def specs + @specs ||= begin + idx = super + idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote + idx.use(installed_specs, :override_dupes) + idx + end + end + + end + end +end diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index b3bbe2c1..a769ee69 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -66,15 +66,10 @@ module Bundler alias_method :name, :to_s def specs - @specs ||= begin - # remote_specs usually generates a way larger Index than the other - # sources, and large_idx.use small_idx is way faster than - # small_idx.use large_idx. - idx = @allow_remote ? remote_specs.dup : Index.new - idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote - idx.use(installed_specs, :override_dupes) - idx - end + # remote_specs usually generates a way larger Index than the other + # sources, and large_idx.use small_idx is way faster than + # small_idx.use large_idx. + @specs ||= @allow_remote ? remote_specs.dup : Index.new end def install(spec) |