Commit 7c68caba authored by Marius Rackwitz's avatar Marius Rackwitz

[Analyzer] More consistent scope suffixes

parent e0ff376b
...@@ -348,32 +348,39 @@ module Pod ...@@ -348,32 +348,39 @@ module Pod
result = nil result = nil
all_spec_variants = targets_by_distinctors.keys.map { |k| k[0] } all_spec_variants = targets_by_distinctors.keys.map { |k| k[0] }
all_platform_variants = targets_by_distinctors.keys.map { |k| k[1] } all_platform_variants = targets_by_distinctors.keys.map { |k| k[1] }
all_platform_name_variants = all_platform_variants.map(&:name)
platform_name_proc = nil
if all_platform_name_variants.uniq.count == all_platform_name_variants.count
# => Platform name
platform_name_proc = proc { |platform| Platform.string_name(platform.symbolic_name).tr(' ', '') }
else
# => Platform name + SDK version
platform_name_proc = proc { |platform| platform.to_s.tr(' ', '') }
end
if all_platform_variants.uniq.count == all_platform_variants.count if all_platform_variants.uniq.count == all_platform_variants.count
all_platform_name_variants = all_platform_variants.map(&:name) result = targets_by_distinctors.map { |d, _| [d, platform_name_proc.call(d[1])] }
if all_platform_name_variants.uniq.count == all_platform_name_variants.count
# => Platform name
result = targets_by_distinctors.map { |d, _| [d, Platform.string_name(d[1].symbolic_name).tr(' ', '')] }
else
# => Platform name + SDK version
result = targets_by_distinctors.map { |d, _| [d, d[1].to_s.tr(' ', '')] }
end
elsif all_spec_variants.uniq.count == all_spec_variants.count
common_specs = all_spec_variants.reduce(all_spec_variants.first, &:&)
result = targets_by_distinctors.map do |distinctor, _|
specs, = *distinctor
specs -= common_specs
subspec_names = specs.map { |spec| spec.name.split('/')[1..-1].join('_') }
# => Subspecs names without common subspecs
[distinctor, subspec_names.empty? ? nil : subspec_names.join('-')]
end
else else
result = targets_by_distinctors.map do |distinctor, target_definitions| common_specs = all_spec_variants.reduce(all_spec_variants.first, &:&)
names = target_definitions.map do |target_definition| if all_spec_variants.uniq.count == all_spec_variants.count
target_definition.root? ? 'Pods' : target_definition.name result = targets_by_distinctors.map do |distinctor, _|
specs, = *distinctor
specs -= common_specs
subspec_names = specs.map { |spec| spec.name.split('/')[1..-1].join('_') }
# => Subspecs names without common subspecs
[distinctor, subspec_names.empty? ? nil : subspec_names.join('-')]
end
else
result = targets_by_distinctors.map do |distinctor, _|
specs, platform = *distinctor
specs -= common_specs
subspec_names = specs.map { |spec| spec.name.split('/')[1..-1].join('_') }
platform_name = platform_name_proc.call(platform)
name_parts = [platform_name] + subspec_names
# => Platform name (+ SDK version) + subspecs names without common subspecs
[distinctor, name_parts.join('-')]
end end
# => *All* target definition names
[distinctor, names.join('-')]
end end
end end
......
...@@ -163,18 +163,33 @@ module Pod ...@@ -163,18 +163,33 @@ module Pod
@analyzer.send(:scope_suffix_for_distinctor, specs).values.should == [nil, 'Foo', 'Bar'] @analyzer.send(:scope_suffix_for_distinctor, specs).values.should == [nil, 'Foo', 'Bar']
end end
it 'returns scopes by target definition labels' do it 'returns scopes by platform names and subspec names if they qualify' do
specs = { specs = {
[[@root_spec], Platform.ios] => [@target_definitions[0]], [[@root_spec], Platform.ios] => [@target_definitions[0]],
[[@root_spec, stub(:name => 'Spec/Foo')], Platform.ios] => [@target_definitions[1], @target_definitions[2]], [[@root_spec, stub(:name => 'Spec/Foo')], Platform.ios] => [@target_definitions[1]],
[[@root_spec], Platform.osx] => [@target_definitions[3]], [[@root_spec], Platform.osx] => [@target_definitions[2]],
[[@root_spec, stub(:name => 'Spec/Bar')], Platform.osx] => [@target_definitions[4]], [[@root_spec, stub(:name => 'Spec/Bar')], Platform.osx] => [@target_definitions[3]],
} }
@analyzer.send(:scope_suffix_for_distinctor, specs).values.should == [ @analyzer.send(:scope_suffix_for_distinctor, specs).values.should == [
'Pods', 'iOS',
'Target Definition 1-Target Definition 2', 'iOS-Foo',
'Target Definition 3', 'OSX',
'Target Definition 4', 'OSX-Bar',
]
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]],
}
@analyzer.send(:scope_suffix_for_distinctor, specs).values.should == [
'iOS7.0',
'iOS-Foo',
'OSX',
'OSX-Bar',
] ]
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