Commit 43e79bd6 authored by Fabio Pelosin's avatar Fabio Pelosin

[Platform] Simplify deployment target specification.

- Allow to specify the deployment target after initialization
parent 50405dc5
...@@ -8,17 +8,24 @@ module Pod ...@@ -8,17 +8,24 @@ module Pod
new :osx new :osx
end 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 @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 end
def name def name
@symbolic_name @symbolic_name
end end
def deployment_target= (version)
@deployment_target = Pod::Version.create(version)
end
def ==(other_platform_or_symbolic_name) def ==(other_platform_or_symbolic_name)
if other_platform_or_symbolic_name.is_a?(Symbol) if other_platform_or_symbolic_name.is_a?(Symbol)
@symbolic_name == other_platform_or_symbolic_name @symbolic_name == other_platform_or_symbolic_name
...@@ -51,12 +58,6 @@ module Pod ...@@ -51,12 +58,6 @@ module Pod
name.nil? name.nil?
end end
def deployment_target
if (options && opt = options[:deployment_target])
Pod::Version.new(opt)
end
end
def requires_legacy_ios_archs? def requires_legacy_ios_archs?
return unless deployment_target return unless deployment_target
(name == :ios) && (deployment_target < Pod::Version.new("4.3")) (name == :ios) && (deployment_target < Pod::Version.new("4.3"))
......
...@@ -23,31 +23,34 @@ describe Pod::Platform do ...@@ -23,31 +23,34 @@ describe Pod::Platform do
end end
it "presents an accurate string representation" do 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(:osx).to_s.should == 'OS X'
Pod::Platform.new(nil).to_s.should == "iOS - 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(:ios, '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' Pod::Platform.new(:osx, '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)
end end
it "uses it's name as it's symbold version" do it "uses it's name as it's symbold version" do
@platform.to_sym.should == :ios @platform.to_sym.should == :ios
end 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 end
describe "Pod::Platform with a nil value" do describe "Pod::Platform with a nil value" do
...@@ -59,3 +62,35 @@ describe "Pod::Platform with a nil value" do ...@@ -59,3 +62,35 @@ describe "Pod::Platform with a nil value" do
@platform.should.be.nil @platform.should.be.nil
end end
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment