Class: Pod::Specification::Set

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/resolver/lazy_specification.rb

Defined Under Namespace

Classes: External, LazySpecification, SpecWithSource

Instance Method Summary collapse

Instance Method Details

#all_specifications(warn_for_multiple_pod_sources) ⇒ Object

returns the highest versioned spec last



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cocoapods/resolver/lazy_specification.rb', line 51

def all_specifications(warn_for_multiple_pod_sources)
  @all_specifications ||= begin
    sources_by_version = {}
    versions_by_source.each do |source, versions|
      versions.each { |v| (sources_by_version[v] ||= []) << source }
    end

    if warn_for_multiple_pod_sources
      duplicate_versions = sources_by_version.select { |_version, sources| sources.count > 1 }

      duplicate_versions.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
    end

    # sort versions from high to low
    sources_by_version.sort_by(&:first).flat_map do |version, sources|
      # within each version, we want the prefered (first-specified) source
      # to be the _last_ one
      sources.reverse_each.map { |source| LazySpecification.new(name, version, source) }
    end
  end
end