Commit 01b2fa5b authored by Samuel E. Giddins's avatar Samuel E. Giddins

[LazySpecification] Warn when there are multiple sources per version in #all_specifications

Addresses #3 of https://github.com/CocoaPods/CocoaPods/pull/2637#issuecomment-58584402
parent 8a113caa
module Pod module Pod
class Specification::Set class Specification
class Set
class LazySpecification < BasicObject class LazySpecification < BasicObject
attr_reader :name, :version, :source attr_reader :name, :version, :source
...@@ -33,9 +34,22 @@ module Pod ...@@ -33,9 +34,22 @@ module Pod
end end
def all_specifications def all_specifications
@all_specifications ||= versions_by_source.map do |source, versions| @all_specifications ||= begin
versions_by_source.reduce({}) do |sources_by_version, (source, versions)|
versions.each { |v| (sources_by_version[v] ||= []) << source }
sources_by_version
end.select { |_version, sources| sources.count > 1 }.each do |version, sources|
UI.warn "Found multiple specifications for `#{name} (#{version})`:\n" +
sources.
map { |s| s.specification_path(name, version) }.
map { |v| "- #{v}" }.join("\n")
end
versions_by_source.map do |source, versions|
versions.map { |version| LazySpecification.new(name, version, source) } versions.map { |version| LazySpecification.new(name, version, source) }
end.flatten end.flatten
end end
end end
end
end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment