buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r917054 - in /buildr/trunk: lib/buildr/packaging/version_requirement.rb rakelib/setup.rake spec/spec_helpers.rb
Date Sat, 27 Feb 2010 21:54:04 GMT
Author: boisvert
Date: Sat Feb 27 21:54:03 2010
New Revision: 917054

URL: http://svn.apache.org/viewvc?rev=917054&view=rev
Log:
Tweaks and patches for rubygems 1.3.6

Modified:
    buildr/trunk/lib/buildr/packaging/version_requirement.rb
    buildr/trunk/rakelib/setup.rake
    buildr/trunk/spec/spec_helpers.rb

Modified: buildr/trunk/lib/buildr/packaging/version_requirement.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/version_requirement.rb?rev=917054&r1=917053&r2=917054&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/version_requirement.rb (original)
+++ buildr/trunk/lib/buildr/packaging/version_requirement.rb Sat Feb 27 21:54:03 2010
@@ -14,14 +14,34 @@
 # the License.
 
 
+# Rubygems 1.3.6 removed the 'version' accessor so monkey-patch it back to
+# circumvent version validation.  This is needed because Gem::Version doesn't
+# accept version specs with dashes.
+unless Gem::Version.new(0).respond_to?(:version=)
+  class Gem::Version
+    def version=(version)
+      @version = version.to_s
+      @version.strip!
+
+      # re-prime @segments
+      @segments = nil
+      segments
+    end
+  end
+end
+
 module Buildr
-  
+
   #
   # See ArtifactNamespace#need
   class VersionRequirement
-    
+
     CMP_PROCS = Gem::Requirement::OPS.dup
-    CMP_REGEX = Gem::Requirement::OP_RE.dup
+    CMP_REGEX = if defined?(Gem::Requirement::OP_RE)
+      Gem::Requirement::OP_RE
+    else
+      Gem::Requirement::OPS.keys.map { |k| Regexp.quote k }.join "|"
+    end
     CMP_CHARS = CMP_PROCS.keys.join
     BOOL_CHARS = '\|\&\!'
     VER_CHARS = '\w\.\-'
@@ -31,16 +51,16 @@
       def version?(str)
         /^\s*\d[#{VER_CHARS}]*\s*$/ === str
       end
-      
+
       # is +str+ a version requirement?
       def requirement?(str)
         /[#{BOOL_CHARS}#{CMP_CHARS}\(\)]/ === str
       end
-      
+
       # :call-seq:
       #    VersionRequirement.create(" >1 <2 !(1.5) ") -> requirement
       #
-      # parse the +str+ requirement 
+      # parse the +str+ requirement
       def create(str)
         instance_eval normalize(str)
       rescue StandardError => e
@@ -61,7 +81,7 @@
         vreq.negative = !vreq.negative
         vreq
       end
-      
+
       def normalize(str)
         str = str.strip
         if str[/[^\s\(\)#{BOOL_CHARS + VER_CHARS + CMP_CHARS}]/]
@@ -147,7 +167,7 @@
     def &(other)
       operation(:&, other)
     end
-    
+
     # return the parsed expression
     def to_s
       str = requirements.map(&:to_s).join(" " + @op.to_s + " ").to_s
@@ -160,7 +180,7 @@
     protected
     attr_reader :requirements, :op
     def operation(op, other)
-      @op ||= op 
+      @op ||= op
       if negative == other.negative && @op == op && other.requirements.size
== 1
         @requirements << other.requirements.first
         self

Modified: buildr/trunk/rakelib/setup.rake
URL: http://svn.apache.org/viewvc/buildr/trunk/rakelib/setup.rake?rev=917054&r1=917053&r2=917054&view=diff
==============================================================================
--- buildr/trunk/rakelib/setup.rake (original)
+++ buildr/trunk/rakelib/setup.rake Sat Feb 27 21:54:03 2010
@@ -35,7 +35,14 @@
     args = []
     args << 'sudo' << 'env' << "JAVA_HOME=#{ENV['JAVA_HOME']}" if sudo_needed?
and RAKE_SUDO
     args << rb_bin << '-S' << 'gem' << 'install' << name
-    args << '--version' << dep.version_requirements.to_s
+
+    if (spec.respond_to? :requirement)
+      args << '--version' << dep.requirement.to_s
+    else
+      # Dependency.version_requirements deprecated in rubygems 1.3.6
+      args << '--version' << dep.version_requirements.to_s
+    end
+
     args << '--source' << options[:source] if options[:source]
     args << '--source' << 'http://gems.rubyforge.org'
     args << '--install-dir' << ENV['GEM_HOME'] if ENV['GEM_HOME']
@@ -49,6 +56,11 @@
 task :setup do
   missing = spec.dependencies.select { |dep| Gem::SourceIndex.from_installed_gems.search(dep).empty?
}
   missing.each do |dep|
-    install_gem dep.name, :version=>dep.version_requirements
+    if (spec.respond_to? :requirement)
+      install_gem dep.name, :version=>dep.requirement
+    else
+      # Dependency.version_requirements deprecated in rubygems 1.3.6
+      install_gem dep.name, :version=>dep.version_requirements
+    end
   end
 end

Modified: buildr/trunk/spec/spec_helpers.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/spec_helpers.rb?rev=917054&r1=917053&r2=917054&view=diff
==============================================================================
--- buildr/trunk/spec/spec_helpers.rb (original)
+++ buildr/trunk/spec/spec_helpers.rb Sat Feb 27 21:54:03 2010
@@ -22,8 +22,12 @@
 
   # For testing we use the gem requirements specified on the buildr.gemspec
   spec = Gem::Specification.load(File.expand_path('../buildr.gemspec', File.dirname(__FILE__)))
-  spec.dependencies.each { |dep| gem dep.name, dep.version_requirements.to_s }
-
+  if (spec.respond_to? :requirement)
+    spec.dependencies.each { |dep| gem dep.name, dep.requirement.to_s }
+  else
+    # Dependency.version_requirements deprecated in rubygems 1.3.6
+    spec.dependencies.each { |dep| gem dep.name, dep.version_requirements.to_s }
+  end
   # Make sure to load from these paths first, we don't want to load any
   # code from Gem library.
   $LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__)),



Mime
View raw message