Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
ac4fe54e
Commit
ac4fe54e
authored
Jan 25, 2016
by
Marius Rackwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Analyzer] Simplify parameter type of #scope_suffix_for_distinctor
parent
f85fd191
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
33 deletions
+32
-33
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+7
-7
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+25
-26
No files found.
lib/cocoapods/installer/analyzer.rb
View file @
ac4fe54e
...
@@ -303,7 +303,7 @@ module Pod
...
@@ -303,7 +303,7 @@ module Pod
pod_targets
=
distinct_targets
.
flat_map
do
|
_
,
targets_by_distinctors
|
pod_targets
=
distinct_targets
.
flat_map
do
|
_
,
targets_by_distinctors
|
if
targets_by_distinctors
.
count
>
1
if
targets_by_distinctors
.
count
>
1
# There are different sets of subspecs or the spec is used across different platforms
# 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
|
targets_by_distinctors
.
flat_map
do
|
distinctor
,
target_definitions
|
specs
,
=
*
distinctor
specs
,
=
*
distinctor
generate_pod_target
(
target_definitions
,
specs
,
:scope_suffix
=>
suffixes
[
distinctor
])
generate_pod_target
(
target_definitions
,
specs
,
:scope_suffix
=>
suffixes
[
distinctor
])
...
@@ -340,14 +340,14 @@ module Pod
...
@@ -340,14 +340,14 @@ module Pod
# Describes what makes pod targets configurations distinct among other.
# 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]
# @return [(Array<Specification>, Platform) => String]
#
#
def
scope_suffix_for_distinctor
(
targets_by_
distinctors
)
def
scope_suffix_for_distinctor
(
distinctors
)
result
=
nil
result
=
nil
all_spec_variants
=
targets_by_distinctors
.
key
s
.
map
{
|
k
|
k
[
0
]
}
all_spec_variants
=
distinctor
s
.
map
{
|
k
|
k
[
0
]
}
all_platform_variants
=
targets_by_distinctors
.
key
s
.
map
{
|
k
|
k
[
1
]
}
all_platform_variants
=
distinctor
s
.
map
{
|
k
|
k
[
1
]
}
all_platform_name_variants
=
all_platform_variants
.
map
(
&
:name
)
all_platform_name_variants
=
all_platform_variants
.
map
(
&
:name
)
platform_name_proc
=
nil
platform_name_proc
=
nil
...
@@ -360,10 +360,10 @@ module Pod
...
@@ -360,10 +360,10 @@ module Pod
end
end
if
all_platform_variants
.
uniq
.
count
==
all_platform_variants
.
count
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
else
common_specs
=
all_spec_variants
.
reduce
(
all_spec_variants
.
first
,
&
:&
)
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
,
=
*
distinctor
specs
-=
common_specs
specs
-=
common_specs
subspec_names
=
specs
.
map
{
|
spec
|
spec
.
name
.
split
(
'/'
)[
1
..-
1
].
join
(
'_'
)
}
subspec_names
=
specs
.
map
{
|
spec
|
spec
.
name
.
split
(
'/'
)[
1
..-
1
].
join
(
'_'
)
}
...
...
spec/unit/installer/analyzer_spec.rb
View file @
ac4fe54e
...
@@ -134,42 +134,41 @@ module Pod
...
@@ -134,42 +134,41 @@ module Pod
before
do
before
do
@analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
stub
(
'Podfile'
),
nil
)
@analyzer
=
Pod
::
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
stub
(
'Podfile'
),
nil
)
@root_spec
=
stub
(
:name
=>
'Spec'
)
@root_spec
=
stub
(
:name
=>
'Spec'
)
@target_definitions
=
5
.
times
.
map
{
|
i
|
stub
(
:name
=>
"Target Definition
#{
i
}
"
,
:root?
=>
i
==
0
)
}
end
end
it
'returns scopes by platform names if they qualify'
do
it
'returns scopes by platform names if they qualify'
do
specs
=
{
specs
=
[
[[
@root_spec
],
Platform
.
ios
]
=>
[
@target_definitions
[
0
]]
,
[[
@root_spec
],
Platform
.
ios
],
[[
@root_spec
],
Platform
.
osx
]
=>
[
@target_definitions
[
1
]]
,
[[
@root_spec
],
Platform
.
osx
],
}
]
@analyzer
.
send
(
:scope_suffix_for_distinctor
,
specs
).
values
.
should
==
%w(iOS OSX)
@analyzer
.
send
(
:scope_suffix_for_distinctor
,
specs
).
values
.
should
==
%w(iOS OSX)
end
end
it
'returns scopes by versioned platform names if they qualify'
do
it
'returns scopes by versioned platform names if they qualify'
do
specs
=
{
specs
=
[
[[
@root_spec
],
Platform
.
ios
]
=>
[
@target_definitions
[
0
]]
,
[[
@root_spec
],
Platform
.
ios
],
[[
@root_spec
],
Platform
.
new
(
:ios
,
'7.0'
)]
=>
[
@target_definitions
[
1
]]
,
[[
@root_spec
],
Platform
.
new
(
:ios
,
'7.0'
)],
}
]
@analyzer
.
send
(
:scope_suffix_for_distinctor
,
specs
).
values
.
should
==
[
'iOS'
,
'iOS7.0'
]
@analyzer
.
send
(
:scope_suffix_for_distinctor
,
specs
).
values
.
should
==
[
'iOS'
,
'iOS7.0'
]
end
end
it
'returns scopes by subspec names if they qualify'
do
it
'returns scopes by subspec names if they qualify'
do
shared_subspec
=
stub
(
:name
=>
'Spec/Shared'
)
shared_subspec
=
stub
(
:name
=>
'Spec/Shared'
)
specs
=
{
specs
=
[
[[
@root_spec
,
shared_subspec
],
Platform
.
ios
]
=>
[
@target_definitions
[
0
]]
,
[[
@root_spec
,
shared_subspec
],
Platform
.
ios
],
[[
@root_spec
,
shared_subspec
,
stub
(
:name
=>
'Spec/Foo'
)],
Platform
.
ios
]
=>
[
@target_definitions
[
1
]]
,
[[
@root_spec
,
shared_subspec
,
stub
(
:name
=>
'Spec/Foo'
)],
Platform
.
ios
],
[[
@root_spec
,
shared_subspec
,
stub
(
:name
=>
'Spec/Bar'
)],
Platform
.
ios
]
=>
[
@target_definitions
[
2
]]
,
[[
@root_spec
,
shared_subspec
,
stub
(
:name
=>
'Spec/Bar'
)],
Platform
.
ios
],
}
]
@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 platform names and subspec names if they qualify'
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
],
[[
@root_spec
,
stub
(
:name
=>
'Spec/Foo'
)],
Platform
.
ios
]
=>
[
@target_definitions
[
1
]]
,
[[
@root_spec
,
stub
(
:name
=>
'Spec/Foo'
)],
Platform
.
ios
],
[[
@root_spec
],
Platform
.
osx
]
=>
[
@target_definitions
[
2
]]
,
[[
@root_spec
],
Platform
.
osx
],
[[
@root_spec
,
stub
(
:name
=>
'Spec/Bar'
)],
Platform
.
osx
]
=>
[
@target_definitions
[
3
]]
,
[[
@root_spec
,
stub
(
:name
=>
'Spec/Bar'
)],
Platform
.
osx
],
}
]
@analyzer
.
send
(
:scope_suffix_for_distinctor
,
specs
).
values
.
should
==
[
@analyzer
.
send
(
:scope_suffix_for_distinctor
,
specs
).
values
.
should
==
[
'iOS'
,
'iOS'
,
'iOS-Foo'
,
'iOS-Foo'
,
...
@@ -179,12 +178,12 @@ module Pod
...
@@ -179,12 +178,12 @@ module Pod
end
end
it
'returns scopes by versioned platform names and subspec names if they qualify'
do
it
'returns scopes by versioned platform names and subspec names if they qualify'
do
specs
=
{
specs
=
[
[[
@root_spec
],
Platform
.
new
(
:ios
,
'7.0'
)]
=>
[
@target_definitions
[
0
]]
,
[[
@root_spec
],
Platform
.
new
(
:ios
,
'7.0'
)],
[[
@root_spec
,
stub
(
:name
=>
'Spec/Foo'
)],
Platform
.
ios
]
=>
[
@target_definitions
[
1
]]
,
[[
@root_spec
,
stub
(
:name
=>
'Spec/Foo'
)],
Platform
.
ios
],
[[
@root_spec
],
Platform
.
osx
]
=>
[
@target_definitions
[
2
]]
,
[[
@root_spec
],
Platform
.
osx
],
[[
@root_spec
,
stub
(
:name
=>
'Spec/Bar'
)],
Platform
.
osx
]
=>
[
@target_definitions
[
3
]]
,
[[
@root_spec
,
stub
(
:name
=>
'Spec/Bar'
)],
Platform
.
osx
],
}
]
@analyzer
.
send
(
:scope_suffix_for_distinctor
,
specs
).
values
.
should
==
[
@analyzer
.
send
(
:scope_suffix_for_distinctor
,
specs
).
values
.
should
==
[
'iOS7.0'
,
'iOS7.0'
,
'iOS-Foo'
,
'iOS-Foo'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment