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
8fbb7d55
Commit
8fbb7d55
authored
Apr 02, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Downloader] Introduce the notion of a download request
parent
e733b78c
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
59 deletions
+98
-59
.rubocop.yml
.rubocop.yml
+3
-0
downloader.rb
lib/cocoapods/downloader.rb
+7
-9
cache.rb
lib/cocoapods/downloader/cache.rb
+26
-48
request.rb
lib/cocoapods/downloader/request.rb
+45
-0
abstract_external_source.rb
lib/cocoapods/external_sources/abstract_external_source.rb
+8
-1
pod_source_installer.rb
lib/cocoapods/installer/pod_source_installer.rb
+9
-1
No files found.
.rubocop.yml
View file @
8fbb7d55
...
...
@@ -4,6 +4,9 @@ inherit_from:
#- CocoaPods ------------------------------------------------------------------
ParameterLists
:
CountKeywordArgs
:
false
AllCops
:
Exclude
:
-
spec/fixtures/**/*.rb
...
...
lib/cocoapods/downloader.rb
View file @
8fbb7d55
...
...
@@ -6,21 +6,19 @@ require 'tmpdir'
module
Pod
module
Downloader
require
'cocoapods/downloader/cache'
require
'cocoapods/downloader/request'
def
self
.
download
(
name_or_spec
,
download_target
,
released:
false
,
downloader_options:
nil
,
head:
false
,
request
,
target
,
cache_path:
!
Config
.
instance
.
skip_download_cache
&&
Config
.
instance
.
cache_root
+
'Pods'
)
cache_path
,
tmp_cache
=
Pathname
(
Dir
.
mktmpdir
),
true
unless
cache_path
cache
=
Cache
.
new
(
cache_path
)
result
=
cache
.
download_pod
(
name_or_spec
,
released
,
downloader_options
,
head
)
if
download_
target
FileUtils
.
rm_rf
download_
target
FileUtils
.
cp_r
(
result
.
location
,
download_
target
)
result
=
cache
.
download_pod
(
request
)
if
target
FileUtils
.
rm_rf
target
FileUtils
.
cp_r
(
result
.
location
,
target
)
end
result
ensure
...
...
lib/cocoapods/downloader/cache.rb
View file @
8fbb7d55
...
...
@@ -13,79 +13,57 @@ module Pod
root
.
mkpath
unless
root
.
exist?
end
def
download_pod
(
name_or_spec
,
released
=
false
,
downloader_opts
=
nil
,
head
=
false
)
spec
=
nil
if
name_or_spec
.
is_a?
Pod
::
Specification
spec
=
name_or_spec
.
root
name
,
version
,
downloader_opts
=
spec
.
name
,
spec
.
version
,
spec
.
source
.
dup
else
name
=
Specification
.
root_name
(
name_or_spec
.
to_s
)
end
raise
ArgumentError
,
'Must give spec for a released download.'
if
released
&&
!
spec
result
=
cached_pod
(
name
,
spec
,
released
&&
version
,
!
released
&&
downloader_opts
)
result
||
uncached_pod
(
name
,
spec
,
released
,
version
,
downloader_opts
,
head
)
def
download_pod
(
request
)
cached_pod
(
request
)
||
uncached_pod
(
request
)
rescue
Informative
raise
rescue
UI
.
notice
(
"Error installing
#{
name
}
"
)
UI
.
notice
(
"Error installing
#{
request
.
name
}
"
)
raise
end
private
def
cache_key
(
pod_name
,
version
=
nil
,
downloader_opts
=
nil
)
raise
ArgumentError
,
"Need a pod name (
#{
pod_name
}
), and either a version (
#{
version
}
) or downloader options (
#{
downloader_opts
}
)."
unless
pod_name
&&
(
version
||
downloader_opts
)
&&
!
(
version
&&
downloader_opts
)
if
version
"Release/
#{
pod_name
}
/
#{
version
}
"
elsif
downloader_opts
opts
=
downloader_opts
.
to_a
.
sort_by
(
&
:first
).
map
{
|
k
,
v
|
"
#{
k
}
=
#{
v
}
"
}.
join
(
'-'
).
gsub
(
/
#{
File
::
SEPARATOR
}
+/
,
'+'
)
"External/
#{
pod_name
}
/
#{
opts
}
"
end
end
def
path_for_pod
(
name
,
version
=
nil
,
downloader_opts
=
nil
)
root
+
cache_key
(
name
,
version
,
downloader_opts
)
def
path_for_pod
(
request
)
root
+
request
.
slug
end
def
path_for_spec
(
name
,
version
=
nil
,
downloader_opts
=
nil
)
path
=
root
+
'Specs'
+
cache_key
(
name
,
version
,
downloader_opts
)
def
path_for_spec
(
request
)
path
=
root
+
'Specs'
+
request
.
slug
path
.
sub_ext
(
'.podspec.json'
)
end
def
cached_pod
(
name
,
spec
,
version
,
downloader_opts
)
path
=
path_for_pod
(
name
,
version
,
downloader_opts
)
spec
||=
cached_spec
(
name
,
version
,
downloader_opts
)
def
cached_pod
(
request
)
path
=
path_for_pod
(
request
)
spec
=
request
.
spec
||
cached_spec
(
request
)
return
unless
spec
&&
path
.
directory?
Result
.
new
(
path
,
spec
,
downloader_opt
s
)
Result
.
new
(
path
,
spec
,
request
.
param
s
)
end
def
cached_spec
(
name
,
version
,
downloader_opts
)
path
=
path_for_spec
(
name
,
version
,
downloader_opts
)
def
cached_spec
(
request
)
path
=
path_for_spec
(
request
)
path
.
file?
&&
Specification
.
from_file
(
path
)
end
def
uncached_pod
(
name
,
spec
,
released
,
version
,
downloader_opts
,
head
)
def
uncached_pod
(
request
)
in_tmpdir
do
|
target
|
result
=
Result
.
new
result
.
checkout_options
=
download
(
name
,
target
,
downloader_opts
,
head
)
result
.
checkout_options
=
download
(
request
.
name
,
target
,
request
.
params
,
request
.
head?
)
if
re
leased
result
.
location
=
destination
=
path_for_pod
(
name
,
version
)
copy_and_clean
(
target
,
destination
,
spec
)
write_spec
spec
,
path_for_spec
(
name
,
version
)
if
re
quest
.
released_pod?
result
.
location
=
destination
=
path_for_pod
(
request
)
copy_and_clean
(
target
,
destination
,
request
.
spec
)
write_spec
(
request
.
spec
,
path_for_spec
(
request
)
)
else
podspecs
=
Sandbox
::
PodspecFinder
.
new
(
target
).
podspecs
podspecs
[
name
]
=
spec
if
spec
podspecs
.
each
do
|
_
,
found_
spec
|
destination
=
path_for_pod
(
found_spec
.
name
,
nil
,
result
.
checkout_options
)
copy_and_clean
(
target
,
destination
,
found_
spec
)
write_spec
found_spec
,
path_for_spec
(
found_spec
.
name
,
nil
,
result
.
checkout_options
)
if
name
==
found_
spec
.
name
podspecs
[
request
.
name
]
=
request
.
spec
if
request
.
spec
podspecs
.
each
do
|
_
,
spec
|
destination
=
path_for_pod
(
request
)
copy_and_clean
(
target
,
destination
,
spec
)
write_spec
(
spec
,
path_for_spec
(
request
)
)
if
request
.
name
==
spec
.
name
result
.
location
=
destination
result
.
spec
=
found_
spec
result
.
spec
=
spec
end
end
end
...
...
lib/cocoapods/downloader/request.rb
0 → 100644
View file @
8fbb7d55
module
Pod
module
Downloader
class
Request
attr_reader
:released_pod
alias_method
:released_pod?
,
:released_pod
attr_reader
:spec
attr_reader
:head
alias_method
:head?
,
:head
attr_reader
:params
attr_reader
:name
def
initialize
(
spec:
nil
,
released:
false
,
name:
nil
,
version:
nil
,
params:
false
,
head:
false
)
@released_pod
=
released
@spec
=
spec
@params
=
spec
?
spec
.
source
.
dup
:
params
@name
=
spec
?
spec
.
name
:
name
@head
=
head
validate!
end
def
slug
if
released_pod?
"Release/
#{
name
}
/
#{
spec
.
version
}
"
else
opts
=
params
.
to_a
.
sort_by
(
&
:first
).
map
{
|
k
,
v
|
"
#{
k
}
=
#{
v
}
"
}.
join
(
'-'
).
gsub
(
/
#{
Regexp
.
escape
File
::
SEPARATOR
}
+/
,
'+'
)
"External/
#{
name
}
/
#{
opts
}
"
end
end
private
def
validate!
raise
ArgumentError
,
'Requires a name'
unless
name
raise
ArgumentError
,
'Requires a version if released'
if
released_pod?
&&
!
spec
.
version
raise
ArgumentError
,
'Requires params'
unless
params
raise
ArgumentError
,
'Must give a spec for a released download request'
if
released_pod?
&&
!
spec
end
end
end
end
lib/cocoapods/external_sources/abstract_external_source.rb
View file @
8fbb7d55
...
...
@@ -98,7 +98,7 @@ module Pod
title
=
"Pre-downloading: `
#{
name
}
`
#{
description
}
"
UI
.
titled_section
(
title
,
:verbose_prefix
=>
'-> '
)
do
target
=
sandbox
.
pod_dir
(
name
)
download_result
=
Downloader
.
download
(
name
,
target
,
:downloader_options
=>
params
)
download_result
=
Downloader
.
download
(
download_request
,
target
)
spec
=
download_result
.
spec
raise
Informative
,
"Unable to find a specification for '
#{
name
}
'."
unless
spec
...
...
@@ -109,6 +109,13 @@ module Pod
end
end
def
download_request
Downloader
::
Request
.
new
(
name:
name
,
params:
params
)
end
# Stores the podspec in the sandbox and marks it as from an external
# source.
#
...
...
lib/cocoapods/installer/pod_source_installer.rb
View file @
8fbb7d55
...
...
@@ -74,13 +74,21 @@ module Pod
# @return [void]
#
def
download_source
download_result
=
Downloader
.
download
(
root_spec
,
root
,
:released
=>
released?
,
:head
=>
head_pod?
)
download_result
=
Downloader
.
download
(
download_request
,
root
)
if
(
@specific_source
=
download_result
.
checkout_options
)
&&
specific_source
!=
root_spec
.
source
sandbox
.
store_checkout_source
(
root_spec
.
name
,
specific_source
)
end
end
def
download_request
Downloader
::
Request
.
new
(
spec:
root_spec
,
released:
released?
,
head:
head_pod?
,
)
end
extend
Executable
executable
:bash
...
...
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