модуль Bundler::Molinillo::SpecificationProvider
Предоставляет информацию о спецификациях и зависимостях решателю, позволяя классу {Resolver} оставаться универсальным, при этом обеспечивая мощь и гибкость.
Этот модуль содержит методы, которые должны реализовывать пользователи Bundler::Molinillo, используя знания о собственных моделях классов.
Открытые методы экземпляров
# File lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 97 def allow_missing?(dependency) false end
Возвращает значение, указывающее, можно ли безопасно игнорировать данную зависимость, у которой нет возможных соответствующих спецификаций.
@param [Object] dependency @return [Boolean] можно ли безопасно пропустить эту зависимость.
# File lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 31 def dependencies_for(specification) [] end
Возвращает зависимости спецификации.
@note Этот метод должен быть «чистым», т.е. возвращаемое значение должно зависеть
only on the `specification` parameter.
@param [Object] specification @return [Array<Object>] зависимости, необходимые для данной
`specification`.
# File lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 54 def name_for(dependency) dependency.to_s end
Возвращает имя для данной зависимости.
@note Этот метод должен быть «чистым», т.е. возвращаемое значение должно зависеть
only on the `dependency` parameter.
@param [Object] dependency @return [String] имя для данной зависимости.
# File lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 60 def name_for_explicit_dependency_source 'user-specified dependency' end
@return [String] имя источника явных зависимостей, т.е.
those passed to {Resolver#resolve} directly. # File lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 66 def name_for_locking_dependency_source 'Lockfile' end
@return [String] имя источника «заблокированных» зависимостей, т.е.
those passed to {Resolver#resolve} directly as the `base` # File lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 44 def requirement_satisfied_by?(requirement, activated, spec) true end
Определяет, удовлетворяет ли заданный `requirement` заданный `spec`, в контексте текущего графа зависимостей `activated`.
@param [Object] requirement @param [DependencyGraph] activated текущий граф зависимостей в
resolution process.
@param [Object] spec @return [Boolean] удовлетворяет ли `requirement` `spec` в
context of the current `activated` dependency graph.
# File lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 20 def search_for(dependency) [] end
Поиск спецификаций, соответствующих данной зависимости. Спецификации в возвращаемом массиве будут рассмотрены в обратном порядке, поэтому последней должна быть самая последняя версия. @note Этот метод должен быть «чистым», т.е. возвращаемое значение должно зависеть
only on the `dependency` parameter.
@param [Object] dependency @return [Array<Object>] спецификации, удовлетворяющие заданной
`dependency`.
# File lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb, line 82
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 Сортирует зависимости таким образом, что сначала идут те, которые проще всего разрешить. Легче всего разрешить (как правило) определяется:
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`.
Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.