class Gem::Resolver::Conflict
内部用于指示依赖关系与将要激活的规范发生冲突。
属性
activated[R]
在冲突发生前被激活的规范
dependency[R]
与激活的 gem 冲突的依赖关系。
公共类方法
new(dependency, activated, failed_dep=dependency) 点击以切换源代码
当 dependency
与已 activated
的规范冲突时,创建一个新的解析器冲突。
# File rubygems/resolver/conflict.rb, line 24 def initialize(dependency, activated, failed_dep=dependency) @dependency = dependency @activated = activated @failed_dep = failed_dep end
公共实例方法
conflicting_dependencies() 点击以切换源代码
返回发生冲突的 2 个依赖对象
# File rubygems/resolver/conflict.rb, line 47 def conflicting_dependencies [@failed_dep.dependency, @activated.request.dependency] end
explain() 点击以切换源代码
对冲突的字符串解释。
# File rubygems/resolver/conflict.rb, line 40 def explain "<Conflict wanted: #{@failed_dep}, had: #{activated.spec.full_name}>" end
explanation() 点击以切换源代码
异常用于打印有用消息的冲突解释
# File rubygems/resolver/conflict.rb, line 54 def explanation activated = @activated.spec.full_name dependency = @failed_dep.dependency requirement = dependency.requirement alternates = dependency.matching_specs.map(&:full_name) unless alternates.empty? matching = <<-MATCHING.chomp Gems matching %s: %s MATCHING matching = format(matching, dependency, alternates.join(", ")) end explanation = <<-EXPLANATION Activated %s which does not match conflicting dependency (%s) Conflicting dependency chains: %s versus: %s %s EXPLANATION format(explanation, activated, requirement, request_path(@activated).reverse.join(", depends on\n "), request_path(@failed_dep).reverse.join(", depends on\n "), matching) end
for_spec?(spec) 点击以切换源代码
如果冲突依赖的名称与 spec
匹配,则返回 true。
# File rubygems/resolver/conflict.rb, line 88 def for_spec?(spec) @dependency.name == spec.name end
request_path(current) 点击以切换源代码
从 current
列表激活的路径。
# File rubygems/resolver/conflict.rb, line 116 def request_path(current) path = [] while current do case current when Gem::Resolver::ActivationRequest then path << "#{current.request.dependency}, #{current.spec.version} activated" current = current.parent when Gem::Resolver::DependencyRequest then path << current.dependency.to_s current = current.requester else raise Gem::Exception, "[BUG] unknown request class #{current.class}" end end path = ["user request (gem command or Gemfile)"] if path.empty? path end
requester() 点击以切换源代码
返回列出依赖关系的规范
# File rubygems/resolver/conflict.rb, line 143 def requester @failed_dep.requester end