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
22de3728
Commit
22de3728
authored
May 11, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Specification#preferred_dependency] Implementation.
parent
77c1f0b1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
43 deletions
+47
-43
specification.rb
lib/cocoapods/specification.rb
+47
-43
No files found.
lib/cocoapods/specification.rb
View file @
22de3728
...
...
@@ -131,6 +131,7 @@ module Pod
### Regular attributes
attr_accessor
:parent
attr_accessor
:preferred_dependency
def
name
@parent
?
"
#{
@parent
.
name
}
/
#{
@name
}
"
:
@name
...
...
@@ -138,13 +139,6 @@ module Pod
attr_writer
:name
def
main_subspec
return
self
unless
@main_subspec
subspecs
.
find
{
|
s
|
s
.
name
==
"
#{
self
.
name
}
/
#{
@main_subspec
}
"
}
end
attr_writer
:main_subspec
### Attributes that return the first value defined in the chain
def
summary
...
...
@@ -267,25 +261,20 @@ module Pod
result
end
# A specification inherits all of its subspecs as dependencies
# A specification inherits the preferred_dependency or
# all of its subspecs as dependencies
def
subspec_dependencies
specs
=
preferred_dependency
?
[
subspec_by_name
(
preferred_dependency
)]
:
subspecs
specs
\
.
reject
{
|
s
|
s
.
supports_platform?
(
active_platform
)
}
\
.
map
{
|
s
|
Dependency
.
new
(
s
.
name
,
version
)
}
end
def
dependencies
raise
Informative
,
"
#{
self
.
inspect
}
#dependencies not activated for a platform before consumption."
unless
active_platform
result
=
@dependencies
[
active_platform
]
+
subspecs
.
map
{
|
s
|
Dependency
.
new
(
s
.
name
,
version
)
}
result
+=
parent
.
external_dependencies
if
parent
result
external_dependencies
+
subspec_dependencies
end
### Not attributes
# @visibility private
#
# This is used by PlatformProxy to assign attributes for the scoped platform.
def
_on_platform
(
platform
)
before
,
@define_for_platforms
=
@define_for_platforms
,
[
platform
]
yield
ensure
@define_for_platforms
=
before
end
include
Config
::
Mixin
...
...
@@ -313,7 +302,7 @@ module Pod
end
def
subspec_by_name
(
name
)
return
main_subspec
if
name
.
nil?
||
name
==
self
.
name
return
self
if
name
.
nil?
||
name
==
self
.
name
# Remove this spec's name from the beginning of the name we’re looking for
# and take the first component from the remainder, which is the spec we need
# to find now.
...
...
@@ -326,24 +315,6 @@ module Pod
remainder
.
empty?
?
subspec
:
subspec
.
subspec_by_name
(
name
)
end
# Returns whether the specification is supported in a given platform
def
supports_platform?
(
plaform
)
available_platforms
.
any?
{
|
p
|
platform
.
supports?
p
}
end
# Defines the active platform for comsumption of the specification and
# returns self for method chainability.
# The active platform must the the same accross the chain so attributes
# that are inherited can be correctly resolved.
def
activate_platform
(
platform
)
platform
=
Platform
.
new
(
platform
)
if
platform
.
is_a?
Hash
raise
"
#{
to_s
}
is not compatible with
#{
platform
}
."
unless
supports_platform?
(
platform
)
top_level_parent
.
active_platform
=
platform
.
to_sym
self
end
top_attr_accessor
:active_platform
def
local?
!
source
.
nil?
&&
!
source
[
:local
].
nil?
end
...
...
@@ -425,11 +396,44 @@ module Pod
version
&&
version
==
other
.
version
)
end
private
# Returns whether the specification is supported in a given platform
def
supports_platform?
(
plaform
)
available_platforms
.
any?
{
|
p
|
platform
.
supports?
p
}
end
# Defines the active platform for comsumption of the specification and
# returns self for method chainability.
# The active platform must the the same accross the chain so attributes
# that are inherited can be correctly resolved.
def
activate_platform
(
platform
)
platform
=
Platform
.
new
(
platform
)
if
platform
.
is_a?
Hash
raise
"
#{
to_s
}
is not compatible with
#{
platform
}
."
unless
supports_platform?
(
platform
)
top_level_parent
.
active_platform
=
platform
.
to_sym
self
end
top_attr_accessor
:active_platform
### Not attributes
# @visibility private
#
# This is used by PlatformProxy to assign attributes for the scoped platform.
def
_on_platform
(
platform
)
before
,
@define_for_platforms
=
@define_for_platforms
,
[
platform
]
yield
ensure
@define_for_platforms
=
before
end
# @visibility private
#
# This deployment_target is multiplatform and to support
# subspecs with different platforms is is resolved as the
# first non nil value accross the chain.
def
deployment_target
=
(
version
)
raise
Informative
,
"The deployment target must be defined per platform like `s.ios.deployment_target = '5.0'`."
unless
@define_for_platforms
.
count
==
1
deployment_target
[
@define_for_platforms
.
first
]
=
version
@
deployment_target
[
@define_for_platforms
.
first
]
=
version
end
def
deployment_target
(
platform
)
...
...
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