Skip to content
Browse files

Add Specification#platform.

  • Loading branch information...
1 parent e70377c commit 0c8d53a4f1aff8ca1c65353870009c0555ccc409 @alloy alloy committed
View
9 Rakefile
@@ -65,6 +65,15 @@ namespace :spec do
task :all do
sh "macbacon -a"
end
+
+ desc "Rebuild all the fixture tarballs"
+ task :rebuild_fixture_tarballs do
+ tarballs = FileList['spec/fixtures/**/*.tar.gz']
+ tarballs.each do |tarball|
+ basename = File.basename(tarball)
+ sh "cd #{File.dirname(tarball)} && rm #{basename} && tar -zcf #{basename} #{basename[0..-8]}"
+ end
+ end
end
desc "Run all specs"
View
3 TODO
@@ -1 +1,2 @@
-* Check exit statuses of commands performed and raise when necessary.
+* The user *has* to specify the platform of the project in the Podfile.
+* Based on the platform setting of the Podfile the appropriate xcode project template should be used.
View
36 lib/cocoapods/specification.rb
@@ -115,6 +115,8 @@ def compiler_flags
flags
end
+ attr_accessor :platform
+
# Not attributes
include Config::Mixin
@@ -163,6 +165,10 @@ def from_podfile?
@name.nil? && @version.nil?
end
+ def any_platform?
+ @platform.nil?
+ end
+
# Returns all source files of this pod including header files.
def expanded_source_files
files = []
@@ -227,18 +233,24 @@ def inspect
end
def validate!
- attrs = []
- attrs << "`name'" unless @name
- attrs << "`version'" unless @version
- attrs << "`summary'" unless @summary
- attrs << "`homepage'" unless @homepage
- attrs << "`author(s)'" unless @authors
- attrs << "either `source' or `part_of'" unless @source || @part_of
- attrs << "`source_files'" unless @source_files
- unless attrs.empty?
- raise Informative, "The following required " \
- "#{attrs.size == 1 ? 'attribute is' : 'attributes are'} " \
- "missing: #{attrs.join(", ")}"
+ missing = []
+ missing << "`name'" unless @name
+ missing << "`version'" unless @version
+ missing << "`summary'" unless @summary
+ missing << "`homepage'" unless @homepage
+ missing << "`author(s)'" unless @authors
+ missing << "either `source' or `part_of'" unless @source || @part_of
+ missing << "`source_files'" unless @source_files
+
+ incorrect = []
+ allowed = [nil, :ios, :osx]
+ incorrect << ["`platform'", allowed] unless allowed.include?(@platform)
+
+ unless missing.empty? && incorrect.empty?
+ message = "The following #{(missing + incorrect).size == 1 ? 'attribute is' : 'attributes are'}:\n"
+ message << "* missing: #{missing.join(", ")}" unless missing.empty?
+ message << "* incorrect: #{incorrect.map { |x| "#{x[0]} (#{x[1..-1]})" }.join(", ")}" unless incorrect.empty?
+ raise Informative, message
end
end
View
BIN spec/fixtures/banana-lib.tar.gz
Binary file not shown.
View
BIN spec/fixtures/spec-repos/master.tar.gz
Binary file not shown.
View
30 spec/unit/specification_spec.rb
@@ -131,6 +131,7 @@
@spec.compiler_flags = "-Wunused-value"
@spec.compiler_flags.should == "-Wunused-value -fobj-arc"
end
+
end
describe "A Pod::Specification that's part of another pod's source" do
@@ -256,10 +257,33 @@ def @spec.copy_header_mapping(from)
end
describe "A Pod::Specification, in general," do
+ before do
+ @spec = Pod::Spec.new
+ end
+
+ def validate(&block)
+ Proc.new(&block).should.raise(Pod::Informative)
+ end
+
it "raises if the specification does not contain the minimum required attributes" do
- exception = lambda {
- Pod::Spec.new.validate!
- }.should.raise Pod::Informative
+ exception = validate { @spec.validate! }
exception.message =~ /name.+?version.+?summary.+?homepage.+?authors.+?(source|part_of).+?source_files/
end
+
+ it "raises if the platform is unrecognized" do
+ validate { @spec.validate! }.message.should.not.include 'platform'
+ @spec.platform = :ios
+ validate { @spec.validate! }.message.should.not.include 'platform'
+ @spec.platform = :osx
+ validate { @spec.validate! }.message.should.not.include 'platform'
+ @spec.platform = :windows
+ validate { @spec.validate! }.message.should.include 'platform'
+ end
+
+ it "returns the platform that the static library should be build for" do
+ @spec.should.be.any_platform
+ @spec.platform = :ios
+ @spec.platform.should == :ios
+ @spec.should.not.be.any_platform
+ end
end

0 comments on commit 0c8d53a

Please sign in to comment.
Something went wrong with that request. Please try again.