summaryrefslogtreecommitdiff
path: root/lib/rubygems/dependency_installer.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-22 02:52:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-22 02:52:35 +0000
commitb551e8c8b36766651be4e782e09e3b02e7d14a10 (patch)
treee164a1ef908bd4451568abf05b688f1593915b81 /lib/rubygems/dependency_installer.rb
parent65544f575b25b18dc27f9364f973556ddb48538f (diff)
* lib/rubygems: update to 1.3.6.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/dependency_installer.rb')
-rw-r--r--lib/rubygems/dependency_installer.rb38
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index beea212818..9d9aaba400 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -38,7 +38,7 @@ class Gem::DependencyInstaller
# :format_executable:: See Gem::Installer#initialize.
# :ignore_dependencies:: Don't install any dependencies.
# :install_dir:: See Gem::Installer#install.
- # :prerelease:: Allow prerelease versions
+ # :prerelease:: Allow prerelease versions. See #install.
# :security_policy:: See Gem::Installer::new and Gem::Security.
# :user_install:: See Gem::Installer.new
# :wrappers:: See Gem::Installer::new
@@ -89,14 +89,18 @@ class Gem::DependencyInstaller
if @domain == :both or @domain == :remote then
begin
- requirements = dep.version_requirements.requirements.map do |req, ver|
+ requirements = dep.requirement.requirements.map do |req, ver|
req
end
- all = !@prerelease && (requirements.length > 1 ||
+ all = !dep.prerelease? &&
+ # we only need latest if there's one requirement and it is
+ # guaranteed to match the newest specs
+ (requirements.length > 1 or
(requirements.first != ">=" and requirements.first != ">"))
- found = Gem::SpecFetcher.fetcher.fetch dep, all, true, @prerelease
+ found = Gem::SpecFetcher.fetcher.fetch dep, all, true, dep.prerelease?
+
gems_and_sources.push(*found)
rescue Gem::RemoteFetcher::FetchError => e
@@ -120,7 +124,7 @@ class Gem::DependencyInstaller
def gather_dependencies
specs = @specs_and_sources.map { |spec,_| spec }
- dependency_list = Gem::DependencyList.new
+ dependency_list = Gem::DependencyList.new @development
dependency_list.add(*specs)
unless @ignore_dependencies then
@@ -143,7 +147,7 @@ class Gem::DependencyInstaller
@source_index.any? do |_, installed_spec|
dep.name == installed_spec.name and
- dep.version_requirements.satisfied_by? installed_spec.version
+ dep.requirement.satisfied_by? installed_spec.version
end
end
@@ -164,7 +168,9 @@ class Gem::DependencyInstaller
# +version+. Returns an Array of specs and sources required for
# installation of the gem.
- def find_spec_by_name_and_version gem_name, version = Gem::Requirement.default
+ def find_spec_by_name_and_version(gem_name,
+ version = Gem::Requirement.default,
+ prerelease = false)
spec_and_source = nil
glob = if File::ALT_SEPARATOR then
@@ -189,6 +195,7 @@ class Gem::DependencyInstaller
if spec_and_source.nil? 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|
@@ -205,13 +212,24 @@ class Gem::DependencyInstaller
end
##
- # Installs the gem and all its dependencies. Returns an Array of installed
- # gems specifications.
+ # Installs the gem +dep_or_name+ and all its dependencies. Returns an Array
+ # of installed gem specifications.
+ #
+ # If the +:prerelease+ option is set and there is a prerelease for
+ # +dep_or_name+ the prerelease version will be installed.
+ #
+ # Unless explicitly specified as a prerelease dependency, prerelease gems
+ # that +dep_or_name+ depend on will not be installed.
+ #
+ # If c-1.a depends on b-1 and a-1.a and there is a gem b-1.a available then
+ # c-1.a, b-1 and a-1.a will be installed. b-1.a will need to be installed
+ # separately.
def install dep_or_name, version = Gem::Requirement.default
if String === dep_or_name then
- find_spec_by_name_and_version dep_or_name, version
+ find_spec_by_name_and_version dep_or_name, version, @prerelease
else
+ dep_or_name.prerelease = @prerelease
@specs_and_sources = [find_gems_with_sources(dep_or_name).last]
end