Commit 0c8d53a4 authored by Eloy Duran's avatar Eloy Duran

Add Specification#platform.

parent e70377c0
......@@ -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"
......
* 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.
......@@ -115,6 +115,8 @@ module Pod
flags
end
attr_accessor :platform
# Not attributes
include Config::Mixin
......@@ -163,6 +165,10 @@ module Pod
@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 @@ module Pod
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
......
......@@ -131,6 +131,7 @@ describe "A Pod::Specification loaded from a podspec" do
@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 @@ describe "A Pod::Specification, with installed source," do
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
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