Commit ac4fe54e authored by Marius Rackwitz's avatar Marius Rackwitz

[Analyzer] Simplify parameter type of #scope_suffix_for_distinctor

parent f85fd191
......@@ -303,7 +303,7 @@ module Pod
pod_targets = distinct_targets.flat_map do |_, targets_by_distinctors|
if targets_by_distinctors.count > 1
# There are different sets of subspecs or the spec is used across different platforms
suffixes = scope_suffix_for_distinctor(targets_by_distinctors)
suffixes = scope_suffix_for_distinctor(targets_by_distinctors.keys)
targets_by_distinctors.flat_map do |distinctor, target_definitions|
specs, = *distinctor
generate_pod_target(target_definitions, specs, :scope_suffix => suffixes[distinctor])
......@@ -340,14 +340,14 @@ module Pod
# Describes what makes pod targets configurations distinct among other.
#
# @param [(Array<Specification>, Platform) => TargetDefinition] targets_by_distinctors
# @param [(Array<Specification>, Platform) => TargetDefinition] distinctors
#
# @return [(Array<Specification>, Platform) => String]
#
def scope_suffix_for_distinctor(targets_by_distinctors)
def scope_suffix_for_distinctor(distinctors)
result = nil
all_spec_variants = targets_by_distinctors.keys.map { |k| k[0] }
all_platform_variants = targets_by_distinctors.keys.map { |k| k[1] }
all_spec_variants = distinctors.map { |k| k[0] }
all_platform_variants = distinctors.map { |k| k[1] }
all_platform_name_variants = all_platform_variants.map(&:name)
platform_name_proc = nil
......@@ -360,10 +360,10 @@ module Pod
end
if all_platform_variants.uniq.count == all_platform_variants.count
result = targets_by_distinctors.map { |d, _| [d, platform_name_proc.call(d[1])] }
result = distinctors.map { |d| [d, platform_name_proc.call(d[1])] }
else
common_specs = all_spec_variants.reduce(all_spec_variants.first, &:&)
result = targets_by_distinctors.map do |distinctor, _|
result = distinctors.map do |distinctor|
specs, = *distinctor
specs -= common_specs
subspec_names = specs.map { |spec| spec.name.split('/')[1..-1].join('_') }
......
......@@ -134,42 +134,41 @@ module Pod
before do
@analyzer = Pod::Installer::Analyzer.new(config.sandbox, stub('Podfile'), nil)
@root_spec = stub(:name => 'Spec')
@target_definitions = 5.times.map { |i| stub(:name => "Target Definition #{i}", :root? => i == 0) }
end
it 'returns scopes by platform names if they qualify' do
specs = {
[[@root_spec], Platform.ios] => [@target_definitions[0]],
[[@root_spec], Platform.osx] => [@target_definitions[1]],
}
specs = [
[[@root_spec], Platform.ios],
[[@root_spec], Platform.osx],
]
@analyzer.send(:scope_suffix_for_distinctor, specs).values.should == %w(iOS OSX)
end
it 'returns scopes by versioned platform names if they qualify' do
specs = {
[[@root_spec], Platform.ios] => [@target_definitions[0]],
[[@root_spec], Platform.new(:ios, '7.0')] => [@target_definitions[1]],
}
specs = [
[[@root_spec], Platform.ios],
[[@root_spec], Platform.new(:ios, '7.0')],
]
@analyzer.send(:scope_suffix_for_distinctor, specs).values.should == ['iOS', 'iOS7.0']
end
it 'returns scopes by subspec names if they qualify' do
shared_subspec = stub(:name => 'Spec/Shared')
specs = {
[[@root_spec, shared_subspec], Platform.ios] => [@target_definitions[0]],
[[@root_spec, shared_subspec, stub(:name => 'Spec/Foo')], Platform.ios] => [@target_definitions[1]],
[[@root_spec, shared_subspec, stub(:name => 'Spec/Bar')], Platform.ios] => [@target_definitions[2]],
}
specs = [
[[@root_spec, shared_subspec], Platform.ios],
[[@root_spec, shared_subspec, stub(:name => 'Spec/Foo')], Platform.ios],
[[@root_spec, shared_subspec, stub(:name => 'Spec/Bar')], Platform.ios],
]
@analyzer.send(:scope_suffix_for_distinctor, specs).values.should == [nil, 'Foo', 'Bar']
end
it 'returns scopes by platform names and subspec names if they qualify' do
specs = {
[[@root_spec], Platform.ios] => [@target_definitions[0]],
[[@root_spec, stub(:name => 'Spec/Foo')], Platform.ios] => [@target_definitions[1]],
[[@root_spec], Platform.osx] => [@target_definitions[2]],
[[@root_spec, stub(:name => 'Spec/Bar')], Platform.osx] => [@target_definitions[3]],
}
specs = [
[[@root_spec], Platform.ios],
[[@root_spec, stub(:name => 'Spec/Foo')], Platform.ios],
[[@root_spec], Platform.osx],
[[@root_spec, stub(:name => 'Spec/Bar')], Platform.osx],
]
@analyzer.send(:scope_suffix_for_distinctor, specs).values.should == [
'iOS',
'iOS-Foo',
......@@ -179,12 +178,12 @@ module Pod
end
it 'returns scopes by versioned platform names and subspec names if they qualify' do
specs = {
[[@root_spec], Platform.new(:ios, '7.0')] => [@target_definitions[0]],
[[@root_spec, stub(:name => 'Spec/Foo')], Platform.ios] => [@target_definitions[1]],
[[@root_spec], Platform.osx] => [@target_definitions[2]],
[[@root_spec, stub(:name => 'Spec/Bar')], Platform.osx] => [@target_definitions[3]],
}
specs = [
[[@root_spec], Platform.new(:ios, '7.0')],
[[@root_spec, stub(:name => 'Spec/Foo')], Platform.ios],
[[@root_spec], Platform.osx],
[[@root_spec, stub(:name => 'Spec/Bar')], Platform.osx],
]
@analyzer.send(:scope_suffix_for_distinctor, specs).values.should == [
'iOS7.0',
'iOS-Foo',
......
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