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
05fba7b6
Commit
05fba7b6
authored
Jun 09, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Platform] Default deployment targets.
parent
c4cb7a49
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
40 deletions
+69
-40
platform.rb
lib/cocoapods/platform.rb
+63
-32
platform_spec.rb
spec/unit/platform_spec.rb
+5
-7
specification_spec.rb
spec/unit/specification_spec.rb
+1
-1
No files found.
lib/cocoapods/platform.rb
View file @
05fba7b6
...
...
@@ -22,33 +22,56 @@ module Pod
# Constructs a platform from either another platform or by
# specifying the symbolic name and optionally the deployment target.
#
# @overload initialize(platform)
# @param [Platform] platform Another platform or a symbolic name for the platform.
# @overload initialize(name, deployment_target)
# @param [Symbol] name The name of platform.
# @param [String, Version] deployment_target The optional deployment.
# If not provided a default value according to the platform name will
# be assigned.
#
# @note that if the name is not specified a default deployment
# target will not be assigned.
#
# @example
#
#
p = Platform.new :ios
# Platform.new
p
#
Platform.new(:ios)
# Platform.new
(:ios, '4.3')
#
# @overload initialize(name, deployment_target)
# @param [Symbol] input Another platform or a symbolic name for the platform.
# @param [Version] deployment_target The optional deployment target if initialized by symbolic name.
# @overload initialize(name, opts)
# @deprecated Remove after adding a warning to {Podfile} class.
# @param [Symbol] name The name of platform.
# @param [Hash] opts The options to create a platform with.
# @option opts [String, Version] :deployment_target The deployment target.
#
# @overload initialize(platform)
# @param [Platform] platform Another {Platform}.
#
# @example
#
# Platform.new(:ios)
# Platform.new(
:ios, '4.3'
)
#
platform =
Platform.new(:ios)
# Platform.new(
platform
)
#
def
initialize
(
input
=
nil
,
deployment_
target
=
nil
)
def
initialize
(
input
=
nil
,
target
=
nil
)
if
input
.
is_a?
Platform
@symbolic_name
=
input
.
name
@deployment_target
=
input
.
deployment_target
@declared_deployment_target
=
input
.
declared_deployment_target
else
@symbolic_name
=
input
if
deployment_target
version
=
deployment_target
.
is_a?
(
Hash
)
?
deployment_target
[:
deployment_target
]
:
deployment_target
# backwards compatibility from 0.6
@deployment_target
=
Pod
::
Version
.
create
(
version
)
target
=
target
[
:deployment_target
]
if
target
.
is_a?
(
Hash
)
@declared_deployment_target
=
target
unless
target
case
@symbolic_name
when
:ios
target
=
'4.3'
when
:osx
target
=
'10.6'
else
target
=
''
end
end
@deployment_target
=
Version
.
create
(
target
)
end
end
...
...
@@ -58,18 +81,22 @@ module Pod
@symbolic_name
end
# A deployment target can be initialized by any value that initializes a {Version}.
#
# @return [Version] The optional deployment target of the platform.
# @return [Version] The deployment target of the platform.
#
attr_reader
:deployment_target
# @return [Version] The deployment target declared on initialization.
#
attr_reader
:declared_deployment_target
def
deployment_target
=
(
version
)
@deployment_target
=
Pod
::
Version
.
create
(
version
)
end
# @param [Platform, Symbol] other The other platform to check. If a symbol is
# passed the comparison does not take into account the deployment target.
# @param [Platform, Symbol] other The other platform to check.
#
# @note If a symbol is passed the comparison does not take into account
# the deployment target.
#
# @return [Boolean] Whether two platforms are the equivalent.
#
...
...
@@ -77,36 +104,41 @@ module Pod
if
other
.
is_a?
(
Symbol
)
@symbolic_name
==
other
else
self
.
name
==
(
other
.
name
)
&&
self
.
deployment_target
==
other
.
deployment_target
(
name
==
other
.
name
)
&&
(
deployment_target
==
other
.
deployment_target
)
end
end
# A platform supports (from the point of view of a pod) another platform if they represent the same SDK and if the
# deployment target of the other is lower. If one of the platforms does not specify the deployment target, it is not taken into account.
# A platform supports (from the point of view of a pod) another platform
# if they represent the same SDK and if the deployment target of the other
# is lower. If one of the platforms does not specify the deployment target,
# it is not taken into account.
#
# @note This method returns true if one of the platforms is nil.
#
#
This method always returns true if one of platforms is nil.
#
@return Whether the platform supports being used in the environment
described by another platform.
#
@return Whether the platform supports being used in the environment
#
described by another platform.
#
# @todo rename to supported_on?
#
def
supports?
(
other
)
return
true
if
@symbolic_name
.
nil?
||
other
.
nil?
os_check
=
@symbolic_name
==
other
.
name
version_check
=
(
deployment_target
.
nil?
||
other
.
deployment_target
.
nil?
||
deployment_target
>=
other
.
deployment_target
)
os_check
&&
version_check
other
=
Platform
.
new
(
other
)
(
name
==
other
.
name
)
&&
(
deployment_target
>=
other
.
deployment_target
)
end
# @return [String] A string representation
of the Platform including the deployment target if specified
.
# @return [String] A string representation
including the deployment target
.
#
def
to_s
case
@symbolic_name
when
:ios
'iOS'
+
(
deployment_target
?
"
#{
deployment_target
}
"
:
''
)
s
=
'iOS'
when
:osx
'OS X'
+
(
deployment_target
?
"
#{
deployment_target
}
"
:
''
)
s
=
'OS X'
else
'iOS - OS X'
s
=
'iOS - OS X'
end
s
<<
"
#{
declared_deployment_target
}
"
if
declared_deployment_target
s
end
# @return [Symbol] A Symbol representation of the SDK.
...
...
@@ -126,8 +158,7 @@ module Pod
# @return Whether the platform requires legacy architectures for iOS.
#
def
requires_legacy_ios_archs?
return
unless
deployment_target
(
name
==
:ios
)
&&
(
deployment_target
<
Pod
::
Version
.
new
(
"4.3"
))
(
name
==
:ios
)
&&
(
deployment_target
<
Version
.
new
(
"4.3"
))
end
end
end
spec/unit/platform_spec.rb
View file @
05fba7b6
...
...
@@ -63,6 +63,11 @@ describe Pod::Platform do
p
.
deployment_target
=
Pod
::
Version
.
new
(
'4.0.0'
)
p
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0.0'
)
end
it
"provides a default deployment target on initialization"
do
p
=
Pod
::
Platform
.
new
(
:ios
)
p
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.3'
)
end
end
describe
"with a nil value"
do
...
...
@@ -99,13 +104,6 @@ describe Pod::Platform do
p2
.
should
.
not
.
supports?
(
p1
)
end
it
"supports a platform regardless of the deployment_target if one of the two does not specify it"
do
p1
=
Pod
::
Platform
.
new
(
:ios
)
p2
=
Pod
::
Platform
.
new
(
:ios
,
'4.0'
)
p1
.
should
.
supports?
(
p2
)
p2
.
should
.
supports?
(
p1
)
end
it
"doesn't supports a platform with a different operating system"
do
p1
=
Pod
::
Platform
.
new
(
:ios
)
p2
=
Pod
::
Platform
.
new
(
:osx
)
...
...
spec/unit/specification_spec.rb
View file @
05fba7b6
...
...
@@ -382,7 +382,7 @@ describe "A Pod::Specification subspec" do
@subspec
.
supports_platform?
(
:osx
).
should
.
be
.
false
@subspec
.
supports_platform?
(
:ios
,
'4.0'
).
should
.
be
.
true
@subspec
.
supports_platform?
(
:ios
,
'5.0'
).
should
.
be
.
true
@subsubspec
.
supports_platform?
(
:ios
).
should
.
be
.
tru
e
@subsubspec
.
supports_platform?
(
:ios
).
should
.
be
.
fals
e
@subsubspec
.
supports_platform?
(
:osx
).
should
.
be
.
false
@subsubspec
.
supports_platform?
(
:ios
,
'4.0'
).
should
.
be
.
false
@subsubspec
.
supports_platform?
(
:ios
,
'5.0'
).
should
.
be
.
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