Author: toulmean
Date: Fri Sep 17 22:30:04 2010
New Revision: 998357

URL: http://svn.apache.org/viewvc?rev=998357&view=rev
Log:
BUILDR-403: Buildr::Util::Gems.install does not find gems on remote sources

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/core/util.rb
    buildr/trunk/spec/core/application_spec.rb

Modified: buildr/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=998357&r1=998356&r2=998357&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Fri Sep 17 22:30:04 2010
@@ -22,6 +22,7 @@
 * Fixed:  BUILDR-317 ecj compiler
 * Fixed:  BUILDR-326 follow up: binary safe untarring on Windows (Sam Hendley)
 * Fixed:  BUILDR-342 The jruby gem installer invokes the removed 
Gem.manage_gems function (Rhett Sutphin)
+* Fixed:  BUILDR-403 Buildr::Util::Gems.install does not find gems on remote 
sources
 * Fixed:  BUILDR-436 release task should only replace "-SNAPSHOT" (spec from 
Jean-Philippe Caruana)
 * Fixed:  BUILDR-438 Release Task: customizable version numbers (Alexis Midon)
 * Fixed:  BUILDR-464 Improve the versioning of Buildr (Rhett Sutphin)
@@ -40,6 +41,7 @@
           e.g. (Java.java.lang.String cached as Java::Lang::String) 
           can shadow Ruby modules
 * Fixed:  BUILDR-501 Fix buildr label when listing tasks (Peter Donald)
+* Fixed:  BUILDR-503 Include with as includes directories as files when the 
directory has the same name as the path
 * Fixed:  BUILDR-506 Gem packaging does not work under windows (Peter Donald)
 * Fixed:  BUILDR-508 Remove unnecessary use of Java.classpath in OpenJPA
           extension (Peter Donald)

Modified: buildr/trunk/lib/buildr/core/util.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/util.rb?rev=998357&r1=998356&r2=998357&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/util.rb (original)
+++ buildr/trunk/lib/buildr/core/util.rb Fri Sep 17 22:30:04 2010
@@ -142,8 +142,8 @@ module Buildr
       # is not running interactively (on a tty)
       def install(*dependencies)
         raise ArgumentError, "Expected at least one argument" if 
dependencies.empty?
-        remote = dependencies.map { |dep| 
Gem::SourceInfoCache.search(dep).last || dep }
-        not_found_deps, to_install = remote.partition { |gem| 
gem.is_a?(Gem::Dependency) }
+        remote = dependencies.map{ |dep| Gem.source_index.search(dep).last || 
Gem::SpecFetcher.fetcher.fetch( dep, true ).map{ |spec, source| spec }.last } 
+        not_found_deps, to_install = remote.partition { |gem| 
gem.is_a?(Gem::Dependency) || gem.nil? }
         fail Gem::LoadError, "Build requires the gems #{not_found_deps.join(', 
')}, which cannot be found in local or remote repository." unless 
not_found_deps.empty?
         uses = "This build requires the gems 
#{to_install.map(&:full_name).join(', ')}:"
         fail Gem::LoadError, "#{uses} to install, run Buildr interactively." 
unless $stdout.isatty

Modified: buildr/trunk/spec/core/application_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/core/application_spec.rb?rev=998357&r1=998356&r2=998357&view=diff
==============================================================================
--- buildr/trunk/spec/core/application_spec.rb (original)
+++ buildr/trunk/spec/core/application_spec.rb Fri Sep 17 22:30:04 2010
@@ -164,34 +164,34 @@ describe Buildr::Application do
 
     it 'should fail if required gem not found in remote repository' do
       
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo',
 '>=1.1')])
-      Gem::SourceInfoCache.should_receive(:search).and_return([])
+      Gem.source_index.should_receive(:search).and_return([])
       lambda { Buildr.application.load_gems }.should raise_error(LoadError, 
/cannot be found/i)
     end
 
     it 'should fail if need to install gem and not running in interactive 
mode' do
       
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo',
 '>=1.1')])
-      Gem::SourceInfoCache.should_receive(:search).and_return([...@spec])
+      Gem.source_index.should_receive(:search).and_return([...@spec])
       $stdout.should_receive(:isatty).and_return(false)
       lambda { Buildr.application.load_gems }.should raise_error(LoadError, 
/this build requires the gems/i)
     end
 
     it 'should ask permission before installing required gems' do
       
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo',
 '>=1.1')])
-      Gem::SourceInfoCache.should_receive(:search).and_return([...@spec])
+      Gem.source_index.should_receive(:search).and_return([...@spec])
       $terminal.should_receive(:agree).with(/install/, true)
       lambda { Buildr.application.load_gems }.should raise_error
     end
 
     it 'should fail if permission not granted to install gem' do
       
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo',
 '>=1.1')])
-      Gem::SourceInfoCache.should_receive(:search).and_return([...@spec])
+      Gem.source_index.should_receive(:search).and_return([...@spec])
       $terminal.should_receive(:agree).and_return(false)
       lambda { Buildr.application.load_gems }.should raise_error(LoadError, 
/cannot build without/i)
     end
 
     it 'should install gem if permission granted' do
       
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo',
 '>=1.1')])
-      Gem::SourceInfoCache.should_receive(:search).and_return([...@spec])
+      Gem.source_index.should_receive(:search).and_return([...@spec])
       $terminal.should_receive(:agree).and_return(true)
       Util.should_receive(:ruby) do |*args|
         args.should include('install', 'foo', '-v', '1.2')
@@ -202,7 +202,7 @@ describe Buildr::Application do
 
     it 'should reload gem cache after installing required gems' do
       
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo',
 '>=1.1')])
-      Gem::SourceInfoCache.should_receive(:search).and_return([...@spec])
+      Gem.source_index.should_receive(:search).and_return([...@spec])
       $terminal.should_receive(:agree).and_return(true)
       Util.should_receive(:ruby)
       
Gem.source_index.should_receive(:load_gems_in).with(Gem::SourceIndex.installed_spec_directories)
@@ -218,7 +218,7 @@ describe Buildr::Application do
 
     it 'should load newly installed gems' do
       
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo',
 '>=1.1')])
-      Gem::SourceInfoCache.should_receive(:search).and_return([...@spec])
+      Gem.source_index.should_receive(:search).and_return([...@spec])
       $terminal.should_receive(:agree).and_return(true)
       Util.should_receive(:ruby)
       Buildr.application.should_receive(:gem).with('foo', @spec.version.to_s)
@@ -227,25 +227,26 @@ describe Buildr::Application do
 
     it 'should default to >=0 version requirement if not specified' do
       write 'build.yaml', 'gems: foo'
-      
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', 
'>=0')).and_return([])
+      $terminal.should_receive(:agree).and_return(true)
+      Gem.source_index.should_receive(:search).with(Gem::Dependency.new('foo', 
'>=0')).and_return([])
       lambda { Buildr.application.load_gems }.should raise_error
     end
 
     it 'should parse exact version requirement' do
       write 'build.yaml', 'gems: foo 2.5'
-      
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', 
'=2.5')).and_return([])
+      Gem.source_index.should_receive(:search).with(Gem::Dependency.new('foo', 
'=2.5')).and_return([])
       lambda { Buildr.application.load_gems }.should raise_error
     end
 
     it 'should parse range version requirement' do
       write 'build.yaml', 'gems: foo ~>2.3'
-      
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', 
'~>2.3')).and_return([])
+     Gem.source_index.should_receive(:search).with(Gem::Dependency.new('foo', 
'~>2.3')).and_return([])
       lambda { Buildr.application.load_gems }.should raise_error
     end
 
     it 'should parse multiple version requirements' do
       write 'build.yaml', 'gems: foo >=2.0 !=2.1'
-      
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', 
['>=2.0', '!=2.1'])).and_return([])
+      Gem.source_index.should_receive(:search).with(Gem::Dependency.new('foo', 
['>=2.0', '!=2.1'])).and_return([])
       lambda { Buildr.application.load_gems }.should raise_error
     end
   end


Reply via email to