summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--lib/rubygems/commands/install_command.rb32
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb26
3 files changed, 60 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 76f8ead8d0..c3c635b426 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Dec 23 16:13:10 2013 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rubygems/commands/install_command.rb: Restore gem install
+ --ignore-dependencies for remote gems
+ * test/rubygems/test_gem_commands_install_command.rb: Test for the
+ above.
+
Mon Dec 23 16:12:24 2013 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* array.c: Have to_h raise on elements that are not key-value pairs
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 56ff8fc564..4485eb12e8 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -69,7 +69,7 @@ class Gem::Commands::InstallCommand < Gem::Command
o[:explain] = v
end
- @installed_specs = nil
+ @installed_specs = []
end
def arguments # :nodoc:
@@ -200,10 +200,8 @@ to write the specification by hand. For example:
req = Gem::Requirement.create(version)
- if options[:ignore_dependencies]
- inst = Gem::Installer.new name, options
- inst.install
- @installed_specs.push(inst.spec)
+ if options[:ignore_dependencies] then
+ install_gem_without_dependencies name, req
else
inst = Gem::DependencyInstaller.new options
@@ -227,6 +225,30 @@ to write the specification by hand. For example:
end
end
+ def install_gem_without_dependencies name, req # :nodoc:
+ gem = nil
+
+ if remote? then
+ dependency = Gem::Dependency.new name, req
+ dependency.prerelease = options[:prerelease]
+
+ fetcher = Gem::RemoteFetcher.fetcher
+ gem = fetcher.download_to_cache dependency
+ end
+
+ if local? and not gem then
+ source = Gem::Source::Local.new
+ spec = source.find_gem name, req
+
+ gem = source.download spec
+ end
+
+ inst = Gem::Installer.new gem, options
+ inst.install
+
+ @installed_specs.push(inst.spec)
+ end
+
def install_gems # :nodoc:
exit_code = 0
diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb
index 32f6fc4237..00bbf7bae7 100644
--- a/test/rubygems/test_gem_commands_install_command.rb
+++ b/test/rubygems/test_gem_commands_install_command.rb
@@ -533,6 +533,32 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_match "1 gem installed", @ui.output
end
+ def test_install_gem_ignore_dependencies_both
+ spec = quick_spec 'a', 2
+
+ util_build_gem spec
+
+ FileUtils.mv spec.cache_file, @tempdir
+
+ @cmd.options[:ignore_dependencies] = true
+
+ @cmd.install_gem 'a', '>= 0'
+
+ assert_equal %w[a-2], @cmd.installed_specs.map { |s| s.full_name }
+ end
+
+ def test_install_gem_ignore_dependencies_remote
+ spec_fetcher do |fetcher|
+ fetcher.gem 'a', 2
+ end
+
+ @cmd.options[:ignore_dependencies] = true
+
+ @cmd.install_gem 'a', '>= 0'
+
+ assert_equal %w[a-2], @cmd.installed_specs.map { |spec| spec.full_name }
+ end
+
def test_parses_requirement_from_gemname
spec_fetcher do |fetcher|
fetcher.gem 'a', 2