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
a9d87406
Commit
a9d87406
authored
Jul 03, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Installer] Use aggregate target for library reppresentation
Closes #1157
parent
6827f83d
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
49 additions
and
31 deletions
+49
-31
installer_representation.rb
lib/cocoapods/hooks/installer_representation.rb
+2
-2
library_representation.rb
lib/cocoapods/hooks/library_representation.rb
+1
-0
installer.rb
lib/cocoapods/installer.rb
+6
-4
target.rb
lib/cocoapods/target.rb
+1
-1
aggregate_target.rb
lib/cocoapods/target/aggregate_target.rb
+9
-2
pre_install.txt
...tegration/install_podfile_callbacks/after/pre_install.txt
+1
-1
installer_representation_spec.rb
spec/unit/hooks/installer_representation_spec.rb
+2
-2
library_representation_spec.rb
spec/unit/hooks/library_representation_spec.rb
+7
-3
installer_spec.rb
spec/unit/installer_spec.rb
+14
-15
aggregate_target_spec.rb
spec/unit/target/aggregate_target_spec.rb
+6
-1
No files found.
lib/cocoapods/hooks/installer_representation.rb
View file @
a9d87406
...
...
@@ -59,8 +59,8 @@ module Pod
#
def
specs_by_lib
result
=
{}
installer
.
pod_targets
.
each
do
|
lib
|
result
[
installer
.
library_rep
(
lib
)]
=
lib
.
specs
installer
.
aggregate_targets
.
each
do
|
aggregate_target
|
result
[
installer
.
library_rep
(
aggregate_target
)]
=
aggregate_target
.
specs
end
result
end
...
...
lib/cocoapods/hooks/library_representation.rb
View file @
a9d87406
...
...
@@ -83,6 +83,7 @@ module Pod
def
initialize
(
sandbox
,
library
)
@sandbox
=
sandbox
@library
=
library
raise
"[BUG]"
unless
library
.
is_a?
(
AggregateTarget
)
end
#-----------------------------------------------------------------------#
...
...
lib/cocoapods/installer.rb
View file @
a9d87406
...
...
@@ -547,14 +547,14 @@ module Pod
# @return [LibraryRepresentation]
#
def
library_rep
(
library
)
Hooks
::
LibraryRepresentation
.
new
(
sandbox
,
library
)
def
library_rep
(
aggregate_target
)
Hooks
::
LibraryRepresentation
.
new
(
sandbox
,
aggregate_target
)
end
# @return [Array<LibraryRepresentation>]
#
def
library_reps
@library_reps
||=
pod
_targets
.
map
{
|
lib
|
library_rep
(
lib
)
}
@library_reps
||=
aggregate
_targets
.
map
{
|
lib
|
library_rep
(
lib
)
}
end
# @return [Array<PodRepresentation>]
...
...
@@ -571,7 +571,9 @@ module Pod
# @return [Array<Library>] The library.
#
def
libraries_using_spec
(
spec
)
pod_targets
.
select
{
|
pod_target
|
pod_target
.
specs
.
include?
(
spec
)
}
aggregate_targets
.
select
do
|
aggregate_target
|
aggregate_target
.
pod_targets
.
any?
{
|
pod_target
|
pod_target
.
specs
.
include?
(
spec
)
}
end
end
# @return [Array<Library>] The libraries generated by the installation
...
...
lib/cocoapods/target.rb
View file @
a9d87406
...
...
@@ -38,7 +38,7 @@ module Pod
# @return [String] A string suitable for debugging.
#
def
inspect
"<
#{
self
.
class
}
name=
#{
name
}
platform=
#{
platform
}
>"
"<
#{
self
.
class
}
name=
#{
name
}
>"
end
#-------------------------------------------------------------------------#
...
...
lib/cocoapods/target/aggregate_target.rb
View file @
a9d87406
...
...
@@ -56,9 +56,16 @@ module Pod
#
attr_accessor
:pod_targets
# @return [Array<SpecConsumer>]
# @return [Array<Specification>] The specifications used by this aggregate target.
#
def
specs
pod_targets
.
map
(
&
:specs
).
flatten
end
# @return [Array<Specification::Consumer>] The consumers of the Pod.
#
def
spec_consumers
pod_targets
.
map
(
&
:specs
).
flatten
.
map
{
|
spec
|
spec
.
consumer
(
platform
)
}
specs
.
map
{
|
spec
|
spec
.
consumer
(
platform
)
}
end
# @return [Pathname] The absolute path of acknowledgements file.
...
...
spec/integration/install_podfile_callbacks/after/pre_install.txt
View file @
a9d87406
PODS:Reachability (3.1.0) TARGETS:Pods
-Reachability
PODS:Reachability (3.1.0) TARGETS:Pods
spec/unit/hooks/installer_representation_spec.rb
View file @
a9d87406
...
...
@@ -40,13 +40,13 @@ module Pod
end
it
"the hook representation of the libraries"
do
@rep
.
libraries
.
map
(
&
:name
).
sort
.
should
==
[
'Pods
-JSONKit
'
].
sort
@rep
.
libraries
.
map
(
&
:name
).
sort
.
should
==
[
'Pods'
].
sort
end
it
"returns the specs by library representation"
do
specs_by_lib
=
@rep
.
specs_by_lib
lib_rep
=
specs_by_lib
.
keys
.
first
lib_rep
.
name
.
should
==
'Pods
-JSONKit
'
lib_rep
.
name
.
should
==
'Pods'
specs_by_lib
.
should
==
{
lib_rep
=>
@specs
}
end
...
...
spec/unit/hooks/library_representation_spec.rb
View file @
a9d87406
...
...
@@ -7,7 +7,7 @@ module Pod
@target_definition
=
Podfile
::
TargetDefinition
.
new
(
'MyApp'
,
nil
)
@spec
=
Spec
.
new
@spec
.
name
=
'RestKit'
@lib
=
PodTarget
.
new
([
@spec
],
@target_definition
,
config
.
sandbox
)
@lib
=
AggregateTarget
.
new
(
@target_definition
,
config
.
sandbox
)
@rep
=
Hooks
::
LibraryRepresentation
.
new
(
config
.
sandbox
,
@lib
)
end
...
...
@@ -16,7 +16,7 @@ module Pod
describe
"Public Hooks API"
do
it
"returns the name"
do
@rep
.
name
.
should
==
'Pods-MyApp
-RestKit
'
@rep
.
name
.
should
==
'Pods-MyApp'
end
it
"returns the dependencies"
do
...
...
@@ -29,7 +29,11 @@ module Pod
end
it
"returns the path of the prefix header"
do
@rep
.
prefix_header_path
.
should
==
temporary_directory
+
'Pods/Pods-MyApp-RestKit-prefix.pch'
@rep
.
prefix_header_path
.
should
==
temporary_directory
+
'Pods/Pods-MyApp-prefix.pch'
end
it
"returns the path of the copy resources script"
do
@rep
.
copy_resources_script_path
.
should
==
temporary_directory
+
'Pods/Pods-MyApp-resources.sh'
end
it
"returns the pods project"
do
...
...
spec/unit/installer_spec.rb
View file @
a9d87406
...
...
@@ -383,7 +383,7 @@ module Pod
@specs
=
@installer
.
pod_targets
.
map
(
&
:specs
).
flatten
@spec
=
@specs
.
find
{
|
spec
|
spec
&&
spec
.
name
==
'JSONKit'
}
@installer
.
stubs
(
:installed_specs
).
returns
(
@specs
)
@
lib
=
@installer
.
aggregate_targets
.
first
.
pod
_targets
.
first
@
aggregate_target
=
@installer
.
aggregate
_targets
.
first
end
it
"runs the pre install hooks"
do
...
...
@@ -393,7 +393,7 @@ module Pod
@installer
.
expects
(
:installer_rep
).
returns
(
installer_rep
)
@installer
.
expects
(
:pod_rep
).
with
(
'JSONKit'
).
returns
(
pod_rep
)
@installer
.
expects
(
:library_rep
).
with
(
@
lib
).
returns
(
library_rep
)
@installer
.
expects
(
:library_rep
).
with
(
@
aggregate_target
).
returns
(
library_rep
)
@spec
.
expects
(
:pre_install!
)
@installer
.
podfile
.
expects
(
:pre_install!
).
with
(
installer_rep
)
@installer
.
send
(
:run_pre_install_hooks
)
...
...
@@ -404,7 +404,7 @@ module Pod
target_installer_data
=
stub
()
@installer
.
expects
(
:installer_rep
).
returns
(
installer_rep
)
@installer
.
expects
(
:library_rep
).
with
(
@
lib
).
returns
(
target_installer_data
)
@installer
.
expects
(
:library_rep
).
with
(
@
aggregate_target
).
returns
(
target_installer_data
)
@spec
.
expects
(
:post_install!
)
@installer
.
podfile
.
expects
(
:post_install!
).
with
(
installer_rep
)
@installer
.
send
(
:run_post_install_hooks
)
...
...
@@ -417,15 +417,14 @@ module Pod
pod_target_osx
.
stubs
(
:name
).
returns
(
'label'
)
library_ios_rep
=
stub
()
library_osx_rep
=
stub
()
target_installer_data
=
stub
()
@installer
.
stubs
(
:pod_targets
).
returns
([
pod_target_ios
,
pod_target_osx
])
@installer
.
stubs
(
:installer_rep
).
returns
(
stub
())
@installer
.
stubs
(
:library_rep
).
with
(
pod_target_ios
).
returns
(
library_ios_rep
)
@installer
.
stubs
(
:library_rep
).
with
(
pod_target_osx
).
returns
(
library_osx_rep
)
@installer
.
stubs
(
:library_rep
).
with
(
@aggregate_target
).
returns
(
target_installer_data
).
twice
@installer
.
podfile
.
expects
(
:pre_install!
)
@spec
.
expects
(
:post_install!
).
with
(
library_ios_rep
)
@spec
.
expects
(
:post_install!
).
with
(
library_osx_rep
)
@spec
.
expects
(
:post_install!
).
with
(
target_installer_data
).
once
@installer
.
send
(
:run_pre_install_hooks
)
@installer
.
send
(
:run_post_install_hooks
)
...
...
@@ -438,15 +437,15 @@ module Pod
it
"returns the hook representation of a pod"
do
file_accessor
=
stub
(
:spec
=>
@spec
)
@
lib
.
stubs
(
:file_accessors
).
returns
([
file_accessor
])
@
aggregate_target
.
pod_targets
.
first
.
stubs
(
:file_accessors
).
returns
([
file_accessor
])
rep
=
@installer
.
send
(
:pod_rep
,
'JSONKit'
)
rep
.
name
.
should
==
'JSONKit'
rep
.
root_spec
.
should
==
@spec
end
it
"returns the hook representation of a
library
"
do
rep
=
@installer
.
send
(
:library_rep
,
@
lib
)
rep
.
send
(
:library
).
name
.
should
==
'Pods
-JSONKit
'
it
"returns the hook representation of a
n aggregate target
"
do
rep
=
@installer
.
send
(
:library_rep
,
@
aggregate_target
)
rep
.
send
(
:library
).
name
.
should
==
'Pods'
end
it
"returns the hook representation of all the pods"
do
...
...
@@ -454,14 +453,14 @@ module Pod
reps
.
map
(
&
:name
).
should
==
[
'JSONKit'
]
end
it
"returns the hook representation of all the
target installers
"
do
it
"returns the hook representation of all the
aggregate target
"
do
reps
=
@installer
.
send
(
:library_reps
)
reps
.
map
(
&
:name
).
sort
.
should
==
[
'Pods
-JSONKit
'
].
sort
reps
.
map
(
&
:name
).
sort
.
should
==
[
'Pods'
].
sort
end
it
"returns the targets which use a given Pod"
do
it
"returns the
aggregate
targets which use a given Pod"
do
libs
=
@installer
.
send
(
:libraries_using_spec
,
@spec
)
libs
.
map
(
&
:name
).
should
==
[
'Pods
-JSONKit
'
]
libs
.
map
(
&
:name
).
should
==
[
'Pods'
]
end
end
...
...
spec/unit/target/aggregate_target_spec.rb
View file @
a9d87406
...
...
@@ -79,8 +79,13 @@ module Pod
@target
.
pod_targets
=
[
pod_target
]
end
it
"returns the specs of the Pods used by this aggregate target"
do
@target
.
specs
.
map
(
&
:name
).
should
==
[
"BananaLib"
]
end
it
"returns the spec consumers for the pod targets"
do
@target
.
spec_consumers
.
should
.
not
==
nil
consumer_reps
=
@target
.
spec_consumers
.
map
{
|
consumer
|
[
consumer
.
spec
.
name
,
consumer
.
platform_name
]
}
consumer_reps
.
should
==
[[
"BananaLib"
,
:ios
]]
end
end
...
...
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