Commit edc4f9f7 authored by Samuel E. Giddins's avatar Samuel E. Giddins

[RuboCop] Yield to the style guide, even though I disagree with it in some cases.

parent a92c46a7
......@@ -234,37 +234,42 @@ module Pod
def generate_version_locking_dependencies
require 'molinillo/dependency_graph'
dependency_graph = Molinillo::DependencyGraph.new
unless update_mode == :all || !lockfile
explicit_dependencies = lockfile.to_hash['DEPENDENCIES'] || []
explicit_dependencies.each do |string|
dependency = Dependency.new(string)
dependency_graph.add_root_vertex(dependency.name, nil)
end
add_child_vertex = lambda do |dependency_string, parents|
dependency = Dependency.from_string(dependency_string)
dependency_graph.add_child_vertex(dependency.name, parents.empty? ? dependency : nil, parents, nil)
dependency
end
add_to_dependency_graph = lambda do |object, parents|
case object
when String
dependency = Dependency.from_string(object)
dependency_graph.add_child_vertex(dependency.name, parents.empty? ? dependency : nil, parents, nil)
add_child_vertex.call(object, parents)
when Hash
object.each do |key, value|
dependency = Dependency.from_string(key)
dependency_graph.add_child_vertex(dependency.name, parents.empty? ? dependency : nil, parents, nil)
dependency = add_child_vertex.call(key, parents)
value.each { |v| add_to_dependency_graph.call(v, [dependency.name]) }
end
end
end
pods = lockfile.to_hash['PODS'] || []
pods.each do |p|
add_to_dependency_graph.call(p, [])
pods.each do |pod|
add_to_dependency_graph.call(pod, [])
end
pods_to_update = result.podfile_state.changed + result.podfile_state.deleted
if update_mode == :selected
# If selected Pods should been updated, filter them out of the list
pods_to_update += update[:pods]
end
pods_to_update += update[:pods] if update_mode == :selected
pods_to_update.each { |u| dependency_graph.detach_vertex_named(u) }
end
dependency_graph
end
......
......@@ -67,10 +67,11 @@ module Pod
@specs_by_target ||= begin
specs_by_target = {}
podfile.target_definition_list.each do |target|
specs_by_target[target] = target.dependencies.map(&:name).map do |name|
specs = target.dependencies.map(&:name).map do |name|
node = @activated.vertex_named(name)
(node.recursive_successors << node).to_a
end.
end
specs_by_target[target] = specs.
flatten.
map(&:payload).
uniq.
......@@ -95,11 +96,18 @@ module Pod
def search_for(dependency)
@search ||= {}
@search[dependency] ||= begin
find_cached_set(dependency).
specs = find_cached_set(dependency).
all_specifications.
select { |s| dependency.requirement.satisfied_by? s.version }.
map { |s| s.subspec_by_name dependency.name rescue nil }.
compact.
map do |s|
begin
s.subspec_by_name dependency.name
rescue
nil
end
end.compact
specs.
reverse.
each { |s| s.version.head = dependency.head? }
end
......@@ -214,7 +222,7 @@ module Pod
end
cached_sets[name] = set
unless set
raise Molinillo::NoSuchDependencyError.new(dependency)
raise Molinillo::NoSuchDependencyError.new(dependency) # rubocop:disable Style/RaiseArgs
end
end
cached_sets[name]
......
......@@ -35,10 +35,15 @@ module Pod
def all_specifications
@all_specifications ||= begin
versions_by_source.reduce({}) do |sources_by_version, (source, versions)|
sources_by_version = {}
versions_by_source.each do |source, versions|
versions.each { |v| (sources_by_version[v] ||= []) << source }
sources_by_version
end.select { |_version, sources| sources.count > 1 }.each do |version, sources|
end
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) }.
......
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