diff options
author | Carl Lerche <carllerche@mac.com> | 2010-03-10 00:24:17 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-03-10 00:24:17 -0800 |
commit | 3e360694359c38fa343166a0e93db8aabfad9834 (patch) | |
tree | 8d9cfda1f224f88771d0421c230c20ee47d11486 /lib/bundler/installer.rb | |
parent | 028f2ecca4d9d71e83be4775e10389c888c188c1 (diff) | |
download | bundler-3e360694359c38fa343166a0e93db8aabfad9834.tar.gz |
Refactor indexes
Diffstat (limited to 'lib/bundler/installer.rb')
-rw-r--r-- | lib/bundler/installer.rb | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 2638dadc..516ea025 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -91,51 +91,29 @@ module Bundler end def index - @index ||= begin - index = Index.new + @index ||= Index.build do |idx| + rubygems, other = sources.partition { |s| Source::Rubygems === s } - rg_sources = sources.select { |s| s.is_a?(Source::Rubygems) } - other_sources = sources.select { |s| !s.is_a?(Source::Rubygems) } - - other_sources.each do |source| - i = source.specs + other.each do |source| Bundler.ui.debug "Source: Processing index" - index = i.merge(index) + idx.use source.specs end - index = Index.from_installed_gems.merge(index) - index = Index.from_cached_specs("#{Bundler.bundle_path}/cache").merge(index) - - if File.directory?("#{root}/vendor/cache") - index = cache_source.specs.merge(index) - end + idx.use Index.installed_gems + idx.use Index.cached_gems - rg_sources.each do |source| - i = source.specs + rubygems.each do |source| Bundler.ui.debug "Source: Processing index" - index = i.merge(index) + idx.use source.specs end - - index end end def local_index - @local_index ||= begin - index = Index.new - - sources.each do |source| - next unless source.respond_to?(:local_specs) - index = source.local_specs.merge(index) - end - - index = Index.from_installed_gems.merge(index) - - if File.directory?("#{root}/vendor/cache") - index = cache_source.specs.merge(index).freeze - end - - Index.from_cached_specs("#{Bundler.bundle_path}/cache").merge(index) + @local_index ||= Index.build do |idx| + idx.use runtime_gems + idx.use Index.application_cached_gems # vendor/cache + idx.use Index.system_cached_gems # $GEM_HOME/cache end end |