Does a sanity check on the specification.
Raises InvalidSpecificationException if the spec does not pass the checks.
It also performs some validations that do not raise but print warning messages instead.
# File rubygems/specification_policy.rb, line 43 def validate(strict = false) validate_required! validate_optional(strict) if packaging || strict true end
Implementation for Specification#validate_metadata
# File rubygems/specification_policy.rb, line 119 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
# File rubygems/specification_policy.rb, line 94 def validate_optional(strict) validate_licenses validate_permissions validate_values validate_dependencies validate_extensions validate_removed_attributes if @warnings > 0 if strict error "specification has warnings" else alert_warning help_text 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 226 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
Does a sanity check on the specification.
Raises InvalidSpecificationException if the spec does not pass the checks.
Only runs checks that are considered necessary for the specification to be functional.
# File rubygems/specification_policy.rb, line 60 def validate_required! 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_length validate_lazy_metadata validate_duplicate_dependencies end