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
2fdac707
Commit
2fdac707
authored
May 16, 2015
by
Olivier Halligon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved Command::Cache#cache_info_per_pod to Downloader::Cache#cache_descriptors_per_pod
parent
d2744135
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
55 deletions
+59
-55
cache.rb
lib/cocoapods/command/cache.rb
+3
-32
clean.rb
lib/cocoapods/command/cache/clean.rb
+16
-16
list.rb
lib/cocoapods/command/cache/list.rb
+7
-7
cache.rb
lib/cocoapods/downloader/cache.rb
+33
-0
No files found.
lib/cocoapods/command/cache.rb
View file @
2fdac707
...
...
@@ -14,43 +14,14 @@ module Pod
DESC
def
initialize
(
argv
)
@cache
_root
=
Config
.
instance
.
cache_root
+
'Pods'
@cache
=
Downloader
::
Cache
.
new
(
Config
.
instance
.
cache_root
+
'Pods'
)
super
end
private
# @return [Hash<String, Hash<Symbol, String>>]
# A hash whose keys are the pod spec name
# And values are a hash with the following keys:
# :spec_file : path to the spec file
# :name : name of the pod
# :version : pod version
# :release : boolean to tell if that's a release pod
# :slug : the slug path where the pod cache is located
#
# @todo Move this to Pod::Downloader::Cache
#
def
cache_info_per_pod
specs_dir
=
@cache_root
+
'Specs'
spec_files
=
specs_dir
.
find
.
select
{
|
f
|
f
.
fnmatch
(
'*.podspec.json'
)
}
spec_files
.
reduce
({})
do
|
hash
,
spec_file
|
spec
=
Specification
.
from_file
(
spec_file
)
hash
[
spec
.
name
]
=
[]
if
hash
[
spec
.
name
].
nil?
is_release
=
spec_file
.
to_s
.
start_with?
((
specs_dir
+
'Release'
).
to_s
)
request
=
Downloader
::
Request
.
new
(
:spec
=>
spec
,
:released
=>
is_release
)
hash
[
spec
.
name
]
<<
{
:spec_file
=>
spec_file
,
:version
=>
request
.
spec
.
version
,
:release
=>
is_release
,
:slug
=>
@cache_root
+
request
.
slug
,
}
hash
end
end
def
pod_type
(
pod_cache_info
)
pod_cache_info
[
:release
]
?
'Release'
:
'External'
def
pod_type
(
pod_cache_descriptor
)
pod_cache_descriptor
[
:release
]
?
'Release'
:
'External'
end
end
end
...
...
lib/cocoapods/command/cache/clean.rb
View file @
2fdac707
...
...
@@ -36,17 +36,17 @@ module Pod
clear_cache
else
# Remove only cache for this pod
cache_
list
=
cache_info
_per_pod
[
@pod_name
]
if
cache_
list
.
nil?
cache_
descriptors
=
@cache
.
cache_descriptors
_per_pod
[
@pod_name
]
if
cache_
descriptors
.
nil?
UI
.
notice
(
"No cache for pod named
#{
@pod_name
}
found"
)
elsif
cache_
list
.
count
>
1
&&
!
@wipe_all
elsif
cache_
descriptors
.
count
>
1
&&
!
@wipe_all
# Ask which to remove
choices
=
cache_
list
.
map
{
|
c
|
"
#{
@pod_name
}
v
#{
c
[
:version
]
}
(
#{
pod_type
(
c
)
}
)"
}
choices
=
cache_
descriptors
.
map
{
|
c
|
"
#{
@pod_name
}
v
#{
c
[
:version
]
}
(
#{
pod_type
(
c
)
}
)"
}
index
=
UI
.
choose_from_array
(
choices
,
'Which pod cache do you want to remove?'
)
remove_caches
([
cache_
list
[
index
]])
remove_caches
([
cache_
descriptors
[
index
]])
else
# Remove all found cache of this pod
remove_caches
(
cache_
list
)
remove_caches
(
cache_
descriptors
)
end
end
end
...
...
@@ -63,24 +63,24 @@ module Pod
# Removes the specified cache
#
# @param [Array<Hash>] cache_
info
s
# @param [Array<Hash>] cache_
descriptor
s
# An array of caches to remove, each specified with the same
# hash as cache_
info
_per_pod especially :spec_file and :slug
# hash as cache_
descriptors
_per_pod especially :spec_file and :slug
#
def
remove_caches
(
cache_
info
s
)
cache_
infos
.
each
do
|
info
|
UI
.
message
(
"Removing spec
#{
info
[
:spec_file
]
}
(v
#{
info
[
:version
]
}
)"
)
do
FileUtils
.
rm
(
info
[
:spec_file
])
def
remove_caches
(
cache_
descriptor
s
)
cache_
descriptors
.
each
do
|
desc
|
UI
.
message
(
"Removing spec
#{
desc
[
:spec_file
]
}
(v
#{
desc
[
:version
]
}
)"
)
do
FileUtils
.
rm
(
desc
[
:spec_file
])
end
UI
.
message
(
"Removing cache
#{
info
[
:slug
]
}
"
)
do
FileUtils
.
rm_rf
(
info
[
:slug
])
UI
.
message
(
"Removing cache
#{
desc
[
:slug
]
}
"
)
do
FileUtils
.
rm_rf
(
desc
[
:slug
])
end
end
end
def
clear_cache
UI
.
message
(
"Removing the whole cache dir
#{
@cache
_
root
}
"
)
do
FileUtils
.
rm_rf
(
@cache
_
root
)
UI
.
message
(
"Removing the whole cache dir
#{
@cache
.
root
}
"
)
do
FileUtils
.
rm_rf
(
@cache
.
root
)
end
end
end
...
...
lib/cocoapods/command/cache/list.rb
View file @
2fdac707
...
...
@@ -26,18 +26,18 @@ module Pod
end
def
run
UI
.
puts
(
"Cache root:
#{
@cache
_
root
}
"
)
if
@short_output
UI
.
puts
(
"Cache root:
#{
@cache
.
root
}
"
)
if
@short_output
if
@pod_name
.
nil?
# Print all
cache_info_per_pod
.
each
do
|
pod
,
infos
|
@cache
.
cache_descriptors_per_pod
.
each
do
|
pod
,
cache_desc
|
UI
.
title
pod
print_pod_cache_infos
(
infos
)
print_pod_cache_infos
(
cache_desc
)
end
else
# Print only for the requested pod
cache_
infos
=
cache_info
_per_pod
[
@pod_name
]
if
cache_
info
s
.
nil?
cache_
descriptors
=
@cache
.
cache_descriptors
_per_pod
[
@pod_name
]
if
cache_
descriptor
s
.
nil?
UI
.
notice
(
"No cache for pod named
#{
@pod_name
}
found"
)
else
print_pod_cache_infos
(
cache_
info
s
)
print_pod_cache_infos
(
cache_
descriptor
s
)
end
end
end
...
...
@@ -54,7 +54,7 @@ module Pod
info_list
.
each
do
|
info
|
UI
.
section
(
"
#{
info
[
:version
]
}
(
#{
pod_type
(
info
)
}
)"
)
do
if
@short_output
[
:spec_file
,
:slug
].
each
{
|
k
|
info
[
k
]
=
info
[
k
].
relative_path_from
(
@cache
_
root
)
}
[
:spec_file
,
:slug
].
each
{
|
k
|
info
[
k
]
=
info
[
k
].
relative_path_from
(
@cache
.
root
)
}
end
UI
.
labeled
(
'Spec'
,
info
[
:spec_file
])
UI
.
labeled
(
'Pod'
,
info
[
:slug
])
...
...
lib/cocoapods/downloader/cache.rb
View file @
2fdac707
...
...
@@ -38,6 +38,39 @@ module Pod
raise
end
# @return [Hash<String, Hash<Symbol, String>>]
# A hash whose keys are the pod name
# And values are a hash with the following keys:
# :spec_file : path to the spec file
# :name : name of the pod
# :version : pod version
# :release : boolean to tell if that's a release pod
# :slug : the slug path where the pod cache is located
#
# @todo Move this to Pod::Downloader::Cache
#
def
cache_descriptors_per_pod
specs_dir
=
root
+
'Specs'
release_specs_dir
=
specs_dir
+
'Release'
return
{}
unless
specs_dir
.
exist?
spec_paths
=
specs_dir
.
find
.
select
{
|
f
|
f
.
fnmatch
(
'*.podspec.json'
)
}
spec_paths
.
reduce
({})
do
|
hash
,
spec_path
|
spec
=
Specification
.
from_file
(
spec_path
)
hash
[
spec
.
name
]
=
[]
if
hash
[
spec
.
name
].
nil?
is_release
=
spec_path
.
to_s
.
start_with?
(
release_specs_dir
.
to_s
)
request
=
Downloader
::
Request
.
new
(
:spec
=>
spec
,
:released
=>
is_release
)
hash
[
spec
.
name
]
<<
{
:spec_file
=>
spec_path
,
:name
=>
spec
.
name
,
:version
=>
spec
.
version
,
:release
=>
is_release
,
:slug
=>
root
+
request
.
slug
,
}
hash
end
end
private
# Ensures the cache on disk was created with the same CocoaPods version as
...
...
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