[前][次][番号順一覧][スレッド一覧]

ruby-changes:32254

From: drbrain <ko1@a...>
Date: Sun, 22 Dec 2013 11:06:10 +0900 (JST)
Subject: [ruby-changes:32254] drbrain:r44333 (trunk): * lib/rubygems/commands/install_command.rb: Restore gem install

drbrain	2013-12-22 11:06:02 +0900 (Sun, 22 Dec 2013)

  New Revision: 44333

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44333

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/commands/install_command.rb
    trunk/test/rubygems/test_gem_commands_install_command.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44332)
+++ ChangeLog	(revision 44333)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Dec 22 11:05:53 2013  Eric Hodel  <drbrain@s...>
+
+	* 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.
+
 Sun Dec 22 10:23:40 2013  Eric Hodel  <drbrain@s...>
 
 	* lib/rdoc.rb:  Set RDoc to release version.
Index: lib/rubygems/commands/install_command.rb
===================================================================
--- lib/rubygems/commands/install_command.rb	(revision 44332)
+++ lib/rubygems/commands/install_command.rb	(revision 44333)
@@ -69,7 +69,7 @@ class Gem::Commands::InstallCommand < Ge https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/install_command.rb#L69
       o[:explain] = v
     end
 
-    @installed_specs = nil
+    @installed_specs = []
   end
 
   def arguments # :nodoc:
@@ -200,10 +200,8 @@ to write the specification by hand.  For https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/install_command.rb#L200
 
     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 https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/install_command.rb#L225
     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
 
Index: test/rubygems/test_gem_commands_install_command.rb
===================================================================
--- test/rubygems/test_gem_commands_install_command.rb	(revision 44332)
+++ test/rubygems/test_gem_commands_install_command.rb	(revision 44333)
@@ -533,6 +533,32 @@ ERROR:  Possible alternatives: non_exist https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_install_command.rb#L533
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]