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
43e79bd6
Commit
43e79bd6
authored
May 03, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Platform] Simplify deployment target specification.
- Allow to specify the deployment target after initialization
parent
50405dc5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
27 deletions
+63
-27
platform.rb
lib/cocoapods/platform.rb
+10
-9
platform_spec.rb
spec/unit/platform_spec.rb
+53
-18
No files found.
lib/cocoapods/platform.rb
View file @
43e79bd6
...
...
@@ -8,17 +8,24 @@ module Pod
new
:osx
end
attr_reader
:options
attr_reader
:options
,
:deployment_target
def
initialize
(
symbolic_name
,
options
=
{}
)
def
initialize
(
symbolic_name
,
deployment_target
=
nil
)
@symbolic_name
=
symbolic_name
@options
=
options
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
)
end
end
def
name
@symbolic_name
end
def
deployment_target
=
(
version
)
@deployment_target
=
Pod
::
Version
.
create
(
version
)
end
def
==
(
other_platform_or_symbolic_name
)
if
other_platform_or_symbolic_name
.
is_a?
(
Symbol
)
@symbolic_name
==
other_platform_or_symbolic_name
...
...
@@ -51,12 +58,6 @@ module Pod
name
.
nil?
end
def
deployment_target
if
(
options
&&
opt
=
options
[
:deployment_target
])
Pod
::
Version
.
new
(
opt
)
end
end
def
requires_legacy_ios_archs?
return
unless
deployment_target
(
name
==
:ios
)
&&
(
deployment_target
<
Pod
::
Version
.
new
(
"4.3"
))
...
...
spec/unit/platform_spec.rb
View file @
43e79bd6
...
...
@@ -23,31 +23,34 @@ describe Pod::Platform do
end
it
"presents an accurate string representation"
do
@platform
.
to_s
.
should
==
"iOS"
@platform
.
to_s
.
should
==
"iOS"
Pod
::
Platform
.
new
(
:osx
).
to_s
.
should
==
'OS X'
Pod
::
Platform
.
new
(
nil
).
to_s
.
should
==
"iOS - OS X"
Pod
::
Platform
.
new
(
:ios
,
{
:deployment_target
=>
'5.0.0'
}).
to_s
.
should
==
'iOS 5.0.0'
Pod
::
Platform
.
new
(
:osx
,
{
:deployment_target
=>
'10.7'
}).
to_s
.
should
==
'OS X 10.7'
end
it
"correctly indicates if it supports another platfrom"
do
ios4
=
Pod
::
Platform
.
new
(
:ios
,
{
:deployment_target
=>
'4.0.0'
})
ios5
=
Pod
::
Platform
.
new
(
:ios
,
{
:deployment_target
=>
'5.0.0'
})
ios5
.
should
.
support?
(
ios4
)
ios4
.
should
.
not
.
support?
(
ios5
)
osx6
=
Pod
::
Platform
.
new
(
:osx
,
{
:deployment_target
=>
'10.6'
})
osx7
=
Pod
::
Platform
.
new
(
:osx
,
{
:deployment_target
=>
'10.7'
})
osx7
.
should
.
support?
(
osx6
)
osx6
.
should
.
not
.
support?
(
osx7
)
both
=
Pod
::
Platform
.
new
(
nil
)
both
.
should
.
support?
(
ios4
)
both
.
should
.
support?
(
osx6
)
both
.
should
.
support?
(
nil
)
Pod
::
Platform
.
new
(
:ios
,
'5.0.0'
).
to_s
.
should
==
'iOS 5.0.0'
Pod
::
Platform
.
new
(
:osx
,
'10.7'
).
to_s
.
should
==
'OS X 10.7'
end
it
"uses it's name as it's symbold version"
do
@platform
.
to_sym
.
should
==
:ios
end
it
"allows to specify the deployment target on initialization"
do
p
=
Pod
::
Platform
.
new
(
:ios
,
'4.0.0'
)
p
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0.0'
)
end
it
"allows to specify the deployment target in a hash on initialization (backwards compatibility from 0.6)"
do
p
=
Pod
::
Platform
.
new
(
:ios
,
{
:deployment_target
=>
'4.0.0'
})
p
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0.0'
)
end
it
"allows to specify the deployment target after initialization"
do
p
=
Pod
::
Platform
.
new
(
:ios
,
'4.0.0'
)
p
.
deployment_target
=
'4.0.0'
p
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0.0'
)
p
.
deployment_target
=
Pod
::
Version
.
new
(
'4.0.0'
)
p
.
deployment_target
.
should
==
Pod
::
Version
.
new
(
'4.0.0'
)
end
end
describe
"Pod::Platform with a nil value"
do
...
...
@@ -59,3 +62,35 @@ describe "Pod::Platform with a nil value" do
@platform
.
should
.
be
.
nil
end
end
describe
"Pod::Platform#support?"
do
it
"supports another platform is with the same operating system"
do
p1
=
Pod
::
Platform
.
new
(
:ios
)
p2
=
Pod
::
Platform
.
new
(
:ios
)
p1
.
should
.
support?
(
p2
)
p1
=
Pod
::
Platform
.
new
(
:osx
)
p2
=
Pod
::
Platform
.
new
(
:osx
)
p1
.
should
.
support?
(
p2
)
end
it
"supports a nil platform"
do
p1
=
Pod
::
Platform
.
new
(
:ios
)
p1
.
should
.
support?
(
nil
)
end
it
"supports a platform with a lower or equal deployment_target"
do
p1
=
Pod
::
Platform
.
new
(
:ios
,
'5.0'
)
p2
=
Pod
::
Platform
.
new
(
:ios
,
'4.0'
)
p1
.
should
.
support?
(
p1
)
p1
.
should
.
support?
(
p2
)
p2
.
should
.
not
.
support?
(
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
.
support?
(
p2
)
p2
.
should
.
support?
(
p1
)
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