模块 Gem::Molinillo::SpecificationProvider
为解析器提供关于规范和依赖关系的信息,允许 {Resolver} 类保持通用性,同时仍提供强大的功能和灵活性。
此模块包含 Gem::Molinillo
的用户必须实现的方法,利用他们自己模型类的知识。
公共实例方法
返回是否可以安全地忽略此依赖项,因为它没有可能的匹配规范。
@param [Object] dependency @return [Boolean] 是否可以安全地跳过此依赖项。
# File rubygems/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 108 def allow_missing?(dependency) false end
确定两个依赖项数组是否相等,从而可以进行分组。
@param [Array<Object>] dependencies @param [Array<Object>] other_dependencies @return [Boolean] `dependencies` 和 `other_dependencies` 是否应该
be considered equal.
# File rubygems/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 55 def dependencies_equal?(dependencies, other_dependencies) dependencies == other_dependencies end
返回 `specification` 的依赖项。@note 此方法应为“纯”方法,即返回值应取决于
only on the `specification` parameter.
@param [Object] specification @return [Array<Object>] 给定规范所需的依赖项
`specification`.
# File rubygems/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 31 def dependencies_for(specification) [] end
返回给定 `dependency` 的名称。@note 此方法应为“纯”方法,即返回值应取决于
only on the `dependency` parameter.
@param [Object] dependency @return [String] 给定 `dependency` 的名称。
# File rubygems/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 65 def name_for(dependency) dependency.to_s end
@return [String] 显式依赖项来源的名称,即
those passed to {Resolver#resolve} directly.
# File rubygems/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 71 def name_for_explicit_dependency_source 'user-specified dependency' end
@return [String] “锁定”依赖项来源的名称,即
those passed to {Resolver#resolve} directly as the `base`
# File rubygems/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 77 def name_for_locking_dependency_source 'Lockfile' end
确定在当前 `activated` 依赖图的上下文中,给定的 `spec` 是否满足给定的 `requirement`。
@param [Object] requirement @param [DependencyGraph] activated 当前依赖图中的
resolution process.
@param [Object] spec @return [Boolean] 在当前依赖图中,`spec` 是否满足 `requirement`
context of the current `activated` dependency graph.
# File rubygems/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 44 def requirement_satisfied_by?(requirement, activated, spec) true end
搜索与给定依赖项匹配的规范。返回数组中的规范将按相反顺序考虑,因此最新版本应放在最后。@note 此方法应为“纯”方法,即返回值应取决于
only on the `dependency` parameter.
@param [Object] dependency @return [Array<Object>] 满足给定要求的规范
`dependency`.
# File rubygems/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 20 def search_for(dependency) [] end
对依赖项进行排序,以便首先处理那些最容易解决的依赖项。最容易解决的依赖项(通常)由以下因素定义
1) Is this dependency already activated? 2) How relaxed are the requirements? 3) Are there any conflicts for this dependency? 4) How many possibilities are there to satisfy this dependency?
@param [Array<Object>] dependencies @param [DependencyGraph] activated 当前依赖图中的
resolution process.
@param [{String => Array<Conflict>}] conflicts @return [Array<Object>] `dependencies` 的排序副本。
# File rubygems/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 93 def sort_dependencies(dependencies, activated, conflicts) dependencies.sort_by do |dependency| name = name_for(dependency) [ activated.vertex_named(name).payload ? 0 : 1, conflicts[name] ? 0 : 1, ] end end