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

ruby-changes:27087

From: drbrain <ko1@a...>
Date: Fri, 8 Feb 2013 07:55:12 +0900 (JST)
Subject: [ruby-changes:27087] drbrain:r39139 (trunk): * lib/rubygems/dependency_installer.rb: Only install local gems if

drbrain	2013-02-08 07:17:08 +0900 (Fri, 08 Feb 2013)

  New Revision: 39139

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

  Log:
    * lib/rubygems/dependency_installer.rb:  Only install local gems if
      they end in '.gem'.  Fixes github rubygems issue #407.
    * test/rubygems/test_gem_dependency_installer.rb:  Test for the above.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/dependency_installer.rb
    trunk/test/rubygems/test_gem_dependency_installer.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39138)
+++ ChangeLog	(revision 39139)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Feb  8 07:17:00 2013  Eric Hodel  <drbrain@s...>
+
+	* lib/rubygems/dependency_installer.rb:  Only install local gems if
+	  they end in '.gem'.  Fixes github rubygems issue #407.
+	* test/rubygems/test_gem_dependency_installer.rb:  Test for the above.
+
 Fri Feb  8 00:02:48 2013  Tanaka Akira  <akr@f...>
 
 	* process.c (obj2gid): use getgrnam_r() only if getgrnam_r() and
Index: lib/rubygems/dependency_installer.rb
===================================================================
--- lib/rubygems/dependency_installer.rb	(revision 39138)
+++ lib/rubygems/dependency_installer.rb	(revision 39139)
@@ -260,7 +260,7 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L260
     set = Gem::AvailableSet.new
 
     if consider_local?
-      if File.file? gem_name then
+      if gem_name =~ /\.gem$/ and File.file? gem_name then
         src = Gem::Source::SpecificFile.new(gem_name)
         set.add src.spec, src
       else
Index: test/rubygems/test_gem_dependency_installer.rb
===================================================================
--- test/rubygems/test_gem_dependency_installer.rb	(revision 39138)
+++ test/rubygems/test_gem_dependency_installer.rb	(revision 39139)
@@ -794,11 +794,38 @@ class TestGemDependencyInstaller < Gem:: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_dependency_installer.rb#L794
     assert_equal Gem::Source.new(@gem_repo), s.source
   end
 
+  def test_find_spec_by_name_and_version_bad_gem
+    FileUtils.touch 'rdoc.gem'
+
+    inst = Gem::DependencyInstaller.new
+
+    e = assert_raises Gem::Package::FormatError do
+      inst.find_spec_by_name_and_version 'rdoc.gem'
+    end
+
+    full_path = File.join @tempdir, 'rdoc.gem'
+    assert_equal "package metadata is missing in #{full_path}", e.message
+  end
+
   def test_find_spec_by_name_and_version_directory
     Dir.mkdir 'rdoc'
 
     inst = Gem::DependencyInstaller.new
 
+    e = assert_raises Gem::SpecificGemNotFoundException do
+      inst.find_spec_by_name_and_version 'rdoc'
+    end
+
+    assert_equal "Could not find a valid gem 'rdoc' (>= 0) " +
+                 "locally or in a repository",
+                 e.message
+  end
+
+  def test_find_spec_by_name_and_version_file
+    FileUtils.touch 'rdoc'
+
+    inst = Gem::DependencyInstaller.new
+
     e = assert_raises Gem::SpecificGemNotFoundException do
       inst.find_spec_by_name_and_version 'rdoc'
     end

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

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