From 9c71d5ab7a2e33f3fc5527b646421d90888c12b4 Mon Sep 17 00:00:00 2001 From: Fabio Pelosin Date: Sat, 9 Jun 2012 20:24:29 +0200 Subject: [PATCH] [Platform] Require name for initialization. --- lib/cocoapods/platform.rb | 20 ++------------------ spec/unit/platform_spec.rb | 16 ---------------- spec/unit/specification_spec.rb | 8 ++++---- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/lib/cocoapods/platform.rb b/lib/cocoapods/platform.rb index 0b40fb42a6..f082db2df0 100644 --- a/lib/cocoapods/platform.rb +++ b/lib/cocoapods/platform.rb @@ -1,8 +1,6 @@ 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 @@ def self.osx # 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 @@ def ==(other) # 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 @@ def to_s 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 @@ def to_sym 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? diff --git a/spec/unit/platform_spec.rb b/spec/unit/platform_spec.rb index b618ea7f83..fb5b980e8a 100644 --- a/spec/unit/platform_spec.rb +++ b/spec/unit/platform_spec.rb @@ -37,7 +37,6 @@ 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 @@ 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 @@ 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') diff --git a/spec/unit/specification_spec.rb b/spec/unit/specification_spec.rb index 713f04d30f..174b503fea 100644 --- a/spec/unit/specification_spec.rb +++ b/spec/unit/specification_spec.rb @@ -353,7 +353,7 @@ 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 @@ 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 @@ 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 @@ @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