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
dcc87e5e
Commit
dcc87e5e
authored
Apr 06, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Cache] Add specs for response for uncached pod
parent
d0ef6973
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
13 deletions
+43
-13
cache.rb
lib/cocoapods/downloader/cache.rb
+5
-4
request.rb
lib/cocoapods/downloader/request.rb
+3
-4
cache_spec.rb
spec/unit/downloader/cache_spec.rb
+34
-4
request_spec.rb
spec/unit/downloader/request_spec.rb
+1
-1
No files found.
lib/cocoapods/downloader/cache.rb
View file @
dcc87e5e
...
...
@@ -80,17 +80,18 @@ module Pod
result
.
checkout_options
=
download
(
request
.
name
,
target
,
request
.
params
,
request
.
head?
)
if
request
.
released_pod?
result
.
spec
=
request
.
spec
result
.
location
=
destination
=
path_for_pod
(
request
,
:params
=>
result
.
checkout_options
)
copy_and_clean
(
target
,
destination
,
request
.
spec
)
write_spec
(
request
.
spec
,
path_for_spec
(
request
,
:params
=>
result
.
checkout_options
))
else
podspecs
=
Sandbox
::
PodspecFinder
.
new
(
target
).
podspecs
podspecs
[
request
.
name
]
=
request
.
spec
if
request
.
spec
podspecs
.
each
do
|
_
,
spec
|
destination
=
path_for_pod
(
request
,
:name
=>
spec
.
name
,
:params
=>
result
.
checkout_options
)
podspecs
.
each
do
|
name
,
spec
|
destination
=
path_for_pod
(
request
,
:name
=>
name
,
:params
=>
result
.
checkout_options
)
copy_and_clean
(
target
,
destination
,
spec
)
write_spec
(
spec
,
path_for_spec
(
request
,
:name
=>
spec
.
name
,
:params
=>
result
.
checkout_options
))
if
request
.
name
==
spec
.
name
write_spec
(
spec
,
path_for_spec
(
request
,
:name
=>
name
,
:params
=>
result
.
checkout_options
))
if
request
.
name
==
name
result
.
location
=
destination
result
.
spec
=
spec
end
...
...
lib/cocoapods/downloader/request.rb
View file @
dcc87e5e
...
...
@@ -26,7 +26,6 @@ module Pod
attr_reader
:head
alias_method
:head?
,
:head
# @param [Specification,Nil] spec
# see {#spec}
#
...
...
@@ -61,13 +60,13 @@ module Pod
# @return [String] The slug used to store the files resulting from this
# download request.
#
def
slug
(
name:
self
.
name
,
params:
self
.
params
)
def
slug
(
name:
self
.
name
,
params:
self
.
params
,
spec:
self
.
spec
)
checksum
=
spec
&&
spec
.
checksum
&&
'-'
<<
spec
.
checksum
[
0
,
5
]
if
released_pod?
checksum
=
spec
.
checksum
&&
'-'
<<
spec
.
checksum
[
0
,
5
]
"Release/
#{
name
}
/
#{
spec
.
version
}#{
checksum
}
"
else
opts
=
params
.
to_a
.
sort_by
(
&
:first
).
map
{
|
k
,
v
|
"
#{
k
}
=
#{
v
}
"
}.
join
(
'-'
).
gsub
(
/(
#{
Regexp
.
escape
File
::
SEPARATOR
}
)+/
,
'+'
)
"External/
#{
name
}
/
#{
opts
}
"
"External/
#{
name
}
/
#{
opts
}
#{
checksum
}
"
end
end
...
...
spec/unit/downloader/cache_spec.rb
View file @
dcc87e5e
...
...
@@ -7,6 +7,12 @@ module Pod
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@spec
.
source
=
{
:git
=>
SpecHelper
.
fixture
(
'banana-lib'
)
}
@request
=
Downloader
::
Request
.
new
(
:spec
=>
@spec
,
:released
=>
true
)
@stub_download
=
lambda
do
|
cache
,
&
blk
|
cache
.
define_singleton_method
(
:download
)
do
|
name
,
target
,
params
,
head
|
FileUtils
.
mkdir_p
target
Dir
.
chdir
(
target
)
{
blk
.
call
}
end
end
end
it
'returns the root'
do
...
...
@@ -14,13 +20,37 @@ module Pod
end
describe
'when the download is not cached'
do
it
'downloads the source'
do
Downloader
::
Git
.
any_instance
.
expects
(
:download
)
Downloader
::
Git
.
any_instance
.
expects
(
:checkout_options
).
returns
(
@spec
.
source
)
@cache
.
download_pod
(
@request
)
describe
'when downloading a released pod'
do
it
'downloads the source'
do
Downloader
::
Git
.
any_instance
.
expects
(
:download
)
Downloader
::
Git
.
any_instance
.
expects
(
:checkout_options
).
returns
(
@spec
.
source
)
response
=
@cache
.
download_pod
(
@request
)
response
.
should
==
Downloader
::
Response
.
new
(
@cache
.
root
+
@request
.
slug
,
@spec
,
@spec
.
source
)
end
end
describe
'when downloading an un-released pod'
do
before
do
@request
=
Downloader
::
Request
.
new
(
:name
=>
'BananaLib'
,
:params
=>
@spec
.
source
)
@stub_download
.
call
@cache
do
File
.
open
(
'BananaLib.podspec.json'
,
'w'
)
{
|
f
|
f
<<
@spec
.
to_pretty_json
}
File
.
open
(
'OrangeLib.podspec.json'
,
'w'
)
{
|
f
|
f
<<
@spec
.
to_pretty_json
.
sub
(
/"name": "BananaLib"/
,
'"name": "OrangeLib"'
)
}
@spec
.
source
end
end
it
'downloads the source'
do
@cache
.
expects
(
:copy_and_clean
).
twice
response
=
@cache
.
download_pod
(
@request
)
response
.
should
==
Downloader
::
Response
.
new
(
@cache
.
root
+
@request
.
slug
,
@spec
,
@spec
.
source
)
end
end
end
describe
'when the download is cached'
do
end
after
do
@cache
.
root
.
rmtree
end
...
...
spec/unit/downloader/request_spec.rb
View file @
dcc87e5e
...
...
@@ -9,7 +9,7 @@ module Pod
#--------------------------------------#
describe
'Validation'
do
it
"validates request initialization"
do
it
'validates request initialization'
do
options
=
[
{
:spec
=>
nil
,
:name
=>
nil
},
{
:spec
=>
nil
,
:released
=>
true
},
...
...
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