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
8a7f3a2c
Commit
8a7f3a2c
authored
Feb 23, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SandboxAnalyzer] Detect pre-downloaded Pods
parent
0e0523fc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
69 deletions
+33
-69
library_representation.rb
lib/cocoapods/hooks/library_representation.rb
+7
-7
installer.rb
lib/cocoapods/installer.rb
+10
-26
sandbox_analyzer.rb
lib/cocoapods/installer/analyzer/sandbox_analyzer.rb
+2
-0
path_list.rb
lib/cocoapods/sandbox/path_list.rb
+1
-1
sandbox_analyzer_spec.rb
spec/unit/installer/analyzer/sandbox_analyzer_spec.rb
+5
-0
installer_spec.rb
spec/unit/installer_spec.rb
+8
-35
No files found.
lib/cocoapods/hooks/library_representation.rb
View file @
8a7f3a2c
...
...
@@ -36,13 +36,6 @@ module Pod
library
.
target_definition
end
# @return [PBXNativeTarget] The target generated by the installation
# process.
#
def
target
library
.
target
end
#-----------------------------------------------------------------------#
public
...
...
@@ -58,6 +51,13 @@ module Pod
#
attr_reader
:library
# @return [PBXNativeTarget] The target generated by the installation
# process.
#
def
target
library
.
target
end
#-----------------------------------------------------------------------#
# @!group Private implementation
...
...
lib/cocoapods/installer.rb
View file @
8a7f3a2c
...
...
@@ -90,7 +90,6 @@ module Pod
def
resolve_dependencies
UI
.
section
"Analyzing dependencies"
do
analyze
detect_pods_to_install
prepare_for_legacy_compatibility
clean_sandbox
end
...
...
@@ -158,28 +157,6 @@ module Pod
@libraries
=
analyzer
.
result
.
libraries
end
# Computes the list of the Pods that should be installed or reinstalled in
# the {Sandbox}.
#
# The pods to install are identified as the Pods that don't exist in the
# sandbox or the Pods whose version differs from the one of the lockfile.
#
# @note In update mode specs originating from external dependencies and
# or from head sources are always reinstalled.
#
# @return [void]
#
# @todo [#534] Detect if the folder of a Pod is empty (even if it exits).
#
def
detect_pods_to_install
names
=
[]
names
+=
analysis_result
.
sandbox_state
.
added
+
analysis_result
.
sandbox_state
.
changed
names
+=
sandbox
.
predownloaded_pods
names
=
names
.
map
{
|
name
|
Specification
.
root_name
(
name
)
}
names
=
names
.
flatten
.
uniq
@names_of_pods_to_install
=
names
end
# Prepares the Pods folder in order to be compatible with the most recent
# version of CocoaPods.
#
...
...
@@ -201,9 +178,9 @@ module Pod
sandbox
.
build_headers
.
implode!
sandbox
.
public_headers
.
implode!
unless
analysis_result
.
sandbox_state
.
deleted
.
empty?
unless
sandbox_state
.
deleted
.
empty?
title_options
=
{
:verbose_prefix
=>
"-> "
.
red
}
analysis_result
.
sandbox_state
.
deleted
.
each
do
|
pod_name
|
sandbox_state
.
deleted
.
each
do
|
pod_name
|
UI
.
titled_section
(
"Removing
#{
pod_name
}
"
.
red
,
title_options
)
do
sandbox
.
clean_pod
(
pod_name
)
end
...
...
@@ -233,9 +210,10 @@ module Pod
#
def
install_pod_sources
@installed_specs
=
[]
pods_to_install
=
sandbox_state
.
added
|
sandbox_state
.
changed
title_options
=
{
:verbose_prefix
=>
"-> "
.
green
}
root_specs
.
sort_by
(
&
:name
).
each
do
|
spec
|
if
names_of_
pods_to_install
.
include?
(
spec
.
name
)
if
pods_to_install
.
include?
(
spec
.
name
)
UI
.
titled_section
(
"Installing
#{
spec
}
"
.
green
,
title_options
)
do
install_source_of_pod
(
spec
.
name
)
end
...
...
@@ -477,6 +455,12 @@ module Pod
analysis_result
.
specifications
.
map
{
|
spec
|
spec
.
root
}.
uniq
end
# @return [SpecsState] The state of the sandbox returned by the analyzer.
#
def
sandbox_state
analysis_result
.
sandbox_state
end
#-------------------------------------------------------------------------#
end
...
...
lib/cocoapods/installer/analyzer/sandbox_analyzer.rb
View file @
8a7f3a2c
...
...
@@ -18,6 +18,7 @@ module Pod
# - The specification is in head mode or from an external source and the
# installation process is in update mode.
# - The directory of the Pod is empty.
# - The Pod has been pre-downloaded.
#
# Removed
# - If a specification is present in the lockfile but not in the resolved
...
...
@@ -147,6 +148,7 @@ module Pod
return
true
if
spec
.
version
!=
sandbox_version
(
pod
)
return
true
if
spec
.
checksum
!=
sandbox_checksum
(
pod
)
return
true
if
resolved_spec_names
(
pod
)
!=
sandbox_spec_names
(
pod
)
return
true
if
sandbox
.
predownloaded?
(
pod
)
return
true
if
folder_empty?
(
pod
)
if
update_mode
return
true
if
spec
.
version
.
head?
...
...
lib/cocoapods/sandbox/path_list.rb
View file @
8a7f3a2c
...
...
@@ -53,7 +53,7 @@ module Pod
absolute_paths
=
paths
.
reject
{
|
p
|
p
==
"
#{
root
}
/."
||
p
==
"
#{
root
}
/.."
}
relative_paths
=
absolute_paths
.
map
{
|
p
|
p
[
root_length
..-
1
]
}
@files
=
relative_paths
-
relative_dirs
@dirs
=
relative_dirs
.
map
{
|
d
|
d
.
gsub
(
/\/\.\.?$/
,
''
)
}.
uniq
@dirs
=
relative_dirs
.
map
{
|
d
|
d
.
gsub
(
/\/\.\.?$/
,
''
)
}.
reject
{
|
d
|
d
==
'.'
||
d
==
'..'
}
.
uniq
end
#-----------------------------------------------------------------------#
...
...
spec/unit/installer/analyzer/sandbox_analyzer_spec.rb
View file @
8a7f3a2c
...
...
@@ -83,6 +83,11 @@ module Pod
@analyzer
.
send
(
:pod_changed?
,
'BananaLib'
).
should
==
true
end
it
"considers changed a Pod which has been pre-downloaded"
do
@sandbox
.
stubs
(
:predownloaded?
).
returns
(
true
)
@analyzer
.
send
(
:pod_changed?
,
'BananaLib'
).
should
==
true
end
it
"considers changed a Pod whose specification is in head mode if in update mode"
do
@spec
.
version
.
head
=
true
@analyzer
.
stubs
(
:update_mode
).
returns
(
true
)
...
...
spec/unit/installer_spec.rb
View file @
8a7f3a2c
...
...
@@ -117,39 +117,6 @@ module Pod
#--------------------------------------#
describe
"#detect_pods_to_install"
do
before
do
@analysis_result
=
Installer
::
Analyzer
::
AnalysisResult
.
new
@analysis_result
.
specifications
=
[]
@analysis_result
.
sandbox_state
=
Installer
::
Analyzer
::
SpecsState
.
new
()
@installer
.
stubs
(
:analysis_result
).
returns
(
@analysis_result
)
Pathname
.
any_instance
.
stubs
(
:exist?
).
returns
(
true
)
end
it
"includes the added Pods"
do
@analysis_result
.
sandbox_state
.
add_name
(
'added-pod'
,
:added
)
@installer
.
send
(
:detect_pods_to_install
)
@installer
.
names_of_pods_to_install
.
should
==
[
'added-pod'
]
end
it
"includes the changed Pods"
do
@analysis_result
.
sandbox_state
.
add_name
(
'changed-pod'
,
:changed
)
@installer
.
send
(
:detect_pods_to_install
)
@installer
.
names_of_pods_to_install
.
should
==
[
'changed-pod'
]
end
it
"includes the pre-downloaded Pods"
do
@analysis_result
.
sandbox_state
.
add_name
(
'unchanged-pods'
,
:unchanged
)
config
.
sandbox
.
stubs
(
:predownloaded_pods
).
returns
([
'pre-downloaded-pod'
])
@installer
.
send
(
:detect_pods_to_install
)
@installer
.
names_of_pods_to_install
.
should
==
[
'pre-downloaded-pod'
]
end
end
#--------------------------------------#
describe
"#clean_sandbox"
do
before
do
...
...
@@ -183,9 +150,15 @@ module Pod
it
"installs all the Pods which are marked as needing installation"
do
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@installer
.
stubs
(
:root_specs
).
returns
([
spec
])
@installer
.
stubs
(
:names_of_pods_to_install
).
returns
([
'BananaLib'
])
spec_2
=
Spec
.
new
spec_2
.
name
=
'RestKit'
@installer
.
stubs
(
:root_specs
).
returns
([
spec
,
spec_2
])
sandbox_state
=
Installer
::
Analyzer
::
SpecsState
.
new
sandbox_state
.
added
<<
'BananaLib'
sandbox_state
.
changed
<<
'RestKit'
@installer
.
stubs
(
:sandbox_state
).
returns
(
sandbox_state
)
@installer
.
expects
(
:install_source_of_pod
).
with
(
'BananaLib'
)
@installer
.
expects
(
:install_source_of_pod
).
with
(
'RestKit'
)
@installer
.
send
(
:install_pod_sources
)
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