diff options
Diffstat (limited to 'lib/rubygems/specification.rb')
-rw-r--r-- | lib/rubygems/specification.rb | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index eb89c4c97b..b73c563e2e 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -383,6 +383,8 @@ class Gem::Specification < Gem::BasicSpecification attr_reader :description ## + # :category: Recommended gemspec attributes + # # A contact email address (or addresses) for this gem # # Usage: @@ -393,11 +395,13 @@ class Gem::Specification < Gem::BasicSpecification attr_accessor :email ## + # :category: Recommended gemspec attributes + # # The URL of this gem's home page # # Usage: # - # spec.homepage = 'http://rake.rubyforge.org' + # spec.homepage = 'https://github.com/ruby/rake' attr_accessor :homepage @@ -1322,6 +1326,50 @@ class Gem::Specification < Gem::BasicSpecification end ## + # Abbreviate the spec for downloading. Abbreviated specs are only used for + # searching, downloading and related activities and do not need deployment + # specific information (e.g. list of files). So we abbreviate the spec, + # making it much smaller for quicker downloads. + + def abbreviate + self.files = [] + self.test_files = [] + self.rdoc_options = [] + self.extra_rdoc_files = [] + self.cert_chain = [] + end + + ## + # Sanitize the descriptive fields in the spec. Sometimes non-ASCII + # characters will garble the site index. Non-ASCII characters will + # be replaced by their XML entity equivalent. + + def sanitize + self.summary = sanitize_string(summary) + self.description = sanitize_string(description) + self.post_install_message = sanitize_string(post_install_message) + self.authors = authors.collect { |a| sanitize_string(a) } + end + + ## + # Sanitize a single string. + + def sanitize_string(string) + return string unless string + + # HACK the #to_s is in here because RSpec has an Array of Arrays of + # Strings for authors. Need a way to disallow bad values on gemspec + # generation. (Probably won't happen.) + string = string.to_s + + begin + Builder::XChar.encode string + rescue NameError, NoMethodError + string.to_xs + end + end + + ## # Returns an array with bindir attached to each executable in the # +executables+ list @@ -2609,7 +2657,7 @@ http://opensource.org/licenses/alphabetical # Warnings - %w[author description email homepage summary].each do |attribute| + %w[author email homepage summary].each do |attribute| value = self.send attribute warning "no #{attribute} specified" if value.nil? or value.empty? end |