Checks that the specification contains all required fields, and does a very basic sanity check.
Raises InvalidSpecificationException if the spec does not pass the checks.
# File rubygems/specification_policy.rb, line 41 def validate(strict = false) validate_nil_attributes validate_rubygems_version validate_required_attributes validate_name validate_require_paths @specification.keep_only_files_and_directories validate_non_files validate_self_inclusion_in_files_list validate_specification_version validate_platform validate_array_attributes validate_authors_field validate_metadata validate_licenses validate_permissions validate_lazy_metadata validate_values validate_dependencies if @warnings > 0 if strict error "specification has warnings" else alert_warning help_text end end true end
Implementation for Specification#validate_metadata
# File rubygems/specification_policy.rb, line 92 def validate_metadata metadata = @specification.metadata unless Hash === metadata error 'metadata must be a hash' end metadata.each do |key, value| if !key.kind_of?(String) error "metadata keys must be a String" end if key.size > 128 error "metadata key too large (#{key.size} > 128)" end if !value.kind_of?(String) error "metadata values must be a String" end if value.size > 1024 error "metadata value too large (#{value.size} > 1024)" end if METADATA_LINK_KEYS.include? key if value !~ VALID_URI_PATTERN error "metadata['#{key}'] has invalid link: #{value.inspect}" end end end end
Issues a warning for each file to be packaged which is world-readable.
Implementation for Specification#validate_permissions
# File rubygems/specification_policy.rb, line 190 def validate_permissions return if Gem.win_platform? @specification.files.each do |file| next unless File.file?(file) next if File.stat(file).mode & 0444 == 0444 warning "#{file} is not world-readable" end @specification.executables.each do |name| exec = File.join @specification.bindir, name next unless File.file?(exec) next if File.stat(exec).executable? warning "#{exec} is not executable" end end