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
e65536b2
Commit
e65536b2
authored
Sep 11, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that a pod's spec is not installed if it's only part of other pods.
parent
2b933ce8
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
41 deletions
+88
-41
install.rb
lib/cocoa_pods/command/install.rb
+2
-1
config.rb
lib/cocoa_pods/config.rb
+10
-1
dependency.rb
lib/cocoa_pods/dependency.rb
+1
-0
downloader.rb
lib/cocoa_pods/downloader.rb
+18
-14
resolver.rb
lib/cocoa_pods/resolver.rb
+2
-1
specification.rb
lib/cocoa_pods/specification.rb
+51
-24
set.rb
lib/cocoa_pods/specification/set.rb
+4
-0
No files found.
lib/cocoa_pods/command/install.rb
View file @
e65536b2
...
@@ -3,7 +3,8 @@ module Pod
...
@@ -3,7 +3,8 @@ module Pod
class
Install
<
Command
class
Install
<
Command
def
run
def
run
if
spec
=
Specification
.
from_podfile
(
podfile
)
if
spec
=
Specification
.
from_podfile
(
podfile
)
spec
.
install_dependent_specifications!
(
pods_root
,
true
)
#config.clean = false
spec
.
install_dependent_specifications!
else
else
$stderr
.
puts
"No Podfile found in current working directory."
$stderr
.
puts
"No Podfile found in current working directory."
end
end
...
...
lib/cocoa_pods/config.rb
View file @
e65536b2
...
@@ -10,10 +10,19 @@ module Pod
...
@@ -10,10 +10,19 @@ module Pod
@instance
=
instance
@instance
=
instance
end
end
attr_accessor
:repos_dir
attr_accessor
:repos_dir
,
:clean
def
initialize
def
initialize
@repos_dir
=
Pathname
.
new
(
File
.
expand_path
(
"~/.cocoa-pods"
))
@repos_dir
=
Pathname
.
new
(
File
.
expand_path
(
"~/.cocoa-pods"
))
@clean
=
true
end
def
project_root
Pathname
.
new
(
Dir
.
pwd
)
end
def
project_pods_root
project_root
+
'Pods'
end
end
module
Mixin
module
Mixin
...
...
lib/cocoa_pods/dependency.rb
View file @
e65536b2
...
@@ -4,5 +4,6 @@ require 'rubygems/dependency'
...
@@ -4,5 +4,6 @@ require 'rubygems/dependency'
module
Pod
module
Pod
class
Dependency
<
Gem
::
Dependency
class
Dependency
<
Gem
::
Dependency
attr_accessor
:part_of_other_pod
end
end
end
end
lib/cocoa_pods/downloader.rb
View file @
e65536b2
...
@@ -22,32 +22,36 @@ module Pod
...
@@ -22,32 +22,36 @@ module Pod
# * sync output
# * sync output
executable
:git
executable
:git
def
source_dir
def
download
@pod_root
+
'source'
if
@options
[
:tag
]
download_tag
elsif
@options
[
:commit
]
download_commit
else
raise
"Either a tag or a commit has to be specified."
end
end
end
def
download
def
download_tag
if
tag
=
@options
[
:tag
]
@pod_root
.
mkdir
source_dir
.
mkdir
Dir
.
chdir
(
@pod_root
)
do
Dir
.
chdir
(
source_dir
)
do
git
"init"
git
"init"
git
"remote add origin '
#{
@url
}
'"
git
"remote add origin '
#{
@url
}
'"
git
"fetch origin tags/
#{
tag
}
2>&1"
git
"fetch origin tags/
#{
@options
[
:tag
]
}
2>&1"
git
"reset --hard FETCH_HEAD"
git
"reset --hard FETCH_HEAD"
git
"checkout -b activated-pod-commit 2>&1"
git
"checkout -b activated-pod-commit 2>&1"
end
end
elsif
commit
=
@options
[
:commit
]
git
"clone '
#{
@url
}
' '
#{
source_dir
}
'"
Dir
.
chdir
(
source_dir
)
do
git
"checkout -b activated-pod-commit
#{
commit
}
2>&1"
end
end
else
raise
"Either a tag or a commit has to be specified."
def
download_commit
git
"clone '
#{
@url
}
' '
#{
@pod_root
}
'"
Dir
.
chdir
(
@pod_root
)
do
git
"checkout -b activated-pod-commit
#{
@options
[
:commit
]
}
2>&1"
end
end
end
end
def
clean
def
clean
(
source_dir
+
'.git'
).
rmtree
(
@pod_root
+
'.git'
).
rmtree
end
end
end
end
end
end
...
...
lib/cocoa_pods/resolver.rb
View file @
e65536b2
...
@@ -7,7 +7,8 @@ module Pod
...
@@ -7,7 +7,8 @@ module Pod
def
resolve
def
resolve
@sets
=
[]
@sets
=
[]
find_dependency_sets
(
@specification
)
find_dependency_sets
(
@specification
)
@sets
.
map
(
&
:podspec
)
#@sets.reject(&:only_part_of_other_pod?).map(&:podspec)
@sets
end
end
def
find_dependency_sets
(
specification
)
def
find_dependency_sets
(
specification
)
...
...
lib/cocoa_pods/specification.rb
View file @
e65536b2
...
@@ -64,6 +64,7 @@ module Pod
...
@@ -64,6 +64,7 @@ module Pod
def
part_of
(
name
,
*
version_requirements
)
def
part_of
(
name
,
*
version_requirements
)
#@part_of = Dependency.new(name, *version_requirements)
#@part_of = Dependency.new(name, *version_requirements)
@part_of
=
dependency
(
name
,
*
version_requirements
)
@part_of
=
dependency
(
name
,
*
version_requirements
)
@part_of
.
part_of_other_pod
=
true
end
end
def
source_files
(
*
patterns
)
def
source_files
(
*
patterns
)
...
@@ -83,42 +84,68 @@ module Pod
...
@@ -83,42 +84,68 @@ module Pod
# Not attributes
# Not attributes
def
resolved_dependent_specifications
# This also includes those that are only part of other specs, but are not
@resolved_dependent_specifications
||=
Resolver
.
new
(
self
).
resolve
# actually being used themselves.
def
resolved_dependent_specification_sets
@resolved_dependent_specifications_sets
||=
Resolver
.
new
(
self
).
resolve
end
end
def
install_dependent_specifications!
(
root
,
clean
)
def
install_dependent_specifications!
resolved_dependent_specifications
.
each
do
|
spec
|
sets
=
resolved_dependent_specification_sets
install_spec
=
spec
sets
.
each
do
|
set
|
if
part_of_spec_dep
=
spec
.
read
(
:part_of
)
# In case the set is only part of other pods we don't need to install
install_spec
=
resolved_dependent_specifications
.
find
{
|
s
|
s
.
read
(
:name
)
==
part_of_spec_dep
.
name
}
# the pod itself.
puts
"-- Installing:
#{
install_spec
}
for
#{
spec
}
"
next
if
set
.
only_part_of_other_pod?
else
puts
"-- Installing:
#{
install_spec
}
"
spec
=
set
.
podspec
spec
.
install!
# In case spec is part of another pod we need to dowload the other
# pod's source.
if
spec
.
part_of_other_pod?
# Find the specification of the pod that spec's source is a part of.
part_of_name
=
spec
.
read
(
:part_of
).
name
spec
=
sets
.
find
{
|
set
|
set
.
name
==
part_of_name
}.
podspec
end
end
install_spec
.
install!
(
root
,
clean
)
spec
.
download_if_necessary!
end
end
end
end
# User can override this for custom installation
include
Config
::
Mixin
def
install!
(
pods_root
,
clean
)
def
pod_destroot
config
.
project_pods_root
+
"
#{
@name
}
-
#{
@version
}
"
end
# Places the activated podspec in the project's pods directory.
def
install!
puts
"==> Installing:
#{
self
}
"
config
.
project_pods_root
.
mkpath
require
'fileutils'
require
'fileutils'
pods_root
.
mkpath
FileUtils
.
cp
(
@defined_in_file
,
config
.
project_pods_root
)
pod_root
=
pods_root
+
"
#{
@name
}
-
#{
@version
}
"
end
if
pod_root
.
exist?
puts
" Skipping, the pod already exists:
#{
pod_root
}
"
def
download_if_necessary!
if
pod_destroot
.
exist?
puts
" * Skipping download of
#{
self
}
, pod already downloaded"
else
else
pod_root
.
mkdir
puts
" * Downloading:
#{
self
}
"
FileUtils
.
cp
(
@defined_in_file
,
pod_root
)
download!
download_to
(
pod_root
,
clean
)
end
end
end
end
# User can override this for custom downloading
# Downloads the source of the pod and places it in the project's pods
def
download_to
(
pod_root
,
clean
)
# directory.
downloader
=
Downloader
.
for_source
(
@source
,
pod_root
)
#
# You can override this for custom downloading.
def
download!
downloader
=
Downloader
.
for_source
(
@source
,
pod_destroot
)
downloader
.
download
downloader
.
download
downloader
.
clean
if
clean
downloader
.
clean
if
config
.
clean
end
def
part_of_other_pod?
!
@part_of
.
nil?
end
end
def
from_podfile?
def
from_podfile?
...
...
lib/cocoa_pods/specification/set.rb
View file @
e65536b2
...
@@ -20,6 +20,10 @@ module Pod
...
@@ -20,6 +20,10 @@ module Pod
@required_by
.
inject
(
Dependency
.
new
(
name
))
{
|
previous
,
(
_
,
dep
)
|
previous
.
merge
(
dep
)
}
@required_by
.
inject
(
Dependency
.
new
(
name
))
{
|
previous
,
(
_
,
dep
)
|
previous
.
merge
(
dep
)
}
end
end
def
only_part_of_other_pod?
@required_by
.
all?
{
|
_
,
dep
|
dep
.
part_of_other_pod
}
end
def
name
def
name
@pod_dir
.
basename
.
to_s
@pod_dir
.
basename
.
to_s
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