[Rubygems-developers] [ rubygems-Bugs-25677 ] Gem::Specification#validate fails if homepage is unspecified

noreply at rubyforge.org noreply at rubyforge.org
Thu Apr 30 19:00:18 EDT 2009


Bugs item #25677, was opened at 2009-04-25 01:09
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=25677&group_id=126

Category: other
Group: v1.3.x
Status: Open
Resolution: None
Priority: 3
Submitted By: Mike Burrows (asplake)
Assigned to: Nobody (None)
Summary: Gem::Specification#validate fails if homepage is unspecified

Initial Comment:
rubygems/specification.rb:886:
    unless homepage.empty? or homepage =~ /\A[a-z][a-z\d+.-]*:/i then

The above line fails with
  undefined method `empty?' for nil:NilClass
if homepage is nil, and the helpful "no #{attribute} specified" warning a few lines later is never reached.

Perhaps someone assumed that everyone has #empty? defined on NilClass?  I worked around this problem (and identified my missing homepage setting) by doing just that in my Rakefile.

Thank you for an otherwise wonderful thing!
Mike


RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.2
  - RUBY VERSION: 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-9
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/asplake/.gem/ruby/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/


----------------------------------------------------------------------

>Comment By: Daniel Berger (djberg96)
Date: 2009-04-30 16:00

Message:
Proposed change:

--- specification.rb    2009-04-30 16:48:09.000000000 -0600
+++ specification.new   2009-04-30 16:47:56.000000000 -0600
@@ -883,9 +883,13 @@
             '"FIXME" or "TODO" is not a summary'
     end
 
-    unless homepage.empty? or homepage =~ /\A[a-z][a-z\d+.-]*:/i then
-      raise Gem::InvalidSpecificationException,
-            "\#{homepage}\ is not a URI"
+    if homepage
+      begin
+        URI.parse(homepage)
+      rescue URI::InvalidURIError
+        raise Gem::InvalidSpecificationException,
+          "#{homepage} is not a valid URI"
+      end
     end
 
     # Warnings

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=25677&group_id=126


More information about the Rubygems-developers mailing list