Methods
- N
- V
Included Modules
Constants
HOMEPAGE_URI_PATTERN | = | /\A[a-z][a-z\d+.-]*:/i |
LAZY | = | '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, "") |
LAZY_PATTERN | = | /\AFI XME|\ATO DO/x |
Attributes
[RW] | packaging | If set to true, run packaging-specific checks, as well. |
Class Public methods
new(specification) Link
Instance Public methods
validate(strict = false) Link
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.
validate_metadata() Link
Implementation for Specification#validate_metadata
# File ruby/lib/rubygems/specification_policy.rb, line 126 def validate_metadata metadata = @specification.metadata unless Hash === metadata error "metadata must be a hash" end metadata.each do |key, value| entry = "metadata['#{key}']" unless key.is_a?(String) error "metadata keys must be a String" end if key.size > 128 error "metadata key is too large (#{key.size} > 128)" end unless value.is_a?(String) error "#{entry} value must be a String" end if value.size > 1024 error "#{entry} value is too large (#{value.size} > 1024)" end next unless METADATA_LINK_KEYS.include? key unless VALID_URI_PATTERN.match?(value) error "#{entry} has invalid link: #{value.inspect}" end end end
validate_optional(strict) Link
# File ruby/lib/rubygems/specification_policy.rb, line 97 def validate_optional(strict) validate_licenses validate_permissions validate_values validate_dependencies validate_required_ruby_version validate_extensions validate_removed_attributes validate_unique_links if @warnings > 0 if strict error "specification has warnings" else alert_warning help_text end end end
validate_permissions() Link
Issues a warning for each file to be packaged which is world-readable.
Implementation for Specification#validate_permissions
# File ruby/lib/rubygems/specification_policy.rb, line 243 def validate_permissions return if Gem.win_platform? @specification.files.each do |file| next unless File.file?(file) next if File.stat(file).mode & 0o444 == 0o444 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
validate_required!() Link
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 ruby/lib/rubygems/specification_policy.rb, line 63 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
validate_required_ruby_version() Link
# File ruby/lib/rubygems/specification_policy.rb, line 232 def validate_required_ruby_version if @specification.required_ruby_version.requirements == [Gem::Requirement::DefaultRequirement] warning "make sure you specify the oldest ruby version constraint (like \">= 3.0\") that you want your gem to support by setting the `required_ruby_version` gemspec attribute" end end