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
d5f4684c
Commit
d5f4684c
authored
Feb 16, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Sandbox] Store information about external sources and local Pods
parent
e4be7bbb
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
277 additions
and
89 deletions
+277
-89
downloader.rb
lib/cocoapods/downloader.rb
+8
-8
external_sources.rb
lib/cocoapods/external_sources.rb
+36
-27
installer.rb
lib/cocoapods/installer.rb
+4
-5
file_references_installer.rb
lib/cocoapods/installer/file_references_installer.rb
+1
-3
pod_source_installer.rb
lib/cocoapods/installer/pod_source_installer.rb
+6
-7
sandbox.rb
lib/cocoapods/sandbox.rb
+92
-16
integration_2.rb
spec/integration_2.rb
+5
-5
external_sources_spec.rb
spec/unit/external_sources_spec.rb
+40
-0
file_references_installer_spec.rb
spec/unit/installer/file_references_installer_spec.rb
+9
-0
pod_source_installer_spec.rb
spec/unit/installer/pod_source_installer_spec.rb
+13
-6
sandbox_spec.rb
spec/unit/sandbox_spec.rb
+63
-12
No files found.
lib/cocoapods/downloader.rb
View file @
d5f4684c
...
...
@@ -10,15 +10,15 @@ module Pod
Executable
.
execute_command
(
executable
,
command
,
raise_on_failure
)
end
# Indicates that an action will be perfomed. The action is passed as a
# Indicates that an action will be perfo
r
med. The action is passed as a
# block.
#
# @param [String] message
# The message associated with the action.
#
# @yield The action, this block is always exec
tu
ed.
# @yield The action, this block is always exec
ut
ed.
#
# @retur [void]
# @retur
n
[void]
#
def
ui_action
(
message
)
UI
.
section
(
" >
#{
message
}
"
,
''
,
1
)
do
...
...
@@ -26,15 +26,15 @@ module Pod
end
end
# Indicates that a minor action will be perfo
med. The action is passed as
# a block.
# Indicates that a minor action will be perfo
rmed. The action is passed
# a
s a
block.
#
# @param [String] message
# The message associated with the action.
#
# @yield The action, this block is always exec
tu
ed.
# @yield The action, this block is always exec
ut
ed.
#
# @retur [void]
# @retur
n
[void]
#
def
ui_sub_action
(
message
)
UI
.
section
(
" >
#{
message
}
"
,
''
,
2
)
do
...
...
@@ -47,7 +47,7 @@ module Pod
# @param [String] message
# The message associated with the action.
#
# @retur [void]
# @retur
n
[void]
#
def
ui_message
(
message
)
UI
.
puts
message
...
...
lib/cocoapods/external_sources.rb
View file @
d5f4684c
...
...
@@ -115,6 +115,10 @@ module Pod
raise
"Abstract method"
end
#--------------------------------------#
# @! Subclasses helpers
private
# Stores a specification in the `Local Podspecs` folder.
...
...
@@ -147,6 +151,31 @@ module Pod
end
end
# Pre-downloads a Pod passing the options to the downloader and informing
# the sandbox.
#
# @param [Sandbox] sandbox
# the sandbox where the Pod should be downloaded.
#
# @return [void]
#
def
pre_download
(
sandbox
)
UI
.
info
(
"->"
.
green
+
" Pre-downloading: `
#{
name
}
`"
)
do
target
=
sandbox
.
root
+
name
target
.
rmtree
if
target
.
exist?
downloader
=
Downloader
.
for_target
(
target
,
@params
)
downloader
.
download
store_podspec
(
sandbox
,
target
+
"
#{
name
}
.podspec"
)
sandbox
.
predownloaded_pods
<<
name
if
downloader
.
options_specific?
source
=
@params
else
source
=
downloader
.
checkout_options
end
sandbox
.
store_checkout_source
(
name
,
source
)
end
end
end
#-------------------------------------------------------------------------#
...
...
@@ -168,14 +197,7 @@ module Pod
# operations are needed.
#
def
copy_external_source_into_sandbox
(
sandbox
)
UI
.
info
(
"->"
.
green
+
" Pre-downloading: `
#{
name
}
`"
)
do
target
=
sandbox
.
root
+
name
target
.
rmtree
if
target
.
exist?
downloader
=
Downloader
.
for_target
(
sandbox
.
root
+
name
,
@params
)
downloader
.
download
store_podspec
(
sandbox
,
target
+
"
#{
name
}
.podspec"
)
sandbox
.
predownloaded_pods
<<
name
end
pre_download
(
sandbox
)
end
# @see AbstractExternalSource#description
...
...
@@ -191,7 +213,7 @@ module Pod
#-------------------------------------------------------------------------#
# Provides support for fetching a specification file from a S
vn
source
# Provides support for fetching a specification file from a S
VN
source
# remote.
#
# Supports all the options of the downloader (is similar to the git key of
...
...
@@ -209,14 +231,7 @@ module Pod
# operations are needed.
#
def
copy_external_source_into_sandbox
(
sandbox
)
UI
.
info
(
"->"
.
green
+
" Pre-downloading: `
#{
name
}
`"
)
do
target
=
sandbox
.
root
+
name
target
.
rmtree
if
target
.
exist?
downloader
=
Downloader
.
for_target
(
target
,
@params
)
downloader
.
download
store_podspec
(
sandbox
,
target
+
"
#{
name
}
.podspec"
)
sandbox
.
predownloaded_pods
<<
name
end
pre_download
(
sandbox
)
end
# @see AbstractExternalSource#description
...
...
@@ -232,8 +247,8 @@ module Pod
#-------------------------------------------------------------------------#
# Provides support for fetching a specification file from a
Svn source
# remote.
# Provides support for fetching a specification file from a
Mercurial
#
source
remote.
#
# Supports all the options of the downloader (is similar to the git key of
# `source` attribute of a specification).
...
...
@@ -250,14 +265,7 @@ module Pod
# operations are needed.
#
def
copy_external_source_into_sandbox
(
sandbox
)
UI
.
info
(
"->"
.
green
+
" Pre-downloading: `
#{
name
}
`"
)
do
target
=
sandbox
.
root
+
name
target
.
rmtree
if
target
.
exist?
downloader
=
Downloader
.
for_target
(
target
,
@params
)
downloader
.
download
store_podspec
(
sandbox
,
target
+
"
#{
name
}
.podspec"
)
sandbox
.
predownloaded_pods
<<
name
end
pre_download
(
sandbox
)
end
# @see AbstractExternalSource#description
...
...
@@ -307,6 +315,7 @@ module Pod
#
def
copy_external_source_into_sandbox
(
sandbox
)
store_podspec
(
sandbox
,
pod_spec_path
)
sandbox
.
store_local_path
(
name
,
@params
[
:local
])
end
# @see AbstractExternalSource#description
...
...
lib/cocoapods/installer.rb
View file @
d5f4684c
...
...
@@ -303,11 +303,8 @@ module Pod
specs_by_platform
[
library
.
platform
].
concat
(
specs
)
end
end
pod_installer
=
PodSourceInstaller
.
new
(
sandbox
,
specs_by_platform
)
root_spec
=
specs_by_platform
.
values
.
flatten
.
first
.
root
local_path
=
root_spec
.
source
[
:local
]
pod_installer
.
local_path
=
Pathname
.
new
(
local_path
).
expand_path
if
local_path
# TODO
pod_installer
=
PodSourceInstaller
.
new
(
sandbox
,
specs_by_platform
)
pod_installer
.
clean
=
config
.
clean?
pod_installer
.
aggressive_cache
=
config
.
aggressive_cache?
pod_installer
.
generate_docs
=
config
.
generate_docs?
...
...
@@ -416,6 +413,8 @@ module Pod
# @return [void]
#
def
write_lockfiles
# checkout_options = sandbox.checkout_options
# TODO pass the options to the Lockfile
@lockfile
=
Lockfile
.
generate
(
podfile
,
analyzer
.
specifications
)
UI
.
message
"- Writing Lockfile in
#{
UI
.
path
config
.
lockfile_path
}
"
do
...
...
@@ -429,7 +428,7 @@ module Pod
# Integrates the user projects adding the dependencies on the CocoaPods
# libraries, setting them up to use the xcconfigs and performing other
# actions. This step is also reponsible of creating the workspace if
# actions. This step is also re
s
ponsible of creating the workspace if
# needed.
#
# @return [void]
...
...
lib/cocoapods/installer/file_references_installer.rb
View file @
d5f4684c
...
...
@@ -60,10 +60,8 @@ module Pod
file_accessors
.
each
do
|
file_accessor
|
files
=
file_accessor
.
source_files
spec_name
=
file_accessor
.
spec
.
name
local
=
file_accessor
.
spec
.
local?
local
=
sandbox
.
local?
(
file_accessor
.
spec
.
root
.
name
)
parent_group
=
local
?
pods_project
.
local_pods
:
pods_project
.
pods
parent_group
=
pods_project
.
pods
pods_project
.
add_file_references
(
files
,
spec_name
,
parent_group
)
end
end
...
...
lib/cocoapods/installer/pod_source_installer.rb
View file @
d5f4684c
...
...
@@ -42,11 +42,6 @@ module Pod
# @!group Configuration
# @return [Pathname] the path of the source of the Pod if using the
# `:local` option.
#
attr_accessor
:local_path
# @return [Bool] whether the file not used by CocoaPods should be
# removed.
#
...
...
@@ -117,6 +112,10 @@ module Pod
@specific_source
=
downloader
.
checkout_options
end
end
if
specific_source
sandbox
.
store_checkout_source
(
root_spec
.
name
,
specific_source
)
end
end
# Generates the documentation for the Pod.
...
...
@@ -202,7 +201,7 @@ module Pod
# @return [Pathname] the folder where the source of the Pod is located.
#
def
root
local?
?
local_path
:
sandbox
.
pod_dir
(
root_spec
.
name
)
sandbox
.
pod_dir
(
root_spec
.
name
)
end
# @return [Boolean] whether the source has been pre downloaded in the
...
...
@@ -216,7 +215,7 @@ module Pod
# CocoaPods should not interfere with the files of the user.
#
def
local?
!
local_path
.
nil?
sandbox
.
local?
(
root_spec
.
name
)
end
#-----------------------------------------------------------------------#
...
...
lib/cocoapods/sandbox.rb
View file @
d5f4684c
...
...
@@ -60,6 +60,8 @@ module Pod
@build_headers
=
HeadersStore
.
new
(
self
,
"BuildHeaders"
)
@public_headers
=
HeadersStore
.
new
(
self
,
"Headers"
)
@predownloaded_pods
=
[]
@checkout_sources
=
{}
@local_pods
=
{}
FileUtils
.
mkdir_p
(
@root
)
end
...
...
@@ -134,18 +136,6 @@ module Pod
root
+
"Pods.xcodeproj"
end
# Returns the path for the Pod with the given name.
#
# @param [String] name
# The name of the Pod.
#
# @return [Pathname] the path of the Pod.
#
def
pod_dir
(
name
)
# root + "Sources/#{name}"
root
+
name
end
# Returns the path for the directory where to store the support files of
# a target.
#
...
...
@@ -180,9 +170,9 @@ module Pod
path
.
exist?
?
path
:
nil
end
#--------------------------------------#
#--------------------------------------
-----------------------------------
#
# @!group Pods
Installation
# @!group Pods
storage & source
# Returns the specification for the Pod with the given name.
#
...
...
@@ -197,14 +187,100 @@ module Pod
end
end
# @return [Array<String>] the names of the pods that have been
# Returns the path where the Pod with the given name is stored, taking into
# account whether the Pod is locally sourced.
#
# @param [String] name
# The name of the Pod.
#
# @return [Pathname] the path of the Pod.
#
def
pod_dir
(
name
)
root_name
=
Specification
.
root_name
(
name
)
if
local?
(
root_name
)
Pathname
.
new
(
local_pods
[
root_name
])
else
# root + "Sources/#{name}"
root
+
root_name
end
end
#--------------------------------------#
# @return [Array<String>] The names of the pods that have been
# pre-downloaded from an external source.
#
attr_reader
:predownloaded_pods
#-------------------------------------------------------------------------#
# Checks if a Pod has been pre-downloaded by the resolver in order to fetch
# the podspec.
#
# @param [String] name
# The name of the Pod.
#
# @return [Bool] Whether the Pod has been pre-downloaded.
#
def
predownloaded?
(
name
)
root_name
=
Specification
.
root_name
(
name
)
predownloaded_pods
.
include?
(
root_name
)
end
#--------------------------------------#
# Stores the local path of a Pod.
#
# @param [String] name
# The name of the Pod.
#
# @param [Hash] source
# The hash which contains the options as returned by the
# downloader.
#
# @return [void]
#
def
store_checkout_source
(
name
,
source
)
root_name
=
Specification
.
root_name
(
name
)
checkout_sources
[
root_name
]
=
source
end
# @return [Hash{String=>Hash}] The options necessary to recreate the exact
# checkout of a given Pod grouped by its name.
#
attr_reader
:checkout_sources
#--------------------------------------#
# Stores the local path of a Pod.
#
# @param [String] name
# The name of the Pod.
#
# @param [#to_s] path
# The local path where the Pod is stored.
#
# @return [void]
#
def
store_local_path
(
name
,
path
)
root_name
=
Specification
.
root_name
(
name
)
local_pods
[
root_name
]
=
path
.
to_s
end
# @return [Hash{String=>String}] The path of the Pods with a local source
# grouped by their name.
#
attr_reader
:local_pods
# Checks if a Pod is locally sourced?
#
# @param [String] name
# The name of the Pod.
#
# @return [Bool] Whether the Pod is locally sourced.
#
def
local?
(
name
)
root_name
=
Specification
.
root_name
(
name
)
!
local_pods
[
root_name
].
nil?
end
#-------------------------------------------------------------------------#
...
...
spec/integration_2.rb
View file @
d5f4684c
...
...
@@ -267,18 +267,18 @@ end
# Performs the checks for the test with the given folder using the given
# arguments.
#
# @par
ma
[String] arguments
# @par
am
[String] arguments
# The arguments to pass to the Pod executable.
#
# @par
ma
[String] folder
# @par
am
[String] folder
# The name of the folder which contains the `before` and `after`
# subfolders.
#
def
check
(
arguments
,
folder
)
#
focused_check(arguments, folder)
focused_check
(
arguments
,
folder
)
end
# Shortcut to focus on a test: Comment the implmentation of #check and
# Shortcut to focus on a test: Comment the impl
e
mentation of #check and
# call this from the relevant test.
#
def
focused_check
(
arguments
,
folder
)
...
...
@@ -324,7 +324,7 @@ describe "Integration take 2" do
end
describe
"Installs a Pod with a local source"
do
focused_
check
"install --no-update --no-doc"
,
"install_local_source"
check
"install --no-update --no-doc"
,
"install_local_source"
end
describe
"Installs a Pod with an external source"
do
...
...
spec/unit/external_sources_spec.rb
View file @
d5f4684c
...
...
@@ -57,6 +57,35 @@ module Pod
it
"returns the specification fetching it from the external source in any case"
do
@external_source
.
specification_from_external
(
config
.
sandbox
).
name
.
should
==
'Reachability'
end
#--------------------------------------#
describe
"Subclasses helpers"
do
it
"stores the podspec in the sandbox"
do
sandbox
=
config
.
sandbox
podspec_path
=
fixture
(
'integration/Reachability/Reachability.podspec'
)
@external_source
.
send
(
:store_podspec
,
sandbox
,
podspec_path
)
path
=
config
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
.
should
.
exist?
end
it
"pre-downloads the Pod and store the relevant information in the sandbox"
do
sandbox
=
config
.
sandbox
@external_source
.
send
(
:pre_download
,
sandbox
)
path
=
config
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
.
should
.
exist?
sandbox
.
predownloaded_pods
.
should
==
[
"Reachability"
]
sandbox
.
checkout_sources
.
should
==
{
"Reachability"
=>
{
:git
=>
fixture
(
'integration/Reachability'
),
:commit
=>
"4ec575e4b074dcc87c44018cce656672a979b34a"
}
}
end
end
end
#---------------------------------------------------------------------------#
...
...
@@ -174,5 +203,16 @@ module Pod
it
"returns the description"
do
@external_source
.
description
.
should
.
match
%r|from `.*integration/Reachability`|
end
it
"marks the Pod as local in the sandbox"
do
@external_source
.
copy_external_source_into_sandbox
(
config
.
sandbox
)
config
.
sandbox
.
local_pods
.
should
==
{
"Reachability"
=>
fixture
(
'integration/Reachability'
).
to_s
}
end
end
#---------------------------------------------------------------------------#
end
spec/unit/installer/file_references_installer_spec.rb
View file @
d5f4684c
...
...
@@ -24,6 +24,15 @@ module Pod
file_ref
.
path
.
should
==
"../../spec/fixtures/banana-lib/Classes/Banana.m"
end
it
"adds the files references of the local Pods in a dedicated group"
do
config
.
sandbox
.
store_local_path
(
'BananaLib'
,
'Some Path'
)
@installer
.
install!
group_ref
=
@installer
.
pods_project
[
'Local Pods/BananaLib'
]
group_ref
.
should
.
be
.
not
.
nil
file_ref
=
@installer
.
pods_project
[
'Local Pods/BananaLib/Banana.m'
]
file_ref
.
should
.
be
.
not
.
nil
end
it
"adds the files references of the resources the Pods project"
do
@installer
.
install!
group_ref
=
@installer
.
pods_project
[
'Resources/BananaLib'
]
...
...
spec/unit/installer/pod_source_installer_spec.rb
View file @
d5f4684c
...
...
@@ -62,6 +62,17 @@ module Pod
pod_folder
.
should
.
exist
end
it
"stores the checkout options in the sandbox"
do
@spec
.
version
.
head
=
true
@spec
.
source
=
{
:git
=>
SpecHelper
.
fixture
(
'banana-lib'
),
:tag
=>
'v1.0'
}
@installer
.
install!
sources
=
@installer
.
sandbox
.
checkout_sources
sources
.
should
==
{
"BananaLib"
=>
{
:git
=>
SpecHelper
.
fixture
(
'banana-lib'
),
:commit
=>
"0b8b4084a43c38cfe308efa076fdeb3a64d9d2bc"
}
}
end
end
#--------------------------------------#
...
...
@@ -124,22 +135,18 @@ module Pod
@installer
.
stubs
(
:predownloaded?
).
returns
(
true
)
@installer
.
expects
(
:download_source
).
never
@installer
.
stubs
(
:clean_installation
)
@installer
.
stubs
(
:link_headers
)
@installer
.
install!
end
it
"doesn't downloads the source if the pod has a local source"
do
@installer
.
local_path
=
'Some Path'
config
.
sandbox
.
store_local_path
(
'BananaLib'
,
'Some Path'
)
@installer
.
expects
(
:download_source
).
never
@installer
.
stubs
(
:clean_installation
)
@installer
.
stubs
(
:link_headers
)
@installer
.
install!
end
it
"doesn't clean the installation if the pod has a local source"
do
@installer
.
local_path
=
'Some Path'
config
.
sandbox
.
store_local_path
(
'BananaLib'
,
'Some Path'
)
@installer
.
expects
(
:clean_installation
).
never
@installer
.
stubs
(
:link_headers
)
@installer
.
install!
end
...
...
spec/unit/sandbox_spec.rb
View file @
d5f4684c
...
...
@@ -64,10 +64,6 @@ module Pod
@sandbox
.
project_path
.
should
==
temporary_directory
+
'Sandbox/Pods.xcodeproj'
end
it
"returns the path for a Pod"
do
@sandbox
.
pod_dir
(
'JSONKit'
).
should
==
temporary_directory
+
'Sandbox/JSONKit'
end
it
"returns the directory for the support files of a library"
do
@sandbox
.
library_support_files_dir
(
'Pods'
).
should
==
temporary_directory
+
'Sandbox'
end
...
...
@@ -84,15 +80,70 @@ module Pod
#-------------------------------------------------------------------------#
it
"loads the stored specification with the given name"
do
(
@sandbox
.
root
+
'Local Podspecs'
).
mkdir
FileUtils
.
cp
(
fixture
(
'banana-lib/BananaLib.podspec'
),
@sandbox
.
root
+
'Local Podspecs'
)
@sandbox
.
specification
(
'BananaLib'
).
name
.
should
==
'BananaLib'
end
describe
"Pods storage & source"
do
it
"loads the stored specification with the given name"
do
(
@sandbox
.
root
+
'Local Podspecs'
).
mkdir
FileUtils
.
cp
(
fixture
(
'banana-lib/BananaLib.podspec'
),
@sandbox
.
root
+
'Local Podspecs'
)
@sandbox
.
specification
(
'BananaLib'
).
name
.
should
==
'BananaLib'
end
it
"returns the directory where a Pod is stored"
do
@sandbox
.
pod_dir
(
'JSONKit'
).
should
==
temporary_directory
+
'Sandbox/JSONKit'
end
it
"returns the directory where a local Pod is stored"
do
@sandbox
.
store_local_path
(
'BananaLib'
,
Pathname
.
new
(
'Some Path'
))
@sandbox
.
pod_dir
(
'BananaLib'
).
should
.
be
==
Pathname
.
new
(
'Some Path'
)
end
#--------------------------------------#
it
"stores the list of the names of the pre-downloaded pods"
do
@sandbox
.
predownloaded_pods
<<
'BananaLib'
@sandbox
.
predownloaded_pods
.
should
==
[
'BananaLib'
]
end
it
"returns whether a Pod has been pre-downloaded"
do
@sandbox
.
predownloaded_pods
<<
'BananaLib'
@sandbox
.
predownloaded?
(
'BananaLib'
).
should
.
be
.
true
@sandbox
.
predownloaded?
(
'BananaLib/Subspec'
).
should
.
be
.
true
@sandbox
.
predownloaded?
(
'Monkey'
).
should
.
be
.
false
end
#--------------------------------------#
it
"stores the checkout source of a Pod"
do
source
=
{
:git
=>
'example.com'
,
:commit
=>
'SHA'
}
@sandbox
.
store_checkout_source
(
'BananaLib/Subspec'
,
source
)
@sandbox
.
checkout_sources
[
'BananaLib'
].
should
==
source
end
it
"returns the checkout sources of the Pods"
do
source
=
{
:git
=>
'example.com'
,
:commit
=>
'SHA'
}
@sandbox
.
store_checkout_source
(
'BananaLib'
,
source
)
@sandbox
.
checkout_sources
.
should
==
{
'BananaLib'
=>
source
}
end
#--------------------------------------#
it
"stores the local path of a Pod"
do
@sandbox
.
store_local_path
(
'BananaLib/Subspec'
,
Pathname
.
new
(
'Some Path'
))
@sandbox
.
local_pods
[
'BananaLib'
].
should
==
'Some Path'
end
it
"returns the path of the local pods grouped by name"
do
@sandbox
.
store_local_path
(
'BananaLib'
,
'Some Path'
)
@sandbox
.
local_pods
.
should
==
{
'BananaLib'
=>
'Some Path'
}
end
it
"returns whether a Pod is local"
do
@sandbox
.
store_local_path
(
'BananaLib'
,
Pathname
.
new
(
'Some Path'
))
@sandbox
.
local?
(
'BananaLib'
).
should
.
be
.
true
@sandbox
.
local?
(
'BananaLib/Subspec'
).
should
.
be
.
true
@sandbox
.
local?
(
'Monkey'
).
should
.
be
.
false
end
it
"stores the list of the names of the pre-downloaded pods"
do
@sandbox
.
predownloaded_pods
<<
'JSONKit'
@sandbox
.
predownloaded_pods
.
should
==
[
'JSONKit'
]
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