diff options
Diffstat (limited to 'lib/rubygems/dependency_installer.rb')
-rw-r--r-- | lib/rubygems/dependency_installer.rb | 78 |
1 files changed, 37 insertions, 41 deletions
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb index 5afb1bfa0d..29e8b21643 100644 --- a/lib/rubygems/dependency_installer.rb +++ b/lib/rubygems/dependency_installer.rb @@ -21,14 +21,14 @@ class Gem::DependencyInstaller attr_reader :installed_gems DEFAULT_OPTIONS = { - :env_shebang => false, - :domain => :both, # HACK dup - :force => false, - :format_executable => false, # HACK dup + :env_shebang => false, + :domain => :both, # HACK dup + :force => false, + :format_executable => false, # HACK dup :ignore_dependencies => false, - :prerelease => false, - :security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low? - :wrappers => true, + :prerelease => false, + :security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low? + :wrappers => true, } ## @@ -51,25 +51,26 @@ class Gem::DependencyInstaller def initialize(options = {}) if options[:install_dir] then - spec_dir = options[:install_dir], 'specifications' - @source_index = Gem::SourceIndex.from_gems_in spec_dir - else - @source_index = Gem.source_index + @gem_home = options[:install_dir] + + Gem::Specification.dirs = @gem_home + Gem.ensure_gem_subdirectories @gem_home + options[:install_dir] = @gem_home # FIX: because we suck and reuse below end options = DEFAULT_OPTIONS.merge options - @bin_dir = options[:bin_dir] - @development = options[:development] - @domain = options[:domain] - @env_shebang = options[:env_shebang] - @force = options[:force] - @format_executable = options[:format_executable] + @bin_dir = options[:bin_dir] + @development = options[:development] + @domain = options[:domain] + @env_shebang = options[:env_shebang] + @force = options[:force] + @format_executable = options[:format_executable] @ignore_dependencies = options[:ignore_dependencies] - @prerelease = options[:prerelease] - @security_policy = options[:security_policy] - @user_install = options[:user_install] - @wrappers = options[:wrappers] + @prerelease = options[:prerelease] + @security_policy = options[:security_policy] + @user_install = options[:user_install] + @wrappers = options[:wrappers] @installed_gems = [] @@ -101,6 +102,7 @@ class Gem::DependencyInstaller if @domain == :both or @domain == :remote then begin + # REFACTOR: all = dep.requirement.needs_all? requirements = dep.requirement.requirements.map do |req, ver| req end @@ -146,8 +148,8 @@ class Gem::DependencyInstaller add_found_dependencies to_do, dependency_list unless @ignore_dependencies dependency_list.specs.reject! { |spec| - ! keep_names.include? spec.full_name and - @source_index.any? { |n,_| n == spec.full_name } + not keep_names.include?(spec.full_name) and + Gem::Specification.include?(spec) } unless dependency_list.ok? or @ignore_dependencies or @force then @@ -181,7 +183,7 @@ class Gem::DependencyInstaller to_do.push dep_spec # already locally installed - @source_index.any? do |_, installed_spec| + Gem::Specification.any? do |installed_spec| dep.name == installed_spec.name and dep.requirement.satisfied_by? installed_spec.version end @@ -216,23 +218,20 @@ class Gem::DependencyInstaller local_gems = Dir["#{glob}*"].sort.reverse - unless local_gems.empty? then - local_gems.each do |gem_file| - next unless gem_file =~ /gem$/ - begin - spec = Gem::Format.from_file_by_path(gem_file).spec - spec_and_source = [spec, gem_file] - break - rescue SystemCallError, Gem::Package::FormatError - end + local_gems.each do |gem_file| + next unless gem_file =~ /gem$/ + begin + spec = Gem::Format.from_file_by_path(gem_file).spec + spec_and_source = [spec, gem_file] + break + rescue SystemCallError, Gem::Package::FormatError end end - if spec_and_source.nil? then + unless spec_and_source then dep = Gem::Dependency.new gem_name, version dep.prerelease = true if prerelease spec_and_sources = find_gems_with_sources(dep).reverse - spec_and_source = spec_and_sources.find { |spec, source| Gem::Platform.match spec.platform } @@ -273,9 +272,9 @@ class Gem::DependencyInstaller gather_dependencies - @gems_to_install.each do |spec| - last = spec == @gems_to_install.last - next if @source_index.any? { |n,_| n == spec.full_name } and not last + last = @gems_to_install.size - 1 + @gems_to_install.each_with_index do |spec, index| + next if Gem::Specification.include?(spec) and index != last # TODO: make this sorta_verbose so other users can benefit from it say "Installing gem #{spec.full_name}" if Gem.configuration.really_verbose @@ -298,7 +297,6 @@ class Gem::DependencyInstaller :ignore_dependencies => @ignore_dependencies, :install_dir => @install_dir, :security_policy => @security_policy, - :source_index => @source_index, :user_install => @user_install, :wrappers => @wrappers @@ -309,6 +307,4 @@ class Gem::DependencyInstaller @installed_gems end - end - |