lib/rubygems/dependency_installer.rb in rubygems-update-1.3.5 vs lib/rubygems/dependency_installer.rb in rubygems-update-1.3.6
- old
+ new
@@ -36,11 +36,11 @@
# :env_shebang:: See Gem::Installer::new.
# :force:: See Gem::Installer#install.
# :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
def initialize(options = {})
@@ -87,18 +87,22 @@
end
end
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
if Gem.configuration.really_verbose then
say "Error fetching remote data:\t\t#{e.message}"
@@ -118,11 +122,11 @@
# remote sources unless the ignore_dependencies was given.
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
to_do = specs.dup
seen = {}
@@ -141,11 +145,11 @@
results.reject! do |dep_spec,|
to_do.push dep_spec
@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
results.each do |dep_spec, source_uri|
next if seen[dep_spec.name]
@@ -162,11 +166,13 @@
##
# Finds a spec and the source_uri it came from for gem +gem_name+ and
# +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
gem_name.gsub File::ALT_SEPARATOR, File::SEPARATOR
else
@@ -187,10 +193,11 @@
end
end
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|
Gem::Platform.match spec.platform
}
@@ -203,16 +210,27 @@
@specs_and_sources = [spec_and_source]
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
@installed_gems = []