Commit 8d1430a8 authored by Fabio Pelosin's avatar Fabio Pelosin

[Platform] Support initialization from another platform.

parent 6bbdfa3a
...@@ -10,11 +10,32 @@ module Pod ...@@ -10,11 +10,32 @@ module Pod
attr_reader :deployment_target attr_reader :deployment_target
def initialize(symbolic_name = nil, deployment_target = nil) ##
@symbolic_name = symbolic_name # Public: Constructs a platform from either another platform or by
if deployment_target # specifying the symbolic name and optionally the 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) # input - Another platform or the symbolic name of the platform.
# deployment_target - The optional deployment target if initalized by
# symbolic name
#
# Examples
#
# Platform.new(:ios)
# Platform.new(:ios, '4.3')
# Platform.new(Platform.new(:ios))
#
# Returns nothing.
def initialize(input = nil, deployment_target = nil)
if input.is_a? Platform
@symbolic_name = input.name
@deployment_target = input.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)
end
end end
end end
......
...@@ -7,6 +7,12 @@ describe Pod::Platform do ...@@ -7,6 +7,12 @@ describe Pod::Platform do
Pod::Platform.osx.should == Pod::Platform.new(:osx) Pod::Platform.osx.should == Pod::Platform.new(:osx)
end end
it "can be initialized from another platform" do
platform = Pod::Platform.new(:ios)
new = Pod::Platform.new(platform)
new.should == platform
end
before do before do
@platform = Pod::Platform.ios @platform = Pod::Platform.ios
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