Permalink
Browse files

[Platform] Support initialization from another platform.

  • Loading branch information...
1 parent 6bbdfa3 commit 8d1430a8bd1b30803f093afccf827050e7d68c4b @fabiopelosin fabiopelosin committed Jun 7, 2012
Showing with 32 additions and 5 deletions.
  1. +26 −5 lib/cocoapods/platform.rb
  2. +6 −0 spec/unit/platform_spec.rb
View
31 lib/cocoapods/platform.rb
@@ -10,11 +10,32 @@ def self.osx
attr_reader :deployment_target
- def initialize(symbolic_name = nil, deployment_target = nil)
- @symbolic_name = symbolic_name
- 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)
+ ##
+ # Public: Constructs a platform from either another platform or by
+ # specifying the symbolic name and optionally the deployment target.
+ #
+ # 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.
+
@fabiopelosin
CocoaPods member
fabiopelosin added a line comment Jun 7, 2012

@alloy I agree about not requiring a coding style but specifying a preference it would be great, currently I'm using the GitHub's one.

@alloy
CocoaPods member
alloy added a line comment Jun 7, 2012

@irrationalfab I think the style guide is good for Ruby code. But for documentation we should use YARD which will allow us to generate documentation for dynamic methods (such as the ones in Specification) as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ 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
View
6 spec/unit/platform_spec.rb
@@ -7,6 +7,12 @@
Pod::Platform.osx.should == Pod::Platform.new(:osx)
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
@platform = Pod::Platform.ios
end

0 comments on commit 8d1430a

Please sign in to comment.