method
validate_dependencies
ruby latest stable - Class:
Gem::SpecificationPolicy
Method not available on this version
This method is only available on newer versions. The first available version (v2_6_3) is shown here.
validate_dependencies()public
Implementation for Specification#validate_dependencies
# File lib/rubygems/specification_policy.rb, line 123
def validate_dependencies # :nodoc:
# NOTE: see REFACTOR note in Gem::Dependency about types - this might be brittle
seen = Gem::Dependency::TYPES.inject({}) { |types, type| types.merge({ type => {}}) }
error_messages = []
warning_messages = []
dependencies.each do |dep|
if prev = seen[dep.type][dep.name]
error_messages << duplicate dependency on #{dep}, (#{prev.requirement}) use: add_#{dep.type}_dependency '#{dep.name}', '#{dep.requirement}', '#{prev.requirement}'
end
seen[dep.type][dep.name] = dep
prerelease_dep = dep.requirements_list.any? do |req|
Gem::Requirement.new(req).prerelease?
end
warning_messages << "prerelease dependency on #{dep} is not recommended" if
prerelease_dep && !version.prerelease?
open_ended = dep.requirement.requirements.all? do |op, version|
not version.prerelease? and (op == '>' or op == '>=')
end
if open_ended
op, dep_version = dep.requirement.requirements.first
segments = dep_version.segments
base = segments.first 2
recommendation = if (op == '>' || op == '>=') && segments == [0]
" use a bounded requirement, such as '~> x.y'"
else
bugfix = if op == '>'
", '> #{dep_version}'"
elsif op == '>=' and base != segments
", '>= #{dep_version}'"
end
" if #{dep.name} is semantically versioned, use:\n" " add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}"
end
warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n"
end
end
if error_messages.any?
error error_messages.join
end
if warning_messages.any?
warning_messages.each { |warning_message| warning warning_message }
end
end Related methods
- Instance methods
- validate
- validate_dependencies
- validate_metadata
- validate_permissions
- Class methods
- new
- Private methods
-
error -
help_text -
validate_array_attribute -
validate_array_attributes -
validate_attribute_present -
validate_authors_field -
validate_lazy_metadata -
validate_licenses -
validate_name -
validate_nil_attributes -
validate_non_files -
validate_platform -
validate_require_paths -
validate_required_attributes -
validate_rubygems_version -
validate_self_inclusion_in_files_list -
validate_shebang_line_in -
validate_specification_version -
validate_values -
warning