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
943ea72d
Commit
943ea72d
authored
Feb 19, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Installer] Clean up & specs
parent
d9f450c7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
69 deletions
+111
-69
installer.rb
lib/cocoapods/installer.rb
+74
-57
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+0
-0
sandbox.rb
lib/cocoapods/sandbox.rb
+13
-0
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+6
-12
installer_spec.rb
spec/unit/installer_spec.rb
+0
-0
sandbox_spec.rb
spec/unit/sandbox_spec.rb
+18
-0
No files found.
lib/cocoapods/installer.rb
View file @
943ea72d
...
@@ -81,17 +81,35 @@ module Pod
...
@@ -81,17 +81,35 @@ module Pod
# @return [void]
# @return [void]
#
#
def
install!
def
install!
analyze
resolve_dependencies
detect_pods_to_install
download_dependencies
prepare_for_legacy_compatibility
generate_pods_project
prepare_sandbox
if
config
.
integrate_targets?
UI
.
section
"Integrating client projects"
do
integrate_user_project
end
end
end
def
resolve_dependencies
UI
.
section
"Resolving dependencies"
do
analyze
detect_pods_to_install
prepare_for_legacy_compatibility
prepare_sandbox
end
end
def
download_dependencies
UI
.
section
"Downloading dependencies"
do
UI
.
section
"Downloading dependencies"
do
create_file_accessors
create_file_accessors
install_pod_sources
install_pod_sources
end
end
end
UI
.
section
"Generating Pods Project"
do
def
generate_pods_project
UI
.
section
"Generating pods project"
do
prepare_pods_project
prepare_pods_project
run_pre_install_hooks
run_pre_install_hooks
install_file_references
install_file_references
...
@@ -100,12 +118,6 @@ module Pod
...
@@ -100,12 +118,6 @@ module Pod
write_pod_project
write_pod_project
write_lockfiles
write_lockfiles
end
end
if
config
.
integrate_targets?
UI
.
section
"Integrating client projects"
do
integrate_user_project
end
end
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
@@ -117,7 +129,7 @@ module Pod
...
@@ -117,7 +129,7 @@ module Pod
# @return [Analyzer] the analyzer which provides the information about what
# @return [Analyzer] the analyzer which provides the information about what
# needs to be installed.
# needs to be installed.
#
#
attr_reader
:analy
zer
attr_reader
:analy
sis_result
# @return [Pod::Project] the `Pods/Pods.xcodeproj` project.
# @return [Pod::Project] the `Pods/Pods.xcodeproj` project.
#
#
...
@@ -140,18 +152,15 @@ module Pod
...
@@ -140,18 +152,15 @@ module Pod
private
private
# TODO: This is recreating the file accessors
# TODO: the file accessor should be initializable without a path list
# @!group Installation steps
# @!group Installation steps
# @return [void]
# @return [void]
#
#
def
analyze
def
analyze
@
analyzer
=
Analyzer
.
new
(
sandbox
,
podfile
,
lockfile
)
analyzer
=
Analyzer
.
new
(
sandbox
,
podfile
,
lockfile
)
@
analyzer
.
update_mode
=
update_mode
analyzer
.
update_mode
=
update_mode
@analyzer
.
analyze
@analy
sis_result
=
analy
zer
.
analyze
@libraries
=
analyzer
.
libraries
@libraries
=
analyzer
.
result
.
libraries
end
end
# Computes the list of the Pods that should be installed or reinstalled in
# Computes the list of the Pods that should be installed or reinstalled in
...
@@ -173,11 +182,11 @@ module Pod
...
@@ -173,11 +182,11 @@ module Pod
def
detect_pods_to_install
def
detect_pods_to_install
names
=
[]
names
=
[]
analy
zer
.
specifications
.
each
do
|
spec
|
analy
sis_result
.
specifications
.
each
do
|
spec
|
root_name
=
spec
.
root
.
name
root_name
=
spec
.
root
.
name
if
update_mode
if
update_mode
if
spec
.
version
.
head?
#
|| TODO resolver.pods_from_external_sources.include?(root_name)
if
spec
.
version
.
head?
#
|| resolver.pods_from_external_sources.include?(root_name) TODO
names
<<
root_name
names
<<
root_name
end
end
end
end
...
@@ -187,7 +196,7 @@ module Pod
...
@@ -187,7 +196,7 @@ module Pod
end
end
end
end
names
+=
analy
zer
.
sandbox_state
.
added
+
analyzer
.
sandbox_state
.
changed
names
+=
analy
sis_result
.
sandbox_state
.
added
+
analysis_result
.
sandbox_state
.
changed
names
=
names
.
map
{
|
name
|
Specification
.
root_name
(
name
)
}
names
=
names
.
map
{
|
name
|
Specification
.
root_name
(
name
)
}
names
=
names
.
flatten
.
uniq
names
=
names
.
flatten
.
uniq
@names_of_pods_to_install
=
names
@names_of_pods_to_install
=
names
...
@@ -210,10 +219,6 @@ module Pod
...
@@ -210,10 +219,6 @@ module Pod
#
#
# @todo [#247] Clean the headers of only the pods to install.
# @todo [#247] Clean the headers of only the pods to install.
#
#
# @todo [#534] Clean all the Pods folder that are not unchanged
#
# @todo Use the local pod implode.
#
# @todo Clean the podspecs of all the pods that aren't unchanged so the
# @todo Clean the podspecs of all the pods that aren't unchanged so the
# resolution process doesn't get confused by them.
# resolution process doesn't get confused by them.
#
#
...
@@ -221,36 +226,19 @@ module Pod
...
@@ -221,36 +226,19 @@ module Pod
sandbox
.
build_headers
.
implode!
sandbox
.
build_headers
.
implode!
sandbox
.
public_headers
.
implode!
sandbox
.
public_headers
.
implode!
# TODO local option
unless
analysis_result
.
sandbox_state
.
deleted
.
empty?
unless
analyzer
.
sandbox_state
.
deleted
.
empty?
UI
.
section
"Removing deleted dependencies"
do
UI
.
section
"Removing deleted dependencies"
do
analy
zer
.
sandbox_state
.
deleted
.
each
do
|
pod_name
|
analy
sis_result
.
sandbox_state
.
deleted
.
each
do
|
pod_name
|
UI
.
section
(
"Removing
#{
pod_name
}
"
,
"-> "
.
red
)
do
UI
.
section
(
"Removing
#{
pod_name
}
"
,
"-> "
.
red
)
do
path
=
sandbox
.
root
+
pod_name
sandbox
.
clean_pod
(
pod_name
)
path
.
rmtree
if
path
.
exist?
end
end
end
end
end
end
end
end
end
end
# Creates the Pods project from scratch if it doesn't exists.
# TODO: the file accessor should be initialized by the sandbox as they
#
# created by the Pod source installer as well.
# @return [void]
#
# @todo Clean and modify the project if it exists.
#
def
prepare_pods_project
UI
.
message
"- Creating Pods project"
do
@pods_project
=
Pod
::
Project
.
new
(
sandbox
.
project_path
)
if
config
.
podfile_path
.
exist?
@pods_project
.
add_podfile
(
config
.
podfile_path
)
end
sandbox
.
project
=
@pods_project
end
end
#
#
#
def
create_file_accessors
def
create_file_accessors
libraries
.
each
do
|
library
|
libraries
.
each
do
|
library
|
...
@@ -275,7 +263,6 @@ module Pod
...
@@ -275,7 +263,6 @@ module Pod
#
#
def
install_pod_sources
def
install_pod_sources
@installed_specs
=
[]
@installed_specs
=
[]
root_specs
=
analyzer
.
specifications
.
map
{
|
spec
|
spec
.
root
}.
uniq
root_specs
.
each
do
|
spec
|
root_specs
.
each
do
|
spec
|
if
names_of_pods_to_install
.
include?
(
spec
.
name
)
if
names_of_pods_to_install
.
include?
(
spec
.
name
)
UI
.
section
(
"Installing
#{
spec
}
"
.
green
,
"-> "
.
green
)
do
UI
.
section
(
"Installing
#{
spec
}
"
.
green
,
"-> "
.
green
)
do
...
@@ -313,6 +300,22 @@ module Pod
...
@@ -313,6 +300,22 @@ module Pod
@installed_specs
.
concat
(
specs_by_platform
.
values
.
flatten
)
@installed_specs
.
concat
(
specs_by_platform
.
values
.
flatten
)
end
end
# Creates the Pods project from scratch if it doesn't exists.
#
# @return [void]
#
# @todo Clean and modify the project if it exists.
#
def
prepare_pods_project
UI
.
message
"- Creating Pods project"
do
@pods_project
=
Pod
::
Project
.
new
(
sandbox
.
project_path
)
if
config
.
podfile_path
.
exist?
@pods_project
.
add_podfile
(
config
.
podfile_path
)
end
sandbox
.
project
=
@pods_project
end
end
# Installs the file references in the Pods project. This is done once per
# Installs the file references in the Pods project. This is done once per
# Pod as the same file reference might be shared by multiple targets.
# Pod as the same file reference might be shared by multiple targets.
...
@@ -353,12 +356,13 @@ module Pod
...
@@ -353,12 +356,13 @@ module Pod
# Writes the Podfile and the lock files.
# Writes the Podfile and the lock files.
#
#
# @todo Pass the checkout options to the Lockfile.
#
# @return [void]
# @return [void]
#
#
def
write_lockfiles
def
write_lockfiles
# checkout_options = sandbox.checkout_options
# checkout_options = sandbox.checkout_options
# TODO pass the options to the Lockfile
@lockfile
=
Lockfile
.
generate
(
podfile
,
analysis_result
.
specifications
)
@lockfile
=
Lockfile
.
generate
(
podfile
,
analyzer
.
specifications
)
UI
.
message
"- Writing Lockfile in
#{
UI
.
path
config
.
lockfile_path
}
"
do
UI
.
message
"- Writing Lockfile in
#{
UI
.
path
config
.
lockfile_path
}
"
do
@lockfile
.
write_to_disk
(
config
.
lockfile_path
)
@lockfile
.
write_to_disk
(
config
.
lockfile_path
)
...
@@ -383,13 +387,13 @@ module Pod
...
@@ -383,13 +387,13 @@ module Pod
#
#
def
integrate_user_project
def
integrate_user_project
installation_root
=
config
.
installation_root
installation_root
=
config
.
installation_root
libraries
=
analyzer
.
libraries
integrator
=
UserProjectIntegrator
.
new
(
podfile
,
sandbox
,
installation_root
,
libraries
)
UserProjectIntegrator
.
new
(
podfile
,
sandbox
,
installation_root
,
libraries
)
.
integrate!
integrator
.
integrate!
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
p
ublic
p
rivate
# @!group Hooks
# @!group Hooks
...
@@ -400,7 +404,7 @@ module Pod
...
@@ -400,7 +404,7 @@ module Pod
def
run_pre_install_hooks
def
run_pre_install_hooks
UI
.
message
"- Running pre install hooks"
do
UI
.
message
"- Running pre install hooks"
do
installed_specs
.
each
do
|
spec
|
installed_specs
.
each
do
|
spec
|
executed
=
spec
.
pre_install!
(
pod_data
(
spec
),
library_data
(
libraries
.
first
))
#
todo
executed
=
spec
.
pre_install!
(
pod_data
(
spec
),
library_data
(
libraries
.
first
))
#
TODO
UI
.
message
"-
#{
spec
.
name
}
"
if
executed
UI
.
message
"-
#{
spec
.
name
}
"
if
executed
end
end
...
@@ -429,6 +433,8 @@ module Pod
...
@@ -429,6 +433,8 @@ module Pod
end
end
end
end
#-------------------------------------------------------------------------#
public
public
# @!group Hooks Data
# @!group Hooks Data
...
@@ -447,8 +453,6 @@ module Pod
...
@@ -447,8 +453,6 @@ module Pod
end
end
def
pods_data
def
pods_data
specs
=
libraries
.
map
(
&
:specs
).
flatten
root_specs
=
specs
.
map
{
|
spec
|
spec
.
root
}.
uniq
root_specs
.
map
do
|
spec
|
root_specs
.
map
do
|
spec
|
pod_data
(
spec
)
pod_data
(
spec
)
end
end
...
@@ -466,5 +470,18 @@ module Pod
...
@@ -466,5 +470,18 @@ module Pod
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
private
# @!group Private helpers
# @return [Array<Specification>] All the root specifications of the
# installation.
#
def
root_specs
analysis_result
.
specifications
.
map
{
|
spec
|
spec
.
root
}.
uniq
end
#-------------------------------------------------------------------------#
end
end
end
end
lib/cocoapods/installer/analyzer.rb
View file @
943ea72d
This diff is collapsed.
Click to expand it.
lib/cocoapods/sandbox.rb
View file @
943ea72d
...
@@ -86,6 +86,19 @@ module Pod
...
@@ -86,6 +86,19 @@ module Pod
root
.
rmtree
root
.
rmtree
end
end
#
#
#
def
clean_pod
(
name
)
root_name
=
Specification
.
root_name
(
name
)
unless
local?
(
root_name
)
path
=
pod_dir
(
name
)
path
.
rmtree
if
path
.
exist?
end
podspe_path
=
specification_path
(
name
)
podspe_path
.
rmtree
if
podspe_path
end
# @return [String] a string representation suitable for debugging.
# @return [String] a string representation suitable for debugging.
#
#
def
inspect
def
inspect
...
...
spec/unit/installer/analyzer_spec.rb
View file @
943ea72d
...
@@ -49,8 +49,7 @@ module Pod
...
@@ -49,8 +49,7 @@ module Pod
#--------------------------------------#
#--------------------------------------#
it
"computes the state of the Podfile respect to the Lockfile"
do
it
"computes the state of the Podfile respect to the Lockfile"
do
@analyzer
.
analyze
state
=
@analyzer
.
analyze
.
podfile_state
state
=
@analyzer
.
podfile_state
state
.
added
.
should
==
[
"AFNetworking"
,
"libextobjc"
]
state
.
added
.
should
==
[
"AFNetworking"
,
"libextobjc"
]
state
.
changed
.
should
==
[
"JSONKit"
]
state
.
changed
.
should
==
[
"JSONKit"
]
state
.
unchanged
.
should
==
[
"SVPullToRefresh"
]
state
.
unchanged
.
should
==
[
"SVPullToRefresh"
]
...
@@ -74,8 +73,7 @@ module Pod
...
@@ -74,8 +73,7 @@ module Pod
#--------------------------------------#
#--------------------------------------#
it
"generates the libraries which represent the target definitions"
do
it
"generates the libraries which represent the target definitions"
do
@analyzer
.
analyze
libs
=
@analyzer
.
analyze
.
libraries
libs
=
@analyzer
.
libraries
libs
.
map
(
&
:name
).
should
==
[
'Pods'
]
libs
.
map
(
&
:name
).
should
==
[
'Pods'
]
lib
=
libs
.
first
lib
=
libs
.
first
lib
.
support_files_root
.
should
==
config
.
sandbox
.
root
lib
.
support_files_root
.
should
==
config
.
sandbox
.
root
...
@@ -90,8 +88,7 @@ module Pod
...
@@ -90,8 +88,7 @@ module Pod
it
"generates configures the library appropriately if the installation will not integrate"
do
it
"generates configures the library appropriately if the installation will not integrate"
do
config
.
integrate_targets
=
false
config
.
integrate_targets
=
false
@analyzer
.
analyze
lib
=
@analyzer
.
analyze
.
libraries
.
first
lib
=
@analyzer
.
libraries
.
first
lib
.
user_project_path
.
should
==
config
.
installation_root
lib
.
user_project_path
.
should
==
config
.
installation_root
lib
.
user_target_uuids
.
should
==
[]
lib
.
user_target_uuids
.
should
==
[]
...
@@ -115,8 +112,7 @@ module Pod
...
@@ -115,8 +112,7 @@ module Pod
#--------------------------------------#
#--------------------------------------#
it
"resolves the dependencies"
do
it
"resolves the dependencies"
do
@analyzer
.
analyze
@analyzer
.
analyze
.
specifications
.
map
(
&
:to_s
).
should
==
[
@analyzer
.
specifications
.
map
(
&
:to_s
).
should
==
[
"AFNetworking (1.0.1)"
,
"AFNetworking (1.0.1)"
,
"JSONKit (1.5pre)"
,
"JSONKit (1.5pre)"
,
"SVPullToRefresh (0.4)"
,
"SVPullToRefresh (0.4)"
,
...
@@ -134,8 +130,7 @@ module Pod
...
@@ -134,8 +130,7 @@ module Pod
end
end
it
"adds the specifications to the correspondent libraries in after the resolution"
do
it
"adds the specifications to the correspondent libraries in after the resolution"
do
@analyzer
.
analyze
@analyzer
.
analyze
.
libraries
.
first
.
specs
.
map
(
&
:to_s
).
should
==
[
@analyzer
.
libraries
.
first
.
specs
.
map
(
&
:to_s
).
should
==
[
"AFNetworking (1.0.1)"
,
"AFNetworking (1.0.1)"
,
"JSONKit (1.5pre)"
,
"JSONKit (1.5pre)"
,
"SVPullToRefresh (0.4)"
,
"SVPullToRefresh (0.4)"
,
...
@@ -169,8 +164,7 @@ module Pod
...
@@ -169,8 +164,7 @@ module Pod
it
"computes the state of the Sandbox respect to the resolved dependencies"
do
it
"computes the state of the Sandbox respect to the resolved dependencies"
do
@analyzer
.
stubs
(
:lockfile
).
returns
(
nil
)
@analyzer
.
stubs
(
:lockfile
).
returns
(
nil
)
@analyzer
.
analyze
state
=
@analyzer
.
analyze
.
sandbox_state
state
=
@analyzer
.
sandbox_state
state
.
added
.
sort
.
should
==
[
"AFNetworking"
,
"JSONKit"
,
"SVPullToRefresh"
,
"libextobjc"
]
state
.
added
.
sort
.
should
==
[
"AFNetworking"
,
"JSONKit"
,
"SVPullToRefresh"
,
"libextobjc"
]
end
end
...
...
spec/unit/installer_spec.rb
View file @
943ea72d
This diff is collapsed.
Click to expand it.
spec/unit/sandbox_spec.rb
View file @
943ea72d
...
@@ -36,6 +36,24 @@ module Pod
...
@@ -36,6 +36,24 @@ module Pod
File
.
directory?
(
temporary_directory
+
'Sandbox'
).
should
.
be
.
false
File
.
directory?
(
temporary_directory
+
'Sandbox'
).
should
.
be
.
false
end
end
it
"cleans any trace of the Pod with the given name"
do
pod_root
=
@sandbox
.
root
+
'BananaLib'
pod_root
.
mkpath
@sandbox
.
store_podspec
(
'BananaLib'
,
fixture
(
'banana-lib/BananaLib.podspec'
))
specification_path
=
@sandbox
.
specification_path
(
'BananaLib'
)
@sandbox
.
clean_pod
(
'BananaLib'
)
pod_root
.
should
.
not
.
exist
specification_path
.
should
.
not
.
exist
end
it
"doesn't remove the root of local Pods while cleaning"
do
pod_root
=
@sandbox
.
root
+
'BananaLib'
@sandbox
.
stubs
(
:local?
).
returns
(
true
)
pod_root
.
mkpath
@sandbox
.
clean_pod
(
'BananaLib'
)
pod_root
.
should
.
exist
end
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