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

Add Specification#platform.

parent e70377c0
...@@ -65,6 +65,15 @@ namespace :spec do ...@@ -65,6 +65,15 @@ namespace :spec do
task :all do task :all do
sh "macbacon -a" sh "macbacon -a"
end 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 end
desc "Run all specs" 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 ...@@ -115,6 +115,8 @@ module Pod
flags flags
end end
attr_accessor :platform
# Not attributes # Not attributes
include Config::Mixin include Config::Mixin
...@@ -163,6 +165,10 @@ module Pod ...@@ -163,6 +165,10 @@ module Pod
@name.nil? && @version.nil? @name.nil? && @version.nil?
end end
def any_platform?
@platform.nil?
end
# Returns all source files of this pod including header files. # Returns all source files of this pod including header files.
def expanded_source_files def expanded_source_files
files = [] files = []
...@@ -227,18 +233,24 @@ module Pod ...@@ -227,18 +233,24 @@ module Pod
end end
def validate! def validate!
attrs = [] missing = []
attrs << "`name'" unless @name missing << "`name'" unless @name
attrs << "`version'" unless @version missing << "`version'" unless @version
attrs << "`summary'" unless @summary missing << "`summary'" unless @summary
attrs << "`homepage'" unless @homepage missing << "`homepage'" unless @homepage
attrs << "`author(s)'" unless @authors missing << "`author(s)'" unless @authors
attrs << "either `source' or `part_of'" unless @source || @part_of missing << "either `source' or `part_of'" unless @source || @part_of
attrs << "`source_files'" unless @source_files missing << "`source_files'" unless @source_files
unless attrs.empty?
raise Informative, "The following required " \ incorrect = []
"#{attrs.size == 1 ? 'attribute is' : 'attributes are'} " \ allowed = [nil, :ios, :osx]
"missing: #{attrs.join(", ")}" 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
end end
......
...@@ -131,6 +131,7 @@ describe "A Pod::Specification loaded from a podspec" do ...@@ -131,6 +131,7 @@ describe "A Pod::Specification loaded from a podspec" do
@spec.compiler_flags = "-Wunused-value" @spec.compiler_flags = "-Wunused-value"
@spec.compiler_flags.should == "-Wunused-value -fobj-arc" @spec.compiler_flags.should == "-Wunused-value -fobj-arc"
end end
end end
describe "A Pod::Specification that's part of another pod's source" do 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 ...@@ -256,10 +257,33 @@ describe "A Pod::Specification, with installed source," do
end end
describe "A Pod::Specification, in general," do 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 it "raises if the specification does not contain the minimum required attributes" do
exception = lambda { exception = validate { @spec.validate! }
Pod::Spec.new.validate!
}.should.raise Pod::Informative
exception.message =~ /name.+?version.+?summary.+?homepage.+?authors.+?(source|part_of).+?source_files/ exception.message =~ /name.+?version.+?summary.+?homepage.+?authors.+?(source|part_of).+?source_files/
end 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 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