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
a9ccd659
Commit
a9ccd659
authored
Oct 22, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Podfile#target which scopes dependencies to static libraries.
parent
5f1bb7de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
5 deletions
+69
-5
podfile.rb
lib/cocoapods/podfile.rb
+34
-5
podfile_spec.rb
spec/unit/podfile_spec.rb
+35
-0
No files found.
lib/cocoapods/podfile.rb
View file @
a9ccd659
module
Pod
module
Pod
class
Podfile
class
Podfile
class
Target
attr_reader
:name
,
:parent
,
:target_dependencies
def
initialize
(
name
,
parent
=
nil
)
@name
,
@parent
,
@target_dependencies
=
name
,
parent
,
[]
end
def
lib_name
name
==
:default
?
"libPods"
:
"libPods-
#{
name
}
"
end
# Returns *all* dependencies of this target, not only the target specific
# ones in `target_dependencies`.
def
dependencies
@target_dependencies
+
(
@parent
?
@parent
.
dependencies
:
[])
end
end
def
self
.
from_file
(
path
)
def
self
.
from_file
(
path
)
podfile
=
Podfile
.
new
do
podfile
=
Podfile
.
new
do
eval
(
path
.
read
,
nil
,
path
.
to_s
)
eval
(
path
.
read
,
nil
,
path
.
to_s
)
...
@@ -10,7 +28,7 @@ module Pod
...
@@ -10,7 +28,7 @@ module Pod
end
end
def
initialize
(
&
block
)
def
initialize
(
&
block
)
@
dependencies
=
[]
@
targets
=
{
:default
=>
(
@target
=
Target
.
new
(
:default
))
}
instance_eval
(
&
block
)
instance_eval
(
&
block
)
end
end
...
@@ -58,10 +76,12 @@ module Pod
...
@@ -58,10 +76,12 @@ module Pod
# * http://semver.org
# * http://semver.org
# * http://docs.rubygems.org/read/chapter/7
# * http://docs.rubygems.org/read/chapter/7
def
dependency
(
name
,
*
version_requirements
)
def
dependency
(
name
,
*
version_requirements
)
@dependencies
<<
Dependency
.
new
(
name
,
*
version_requirements
)
@
target
.
target_
dependencies
<<
Dependency
.
new
(
name
,
*
version_requirements
)
end
end
attr_reader
:dependencies
def
dependencies
@targets
.
values
.
map
(
&
:target_dependencies
).
flatten
end
# Specifies that a BridgeSupport metadata should be generated from the
# Specifies that a BridgeSupport metadata should be generated from the
# headers of all installed Pods.
# headers of all installed Pods.
...
@@ -72,6 +92,15 @@ module Pod
...
@@ -72,6 +92,15 @@ module Pod
@generate_bridge_support
=
true
@generate_bridge_support
=
true
end
end
attr_reader
:targets
def
target
(
name
,
options
=
{})
@targets
[
name
]
=
@target
=
Target
.
new
(
name
,
@target
)
yield
ensure
@target
=
@target
.
parent
end
# This is to be compatible with a Specification for use in the Installer and
# This is to be compatible with a Specification for use in the Installer and
# Resolver.
# Resolver.
...
@@ -86,13 +115,13 @@ module Pod
...
@@ -86,13 +115,13 @@ module Pod
end
end
def
dependency_by_name
(
name
)
def
dependency_by_name
(
name
)
@
dependencies
.
find
{
|
d
|
d
.
name
==
name
}
dependencies
.
find
{
|
d
|
d
.
name
==
name
}
end
end
def
validate!
def
validate!
lines
=
[]
lines
=
[]
lines
<<
"* the `platform` attribute should be either `:osx` or `:ios`"
unless
[
:osx
,
:ios
].
include?
(
@platform
)
lines
<<
"* the `platform` attribute should be either `:osx` or `:ios`"
unless
[
:osx
,
:ios
].
include?
(
@platform
)
lines
<<
"* no dependencies were specified, which is, well, kinda pointless"
if
@
dependencies
.
empty?
lines
<<
"* no dependencies were specified, which is, well, kinda pointless"
if
dependencies
.
empty?
raise
(
Informative
,
([
"The Podfile at `
#{
@defined_in_file
}
' is invalid:"
]
+
lines
).
join
(
"
\n
"
))
unless
lines
.
empty?
raise
(
Informative
,
([
"The Podfile at `
#{
@defined_in_file
}
' is invalid:"
]
+
lines
).
join
(
"
\n
"
))
unless
lines
.
empty?
end
end
end
end
...
...
spec/unit/podfile_spec.rb
View file @
a9ccd659
...
@@ -23,6 +23,41 @@ describe "Pod::Podfile" do
...
@@ -23,6 +23,41 @@ describe "Pod::Podfile" do
podfile
.
generate_bridge_support?
.
should
==
true
podfile
.
generate_bridge_support?
.
should
==
true
end
end
describe
"concerning targets (dependency groups)"
do
before
do
@podfile
=
Pod
::
Podfile
.
new
do
target
:debug
do
dependency
'SSZipArchive'
end
target
:test
,
:exclusive
=>
true
do
dependency
'JSONKit'
end
dependency
'ASIHTTPRequest'
end
end
it
"returns all dependencies of all targets combined, which is used during resolving to enusre compatible dependencies"
do
@podfile
.
dependencies
.
map
(
&
:name
).
sort
.
should
==
%w{ ASIHTTPRequest JSONKit SSZipArchive }
end
it
"adds dependencies outside of any explicit target block to the default target"
do
target
=
@podfile
.
targets
[
:default
]
target
.
lib_name
.
should
==
'libPods'
target
.
dependencies
.
should
==
[
Pod
::
Dependency
.
new
(
'ASIHTTPRequest'
)]
end
it
"adds dependencies of the outer target to non-exclusive targets"
do
target
=
@podfile
.
targets
[
:debug
]
target
.
lib_name
.
should
==
'libPods-debug'
target
.
dependencies
.
sort_by
(
&
:name
).
should
==
[
Pod
::
Dependency
.
new
(
'ASIHTTPRequest'
),
Pod
::
Dependency
.
new
(
'SSZipArchive'
)
]
end
end
describe
"concerning validations"
do
describe
"concerning validations"
do
it
"raises if no platform is specified"
do
it
"raises if no platform is specified"
do
exception
=
lambda
{
exception
=
lambda
{
...
...
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