Commit 9c71d5ab authored by Fabio Pelosin's avatar Fabio Pelosin

[Platform] Require name for initialization.

parent 71d754c4
module Pod
# A platform describes an SDK name and deployment target. If no name
# is provided an instance of this class behaves like nil and represents
# all the known platforms
# A platform describes an SDK name and deployment target.
#
class Platform
......@@ -49,7 +47,7 @@ module Pod
# platform = Platform.new(:ios)
# Platform.new(platform)
#
def initialize(input = nil, target = nil)
def initialize(input, target = nil)
if input.is_a? Platform
@symbolic_name = input.name
@deployment_target = input.deployment_target
......@@ -107,12 +105,9 @@ module Pod
# one if they have the same name and the other platform has a minor or
# equal deployment target.
#
# @note This method returns true if one of the platforms is nil.
#
# @return Whether the platform supports another platform.
#
def supports?(other)
return true if @symbolic_name.nil? || other.nil?
other = Platform.new(other)
(other.name == name) && (other.deployment_target <= deployment_target)
end
......@@ -125,8 +120,6 @@ module Pod
s = 'iOS'
when :osx
s = 'OS X'
else
s = 'iOS - OS X'
end
s << " #{declared_deployment_target}" if declared_deployment_target
s
......@@ -138,15 +131,6 @@ module Pod
name
end
# @return Whether the platform does not represents any SDK.
#
# @note A platform behaves as nil if doesn't specify an name and
# represents all the known platforms.
#
def nil?
name.nil?
end
# @return Whether the platform requires legacy architectures for iOS.
#
def requires_legacy_ios_archs?
......
......@@ -37,7 +37,6 @@ describe Pod::Platform do
it "presents an accurate string representation" do
@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, '5.0.0').to_s.should == 'iOS 5.0.0'
Pod::Platform.new(:osx, '10.7').to_s.should == 'OS X 10.7'
end
......@@ -62,16 +61,6 @@ describe Pod::Platform do
end
end
describe "with a nil value" do
before do
@platform = Pod::Platform.new(nil)
end
it "behaves like a nil object" do
@platform.should.be.nil
end
end
describe "regarding supporting platforms" do
it "supports platforms with the same operating system" do
p1 = Pod::Platform.new(:ios)
......@@ -83,11 +72,6 @@ describe Pod::Platform do
p1.should.supports?(p2)
end
it "supports a nil platform" do
p1 = Pod::Platform.new(:ios)
p1.should.supports?(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')
......
......@@ -353,7 +353,7 @@ describe "A Pod::Specification subspec" do
end
it "does not cache platform attributes and can activate another platform" do
@spec.platform = nil
@spec.stubs(:platform).returns nil
@spec.activate_platform(:ios)
@subsubspec.source_files.map { |f| f.to_s }.should == %w[ spec.m subspec_ios.m subsubspec.m ]
@spec.activate_platform(:osx)
......@@ -361,7 +361,7 @@ describe "A Pod::Specification subspec" do
end
it "resolves correctly the available platforms" do
@spec.platform = nil
@spec.stubs(:platform).returns nil
@subspec.platform = :ios, '4.0'
@spec.available_platforms.map{ |p| p.to_sym }.should == [ :osx, :ios ]
@subspec.available_platforms.first.to_sym.should == :ios
......@@ -373,7 +373,7 @@ describe "A Pod::Specification subspec" do
end
it "resolves reports correctly the supported platforms" do
@spec.platform = nil
@spec.stubs(:platform).returns nil
@subspec.platform = :ios, '4.0'
@subsubspec.platform = :ios, '5.0'
@spec.supports_platform?(:ios).should.be.true
......@@ -406,7 +406,7 @@ describe "A Pod::Specification subspec" do
@subspec.active_platform.should == :ios
@subsubspec.active_platform.should == :ios
@spec.platform = nil
@spec.stubs(:platform).returns nil
@subsubspec.activate_platform(:osx)
@subspec.active_platform.should == :osx
@spec.active_platform.should == :osx
......
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