Commit 0c5c43c1 authored by Fabio Pelosin's avatar Fabio Pelosin

Speficiation#activate_for_platform and collateral improvements.

parent 8b505899
This diff is collapsed.
...@@ -63,8 +63,7 @@ module Pod ...@@ -63,8 +63,7 @@ module Pod
@target = @project.add_pod_target(@target_definition.label, @target_definition.platform) @target = @project.add_pod_target(@target_definition.label, @target_definition.platform)
pods.each do |pod| pods.each do |pod|
# TODO add methods like xcconfig to LocalPod as well? (which returns the correct platform) xcconfig.merge!(pod.specification.xcconfig)
xcconfig.merge!(pod.specification.xcconfig[@target_definition.platform.name])
pod.add_to_target(@target) pod.add_to_target(@target)
# TODO: this doesn't need to be done here, it has nothing to do with the target # TODO: this doesn't need to be done here, it has nothing to do with the target
......
...@@ -2,10 +2,10 @@ module Pod ...@@ -2,10 +2,10 @@ module Pod
class LocalPod class LocalPod
attr_reader :specification attr_reader :specification
attr_reader :sandbox attr_reader :sandbox
attr_reader :platform
def initialize(specification, sandbox, platform) def initialize(specification, sandbox, platform)
@specification, @sandbox, @platform = specification, sandbox, platform @specification, @sandbox = specification, sandbox
@specification.activate_platform(platform)
end end
def self.from_podspec(podspec, sandbox, platform) def self.from_podspec(podspec, sandbox, platform)
...@@ -28,6 +28,10 @@ module Pod ...@@ -28,6 +28,10 @@ module Pod
specification.name specification.name
end end
def platform
specification.active_platform
end
def create def create
root.mkpath unless exists? root.mkpath unless exists?
end end
...@@ -83,7 +87,7 @@ module Pod ...@@ -83,7 +87,7 @@ module Pod
def add_to_target(target) def add_to_target(target)
implementation_files.each do |file| implementation_files.each do |file|
target.add_source_file(file, nil, specification.compiler_flags[@platform.name].strip) target.add_source_file(file, nil, specification.compiler_flags.strip)
end end
end end
...@@ -92,7 +96,7 @@ module Pod ...@@ -92,7 +96,7 @@ module Pod
end end
def dependencies def dependencies
specification.dependencies[@platform.name] specification.dependencies
end end
private private
...@@ -116,8 +120,7 @@ module Pod ...@@ -116,8 +120,7 @@ module Pod
end end
end end
def expanded_paths(platforms_with_patterns, options = {}) def expanded_paths(patterns, options = {})
patterns = platforms_with_patterns.is_a?(Hash) ? platforms_with_patterns[@platform.name] : platforms_with_patterns
patterns.map do |pattern| patterns.map do |pattern|
pattern = root + pattern pattern = root + pattern
......
...@@ -34,7 +34,7 @@ module Pod ...@@ -34,7 +34,7 @@ module Pod
end end
end end
def support?(other) def supports?(other)
return true if @symbolic_name.nil? || other.nil? return true if @symbolic_name.nil? || other.nil?
@symbolic_name == other.name && (deployment_target.nil? || other.deployment_target.nil? || deployment_target >= other.deployment_target) @symbolic_name == other.name && (deployment_target.nil? || other.deployment_target.nil? || deployment_target >= other.deployment_target)
end end
......
...@@ -60,8 +60,9 @@ module Pod ...@@ -60,8 +60,9 @@ module Pod
spec = set.specification_by_name(dependency.name) spec = set.specification_by_name(dependency.name)
@loaded_specs << spec.name @loaded_specs << spec.name
@specs[spec.name] = spec @specs[spec.name] = spec
spec.activate_platform(target_definition.platform)
# And recursively load the dependencies of the spec. # And recursively load the dependencies of the spec.
find_dependency_sets(spec, (spec.dependencies[target_definition.platform.to_sym]), target_definition) if spec.dependencies[target_definition.platform.to_sym] find_dependency_sets(spec, spec.dependencies, target_definition) if spec.dependencies
end end
validate_platform!(spec || @specs[dependency.name], target_definition) validate_platform!(spec || @specs[dependency.name], target_definition)
end end
...@@ -69,7 +70,7 @@ module Pod ...@@ -69,7 +70,7 @@ module Pod
end end
def validate_platform!(spec, target) def validate_platform!(spec, target)
unless spec.available_platforms.any? { |platform| target.platform.support?(platform) } unless spec.available_platforms.any? { |platform| target.platform.supports?(platform) }
raise Informative, "[!] The platform of the target `#{target.name}' (#{target.platform}) is not compatible with `#{spec}' which has a minimun requirement of #{spec.available_platforms.join(' - ')}.".red raise Informative, "[!] The platform of the target `#{target.name}' (#{target.platform}) is not compatible with `#{spec}' which has a minimun requirement of #{spec.available_platforms.join(' - ')}.".red
end end
end end
......
...@@ -24,7 +24,7 @@ module Pod ...@@ -24,7 +24,7 @@ module Pod
spec.subspec_by_name(subspec_name) spec.subspec_by_name(subspec_name)
end end
attr_accessor :defined_in_file, :parent attr_accessor :parent
def initialize(parent = nil, name = nil) def initialize(parent = nil, name = nil)
@parent, @name = parent, name if parent @parent, @name = parent, name if parent
...@@ -37,8 +37,6 @@ module Pod ...@@ -37,8 +37,6 @@ module Pod
@define_for_platforms = [:osx, :ios] @define_for_platforms = [:osx, :ios]
@clean_paths, @subspecs = [], [] @clean_paths, @subspecs = [], []
@deployment_target = {} @deployment_target = {}
@platform = Platform.new(nil)
initialized_multiplatform_attributes initialized_multiplatform_attributes
# deprecated attributes # deprecated attributes
...@@ -48,11 +46,11 @@ module Pod ...@@ -48,11 +46,11 @@ module Pod
# Deprecated attributes # Deprecated attributes
# TODO: remove once master repo and fixtures are updated # TODO: remove once master repo and fixtures are updated
def part_of_dependency=(value) def part_of_dependency=(value)
puts "[!] `part_of_dependency' is deprecated in #{name}" puts "[!] `part_of_dependency' is deprecated in #{name}".cyan
end end
def part_of=(value) def part_of=(value)
puts "[!] `part_of' is deprecated in #{name}" puts "[!] `part_of' is deprecated in #{name}".cyan
end end
# Normal attributes # Normal attributes
...@@ -107,13 +105,24 @@ module Pod ...@@ -107,13 +105,24 @@ module Pod
top_attr_writer attr, writer_labmda top_attr_writer attr, writer_labmda
end end
# TODO: First defined
def platform
@platform || ( @parent ? @parent.platform : Platform.new(nil) )
end
def platform=(platform)
@platform = Platform.new(*platform)
end
top_attr_accessor :defined_in_file
top_attr_accessor :homepage top_attr_accessor :homepage
top_attr_accessor :source top_attr_accessor :source
top_attr_accessor :documentation top_attr_accessor :documentation
top_attr_accessor :requires_arc top_attr_accessor :requires_arc
top_attr_accessor :license, lambda { |l| ( l.kind_of? String ) ? { :type => l } : l } top_attr_accessor :license, lambda { |l| ( l.kind_of? String ) ? { :type => l } : l }
top_attr_accessor :version, lambda { |v| Version.new(v) } top_attr_accessor :version, lambda { |v| Version.new(v) }
top_attr_accessor :platform, lambda { |p| Platform.new(*p) }
top_attr_accessor :readme_file, lambda { |file| Pathname.new(file) } top_attr_accessor :readme_file, lambda { |file| Pathname.new(file) }
top_attr_accessor :authors, lambda { |a| parse_authors(a) } top_attr_accessor :authors, lambda { |a| parse_authors(a) }
alias_method :author=, :authors= alias_method :author=, :authors=
...@@ -167,14 +176,19 @@ module Pod ...@@ -167,14 +176,19 @@ module Pod
# It returns the value of the attribute for the current platform. In this way clients do not need to be aware of wich # It returns the value of the attribute for the current platform. In this way clients do not need to be aware of wich
# attributes are multiplatform # attributes are multiplatform
def self.platform_attr_reader(attr) def self.platform_attr_reader(attr)
# TODO: implement define_method(attr) do
attr_reader attr raise Informative, "#{self.inspect}##{attr} not activated for a platform before consumption." unless active_platform
instance_variable_get("@#{attr}")[active_platform]
end
end end
# It returns the value of a pod merged with upstream. The optional lambda can specify how to merge the values # It returns the value of a pod merged with upstream. The optional lambda can specify how to merge the values
def self.pltf_chained_attr_reader(attr, merge_lambda = nil) def self.pltf_chained_attr_reader(attr, merge_lambda = nil)
# TODO: chain the value with the upstream # TODO: chain the value with the upstream
attr_reader attr define_method(attr) do
raise Informative, "#{self.inspect}##{attr} not activated for a platform before consumption." unless active_platform
instance_variable_get("@#{attr}")[active_platform]
end
end end
def self.platform_attr_writer(attr, block = nil) def self.platform_attr_writer(attr, block = nil)
...@@ -216,35 +230,27 @@ module Pod ...@@ -216,35 +230,27 @@ module Pod
alias_method :library=, :libraries= alias_method :library=, :libraries=
def xcconfig def xcconfig
result = {}
@define_for_platforms.each do |platform|
if @parent if @parent
chained = @xcconfig[platform].dup.unshift @parent.xcconfig[platform] chained = @parent.xcconfig.dup.merge! @xcconfig[active_platform]
else else
chained = @xcconfig[platform].dup chained = @xcconfig[active_platform].dup
end end
chained.merge!({ 'OTHER_LDFLAGS' => '-l' << libraries[platform].join(' -l').strip }) unless libraries[platform].empty? chained.merge!({ 'OTHER_LDFLAGS' => '-l' << libraries.join(' -l').strip }) unless libraries.empty?
chained.merge!({ 'OTHER_LDFLAGS' => '-framework ' << frameworks[platform].join(' -framework ').strip }) unless frameworks[platform].empty? chained.merge!({ 'OTHER_LDFLAGS' => '-framework ' << frameworks.join(' -framework ').strip }) unless frameworks.empty?
result[platform] = chained chained
end
result
end end
platform_attr_writer :xcconfig, lambda {|value, current| current.tap { |c| c.merge!(value) } } platform_attr_writer :xcconfig, lambda {|value, current| current.tap { |c| c.merge!(value) } }
def compiler_flags def compiler_flags
result = {}
@define_for_platforms.each do |platform|
if @parent if @parent
chained = @compiler_flags[platform].dup.unshift @parent.compiler_flags[platform] chained = @compiler_flags[active_platform].dup.unshift @parent.compiler_flags[active_platform]
else else
chained = @compiler_flags[platform].dup chained = @compiler_flags[active_platform].dup
chained.unshift '-fobjc-arc' if @requires_arc chained.unshift '-fobjc-arc' if @requires_arc
chained.unshift '' chained.unshift ''
end end
result[platform] = chained.join(' ') chained.join(' ')
end
result
end end
platform_attr_writer :compiler_flags, lambda {|value, current| current << value } platform_attr_writer :compiler_flags, lambda {|value, current| current << value }
...@@ -259,12 +265,8 @@ module Pod ...@@ -259,12 +265,8 @@ module Pod
end end
def dependencies def dependencies
result = {} raise Informative, "#{self.inspect}#dependencies not activated for a platform before consumption." unless active_platform
@define_for_platforms.each do |platform| @dependencies[active_platform] + subspecs.map { |s| Dependency.new(s.name, version) }
inherited_subspecs = subspecs.map {|s| Dependency.new(s.name, version) }
result[platform] = @dependencies[platform] + inherited_subspecs
end
result
end end
# TODO: make top level? # TODO: make top level?
...@@ -329,12 +331,17 @@ module Pod ...@@ -329,12 +331,17 @@ module Pod
available_platforms.any? { |p| platform.supports? p } available_platforms.any? { |p| platform.supports? p }
end end
# Defines the active platform for comsumption of the specification. # Defines the active platform for comsumption of the specification and returns self
def activate_for_platform(platform) def activate_platform(platform)
raise "[!] #{name} does not support platform".red unless supports_platform?(plaform) platform = Platform.new(platform) if platform.is_a? Hash
@active_platform = platform raise "[!] #{name} does not support platform".red unless supports_platform?(platform)
top_level_parent.active_platform = platform.to_sym
self
end end
# The active platform needs to be the same accross the chain
top_attr_accessor :active_platform
def local? def local?
!source.nil? && !source[:local].nil? !source.nil? && !source[:local].nil?
end end
......
...@@ -23,7 +23,8 @@ describe "Pod::Command::Spec#create" do ...@@ -23,7 +23,8 @@ describe "Pod::Command::Spec#create" do
it "creates a new podspec stub file" do it "creates a new podspec stub file" do
run_command('spec', 'create', 'Bananas') run_command('spec', 'create', 'Bananas')
path = temporary_directory + 'Bananas.podspec' path = temporary_directory + 'Bananas.podspec'
spec = Pod::Specification.from_file(path) spec = Pod::Specification.from_file(path).activate_platform(:ios)
spec.name.should == 'Bananas' spec.name.should == 'Bananas'
spec.license.should == { :type => "MIT", :file => "LICENSE" } spec.license.should == { :type => "MIT", :file => "LICENSE" }
spec.version.should == Pod::Version.new('0.0.1') spec.version.should == Pod::Version.new('0.0.1')
...@@ -32,7 +33,7 @@ describe "Pod::Command::Spec#create" do ...@@ -32,7 +33,7 @@ describe "Pod::Command::Spec#create" do
spec.authors.should == { `git config --get user.name`.strip => `git config --get user.email`.strip} spec.authors.should == { `git config --get user.name`.strip => `git config --get user.email`.strip}
spec.source.should == { :git => 'http://EXAMPLE/Bananas.git', :tag => '0.0.1' } spec.source.should == { :git => 'http://EXAMPLE/Bananas.git', :tag => '0.0.1' }
spec.description.should == 'An optional longer description of Bananas.' spec.description.should == 'An optional longer description of Bananas.'
spec.source_files[:ios].should == ['Classes', 'Classes/**/*.{h,m}'] spec.source_files.should == ['Classes', 'Classes/**/*.{h,m}']
end end
it "correctly creates a podspec from github" do it "correctly creates a podspec from github" do
...@@ -128,13 +129,13 @@ describe "Pod::Command::Spec#lint" do ...@@ -128,13 +129,13 @@ describe "Pod::Command::Spec#lint" do
spec_file = fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec' spec_file = fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec'
cmd = command('spec', 'lint', '--quick', spec_file.to_s) cmd = command('spec', 'lint', '--quick', spec_file.to_s)
lambda { cmd.run }.should.raise Pod::Informative lambda { cmd.run }.should.raise Pod::Informative
cmd.output.should.include "Missing license[:file] or [:text]" cmd.output.should.include "Missing license file or text"
end end
it "respects the -only--errors option" do it "respects the -only--errors option" do
spec_file = fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec' spec_file = fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec'
cmd = command('spec', 'lint', '--quick', '--only-errors', spec_file.to_s) cmd = command('spec', 'lint', '--quick', '--only-errors', spec_file.to_s)
lambda { cmd.run }.should.not.raise lambda { cmd.run }.should.not.raise
cmd.output.should.include "Missing license[:file] or [:text]" cmd.output.should.include "Missing license file or text"
end end
end end
...@@ -19,7 +19,7 @@ describe "Pod::Command::Spec::Linter" do ...@@ -19,7 +19,7 @@ describe "Pod::Command::Spec::Linter" do
it "fails a specifications that does not contain the minimum required attributes" do it "fails a specifications that does not contain the minimum required attributes" do
spec, file = write_podspec('Pod::Spec.new do |s| end') spec, file = write_podspec('Pod::Spec.new do |s| end')
linter = Pod::Command::Spec::Linter.new(spec, file) linter = Pod::Command::Spec::Linter.new(spec)
linter.lenient, linter.quick = true, true linter.lenient, linter.quick = true, true
linter.lint.should == false linter.lint.should == false
linter.errors.join(' | ') =~ /name.*version.*summary.*homepage.*authors.*(source.*part_of).*source_files/ linter.errors.join(' | ') =~ /name.*version.*summary.*homepage.*authors.*(source.*part_of).*source_files/
...@@ -27,7 +27,7 @@ describe "Pod::Command::Spec::Linter" do ...@@ -27,7 +27,7 @@ describe "Pod::Command::Spec::Linter" do
it "fails specifications if the name does not match the name of the file" do it "fails specifications if the name does not match the name of the file" do
spec, file = write_podspec(stub_podspec(/s.name *= 'JSONKit'/, "s.name = 'JSONKitAAA'")) spec, file = write_podspec(stub_podspec(/s.name *= 'JSONKit'/, "s.name = 'JSONKitAAA'"))
linter = Pod::Command::Spec::Linter.new(spec, file) linter = Pod::Command::Spec::Linter.new(spec)
linter.lenient, linter.quick = true, true linter.lenient, linter.quick = true, true
linter.lint.should == false linter.lint.should == false
linter.errors.count.should == 1 linter.errors.count.should == 1
...@@ -36,16 +36,16 @@ describe "Pod::Command::Spec::Linter" do ...@@ -36,16 +36,16 @@ describe "Pod::Command::Spec::Linter" do
it "fails a specification if a path starts with a slash" do it "fails a specification if a path starts with a slash" do
spec, file = write_podspec(stub_podspec(/s.source_files = 'JSONKit\.\*'/, "s.source_files = '/JSONKit.*'")) spec, file = write_podspec(stub_podspec(/s.source_files = 'JSONKit\.\*'/, "s.source_files = '/JSONKit.*'"))
linter = Pod::Command::Spec::Linter.new(spec, file) linter = Pod::Command::Spec::Linter.new(spec)
linter.lenient, linter.quick = true, true linter.lenient, linter.quick = true, true
linter.lint.should == false linter.lint.should == false
linter.errors.count.should == 1 linter.errors.count.should == 1
linter.errors[0].should =~ /Paths cannot start with a slash/ linter.errors[0].should =~ /Paths cannot start with a slash/
end end
it "fails a specification if the plafrom is unrecognized" do it "fails a specification if the platform is unrecognized" do
spec, file = write_podspec(stub_podspec(/s.name *= 'JSONKit'/, "s.name = 'JSONKit'\ns.platform = :iososx\n")) spec, file = write_podspec(stub_podspec(/s.name *= 'JSONKit'/, "s.name = 'JSONKit'\ns.platform = :iososx\n"))
linter = Pod::Command::Spec::Linter.new(spec, file) linter = Pod::Command::Spec::Linter.new(spec)
linter.lenient, linter.quick = true, true linter.lenient, linter.quick = true, true
linter.lint.should == false linter.lint.should == false
linter.errors.count.should == 1 linter.errors.count.should == 1
...@@ -54,7 +54,7 @@ describe "Pod::Command::Spec::Linter" do ...@@ -54,7 +54,7 @@ describe "Pod::Command::Spec::Linter" do
it "fails validation if the specification contains warnings" do it "fails validation if the specification contains warnings" do
spec, file = write_podspec(stub_podspec) spec, file = write_podspec(stub_podspec)
linter = Pod::Command::Spec::Linter.new(spec, file) linter = Pod::Command::Spec::Linter.new(spec)
linter.lenient, linter.quick = false, true linter.lenient, linter.quick = false, true
linter.lint.should == false linter.lint.should == false
linter.errors.should.be.empty linter.errors.should.be.empty
...@@ -63,7 +63,7 @@ describe "Pod::Command::Spec::Linter" do ...@@ -63,7 +63,7 @@ describe "Pod::Command::Spec::Linter" do
it "validates in lenient mode if there are no erros but there are warnings" do it "validates in lenient mode if there are no erros but there are warnings" do
spec, file = write_podspec(stub_podspec) spec, file = write_podspec(stub_podspec)
linter = Pod::Command::Spec::Linter.new(spec, file) linter = Pod::Command::Spec::Linter.new(spec)
linter.lenient, linter.quick = true, true linter.lenient, linter.quick = true, true
linter.lint.should == true linter.lint.should == true
linter.errors.should.be.empty linter.errors.should.be.empty
...@@ -72,7 +72,7 @@ describe "Pod::Command::Spec::Linter" do ...@@ -72,7 +72,7 @@ describe "Pod::Command::Spec::Linter" do
it "respects quick mode" do it "respects quick mode" do
spec, file = write_podspec(stub_podspec) spec, file = write_podspec(stub_podspec)
linter = Pod::Command::Spec::Linter.new(spec, file) linter = Pod::Command::Spec::Linter.new(spec)
linter.expects(:peform_multiplatform_analysis).never linter.expects(:peform_multiplatform_analysis).never
linter.expects(:install_pod).never linter.expects(:install_pod).never
linter.expects(:xcodebuild_output_for_platfrom).never linter.expects(:xcodebuild_output_for_platfrom).never
...@@ -83,7 +83,7 @@ describe "Pod::Command::Spec::Linter" do ...@@ -83,7 +83,7 @@ describe "Pod::Command::Spec::Linter" do
it "produces deprecation notices" do it "produces deprecation notices" do
spec, file = write_podspec(stub_podspec(/s\.source_files = 'JSONKit\.\*'/, "s.source_files = 'JSONKit.*'\n if config.ios?\nend")) spec, file = write_podspec(stub_podspec(/s\.source_files = 'JSONKit\.\*'/, "s.source_files = 'JSONKit.*'\n if config.ios?\nend"))
linter = Pod::Command::Spec::Linter.new(spec, file) linter = Pod::Command::Spec::Linter.new(spec)
linter.lenient, linter.quick = false, true linter.lenient, linter.quick = false, true
linter.lint.should == false linter.lint.should == false
linter.errors.should.be.empty linter.errors.should.be.empty
...@@ -92,7 +92,7 @@ describe "Pod::Command::Spec::Linter" do ...@@ -92,7 +92,7 @@ describe "Pod::Command::Spec::Linter" do
it "uses xcodebuild to generate notes and warnings" do it "uses xcodebuild to generate notes and warnings" do
spec, file = write_podspec(stub_podspec) spec, file = write_podspec(stub_podspec)
linter = Pod::Command::Spec::Linter.new(spec, file) linter = Pod::Command::Spec::Linter.new(spec)
linter.lenient, linter.quick = false, false linter.lenient, linter.quick = false, false
linter.lint.should == false linter.lint.should == false
linter.notes.join(' | ').should.include "JSONKit/JSONKit.m:1640:27: warning: equality comparison with extraneous parentheses" unless `which xcodebuild`.strip.empty? linter.notes.join(' | ').should.include "JSONKit/JSONKit.m:1640:27: warning: equality comparison with extraneous parentheses" unless `which xcodebuild`.strip.empty?
...@@ -100,8 +100,8 @@ describe "Pod::Command::Spec::Linter" do ...@@ -100,8 +100,8 @@ describe "Pod::Command::Spec::Linter" do
it "checks for file patterns" do it "checks for file patterns" do
spec, file = write_podspec(stub_podspec(/s\.source_files = 'JSONKit\.\*'/, "s.source_files = 'JSONKit.*'\ns.resources = 'WRONG_FOLDER'")) spec, file = write_podspec(stub_podspec(/s\.source_files = 'JSONKit\.\*'/, "s.source_files = 'JSONKit.*'\ns.resources = 'WRONG_FOLDER'"))
linter = Pod::Command::Spec::Linter.new(spec, file) linter = Pod::Command::Spec::Linter.new(spec)
linter.stubs(:xcodebuild_output_for_platfrom).returns([]) linter.stubs(:xcodebuild_output).returns([])
linter.lenient, linter.quick = false, false linter.lenient, linter.quick = false, false
linter.lint.should == false linter.lint.should == false
linter.errors.join(' | ').should.include "[resources = 'WRONG_FOLDER'] -> did not match any file" linter.errors.join(' | ').should.include "[resources = 'WRONG_FOLDER'] -> did not match any file"
......
...@@ -68,34 +68,34 @@ describe "Pod::Platform with a nil value" do ...@@ -68,34 +68,34 @@ describe "Pod::Platform with a nil value" do
end end
end end
describe "Pod::Platform#support?" do describe "Pod::Platform#supports?" do
it "supports another platform is with the same operating system" do it "supports another platform is with the same operating system" do
p1 = Pod::Platform.new(:ios) p1 = Pod::Platform.new(:ios)
p2 = Pod::Platform.new(:ios) p2 = Pod::Platform.new(:ios)
p1.should.support?(p2) p1.should.supports?(p2)
p1 = Pod::Platform.new(:osx) p1 = Pod::Platform.new(:osx)
p2 = Pod::Platform.new(:osx) p2 = Pod::Platform.new(:osx)
p1.should.support?(p2) p1.should.supports?(p2)
end end
it "supports a nil platform" do it "supports a nil platform" do
p1 = Pod::Platform.new(:ios) p1 = Pod::Platform.new(:ios)
p1.should.support?(nil) p1.should.supports?(nil)
end end
it "supports a platform with a lower or equal deployment_target" do it "supports a platform with a lower or equal deployment_target" do
p1 = Pod::Platform.new(:ios, '5.0') p1 = Pod::Platform.new(:ios, '5.0')
p2 = Pod::Platform.new(:ios, '4.0') p2 = Pod::Platform.new(:ios, '4.0')
p1.should.support?(p1) p1.should.supports?(p1)
p1.should.support?(p2) p1.should.supports?(p2)
p2.should.not.support?(p1) p2.should.not.supports?(p1)
end end
it "supports a platform regardless of the deployment_target if one of the two does not specify it" do it "supports a platform regardless of the deployment_target if one of the two does not specify it" do
p1 = Pod::Platform.new(:ios) p1 = Pod::Platform.new(:ios)
p2 = Pod::Platform.new(:ios, '4.0') p2 = Pod::Platform.new(:ios, '4.0')
p1.should.support?(p2) p1.should.supports?(p2)
p2.should.support?(p1) p2.should.supports?(p1)
end end
end end
...@@ -57,24 +57,23 @@ describe "A Pod::Specification loaded from a podspec" do ...@@ -57,24 +57,23 @@ describe "A Pod::Specification loaded from a podspec" do
end end
it "returns the pod's source files" do it "returns the pod's source files" do
@spec.source_files[:ios].should == ['Classes/*.{h,m}', 'Vendor'] @spec.activate_platform(:ios).source_files.should == ['Classes/*.{h,m}', 'Vendor']
@spec.source_files[:osx].should == ['Classes/*.{h,m}', 'Vendor'] @spec.activate_platform(:osx).source_files.should == ['Classes/*.{h,m}', 'Vendor']
end end
it "returns the pod's dependencies" do it "returns the pod's dependencies" do
expected = Pod::Dependency.new('monkey', '~> 1.0.1', '< 1.0.9') expected = Pod::Dependency.new('monkey', '~> 1.0.1', '< 1.0.9')
@spec.dependencies.should == { :ios => [expected], :osx => [expected] } @spec.activate_platform(:ios).dependencies.should == [expected]
@spec.activate_platform(:osx).dependencies.should == [expected]
end end
it "returns the pod's xcconfig settings" do it "returns the pod's xcconfig settings" do
@spec.xcconfig[:ios].should == { @spec.activate_platform(:ios).xcconfig.should == { 'OTHER_LDFLAGS' => '-framework SystemConfiguration' }
'OTHER_LDFLAGS' => '-framework SystemConfiguration'
}
end end
it "has a shortcut to add frameworks to the xcconfig" do it "has a shortcut to add frameworks to the xcconfig" do
@spec.frameworks = 'CFNetwork', 'CoreText' @spec.frameworks = 'CFNetwork', 'CoreText'
@spec.xcconfig[:ios].should == { @spec.activate_platform(:ios).xcconfig.should == {
'OTHER_LDFLAGS' => '-framework SystemConfiguration ' \ 'OTHER_LDFLAGS' => '-framework SystemConfiguration ' \
'-framework CFNetwork ' \ '-framework CFNetwork ' \
'-framework CoreText' '-framework CoreText'
...@@ -83,7 +82,7 @@ describe "A Pod::Specification loaded from a podspec" do ...@@ -83,7 +82,7 @@ describe "A Pod::Specification loaded from a podspec" do
it "has a shortcut to add libraries to the xcconfig" do it "has a shortcut to add libraries to the xcconfig" do
@spec.libraries = 'z', 'xml2' @spec.libraries = 'z', 'xml2'
@spec.xcconfig[:ios].should == { @spec.activate_platform(:ios).xcconfig.should == {
'OTHER_LDFLAGS' => '-framework SystemConfiguration -lz -lxml2' 'OTHER_LDFLAGS' => '-framework SystemConfiguration -lz -lxml2'
} }
end end
...@@ -102,9 +101,11 @@ describe "A Pod::Specification loaded from a podspec" do ...@@ -102,9 +101,11 @@ describe "A Pod::Specification loaded from a podspec" do
it "adds compiler flags if ARC is required" do it "adds compiler flags if ARC is required" do
@spec.parent.should == nil @spec.parent.should == nil
@spec.requires_arc = true @spec.requires_arc = true
@spec.compiler_flags.should == { :ios => " -fobjc-arc", :osx => " -fobjc-arc" } @spec.activate_platform(:ios).compiler_flags.should == " -fobjc-arc"
@spec.activate_platform(:osx).compiler_flags.should == " -fobjc-arc"
@spec.compiler_flags = "-Wunused-value" @spec.compiler_flags = "-Wunused-value"
@spec.compiler_flags.should == { :ios => " -fobjc-arc -Wunused-value", :osx => " -fobjc-arc -Wunused-value" } @spec.activate_platform(:ios).compiler_flags.should == " -fobjc-arc -Wunused-value"
@spec.activate_platform(:osx).compiler_flags.should == " -fobjc-arc -Wunused-value"
end end
end end
...@@ -231,7 +232,8 @@ describe "A Pod::Specification subspec" do ...@@ -231,7 +232,8 @@ describe "A Pod::Specification subspec" do
end end
it "automatically forwards undefined attributes to the top level parent" do it "automatically forwards undefined attributes to the top level parent" do
[:version, :summary, :platform, :license, :authors, :requires_arc, :compiler_flags].each do |attr| @spec.activate_platform(:ios)
[:version, :summary, :platform, :license, :authors, :requires_arc].each do |attr|
@spec.subspecs.first.send(attr).should == @spec.send(attr) @spec.subspecs.first.send(attr).should == @spec.send(attr)
@spec.subspecs.first.subspecs.first.send(attr).should == @spec.send(attr) @spec.subspecs.first.subspecs.first.send(attr).should == @spec.send(attr)
end end
...@@ -243,6 +245,16 @@ describe "A Pod::Specification subspec" do ...@@ -243,6 +245,16 @@ describe "A Pod::Specification subspec" do
@spec.subspec_by_name('MainSpec/FirstSubSpec').should == @spec.subspecs.first @spec.subspec_by_name('MainSpec/FirstSubSpec').should == @spec.subspecs.first
@spec.subspec_by_name('MainSpec/FirstSubSpec/SecondSubSpec').should == @spec.subspecs.first.subspecs.first @spec.subspec_by_name('MainSpec/FirstSubSpec/SecondSubSpec').should == @spec.subspecs.first.subspecs.first
end end
xit "can be activated for a platorm"
xit "raises if not activated"
xit "returns self on activation for method chainablity"
xit "does not cache platform attributes and can activate another platform"
xit "resolves chained attributes"
xit "resolves not chained attributes"
xit "has the same active platform accross the chain attributes"
xit "raises a top level attribute is assigned to a spec with a parent"
end end
describe "A Pod::Specification with :local source" do describe "A Pod::Specification with :local source" do
...@@ -281,26 +293,31 @@ describe "A Pod::Specification, concerning its attributes that support different ...@@ -281,26 +293,31 @@ describe "A Pod::Specification, concerning its attributes that support different
end end
it "returns the same list of source files for each platform" do it "returns the same list of source files for each platform" do
@spec.source_files.should == { :ios => %w{ file1 file2 }, :osx => %w{ file1 file2 } } @spec.activate_platform(:ios).source_files.should == %w{ file1 file2 }
@spec.activate_platform(:osx).source_files.should == %w{ file1 file2 }
end end
it "returns the same list of resources for each platform" do it "returns the same list of resources for each platform" do
@spec.resources.should == { :ios => %w{ file1 file2 }, :osx => %w{ file1 file2 } } @spec.activate_platform(:ios).resources.should == %w{ file1 file2 }
@spec.activate_platform(:osx).resources.should == %w{ file1 file2 }
end end
it "returns the same list of xcconfig build settings for each platform" do it "returns the same list of xcconfig build settings for each platform" do
build_settings = { 'OTHER_LDFLAGS' => '-lObjC -lz -framework QuartzCore' } build_settings = { 'OTHER_LDFLAGS' => '-lObjC -lz -framework QuartzCore' }
@spec.xcconfig.should == { :ios => build_settings, :osx => build_settings } @spec.activate_platform(:ios).xcconfig.should == build_settings
@spec.activate_platform(:osx).xcconfig.should == build_settings
end end
it "returns the same list of compiler flags for each platform" do it "returns the same list of compiler flags for each platform" do
compiler_flags = ' -fobjc-arc -Wdeprecated-implementations' compiler_flags = ' -fobjc-arc -Wdeprecated-implementations'
@spec.compiler_flags.should == { :ios => compiler_flags, :osx => compiler_flags } @spec.activate_platform(:ios).compiler_flags.should == compiler_flags
@spec.activate_platform(:osx).compiler_flags.should == compiler_flags
end end
it "returns the same list of dependencies for each platform" do it "returns the same list of dependencies for each platform" do
dependencies = %w{ JSONKit SSZipArchive }.map { |name| Pod::Dependency.new(name) } dependencies = %w{ JSONKit SSZipArchive }.map { |name| Pod::Dependency.new(name) }
@spec.dependencies.should == { :ios => dependencies, :osx => dependencies } @spec.activate_platform(:ios).dependencies.should == dependencies
@spec.activate_platform(:osx).dependencies.should == dependencies
end end
end end
...@@ -335,18 +352,18 @@ describe "A Pod::Specification, concerning its attributes that support different ...@@ -335,18 +352,18 @@ describe "A Pod::Specification, concerning its attributes that support different
end end
it "returns a different list of source files for each platform" do it "returns a different list of source files for each platform" do
@spec.source_files.should == { :ios => %w{ file1 }, :osx => %w{ file1 file2 } } @spec.activate_platform(:ios).source_files.should == %w{ file1 }
@spec.activate_platform(:osx).source_files.should == %w{ file1 file2 }
end end
it "returns a different list of resources for each platform" do it "returns a different list of resources for each platform" do
@spec.resources.should == { :ios => %w{ file1 }, :osx => %w{ file1 file2 } } @spec.activate_platform(:ios).resources.should == %w{ file1 }
@spec.activate_platform(:osx).resources.should == %w{ file1 file2 }
end end
it "returns a different list of xcconfig build settings for each platform" do it "returns a different list of xcconfig build settings for each platform" do
@spec.xcconfig.should == { @spec.activate_platform(:ios).xcconfig.should == { 'OTHER_LDFLAGS' => '-lObjC -lz -framework QuartzCore' }
:ios => { 'OTHER_LDFLAGS' => '-lObjC -lz -framework QuartzCore' }, @spec.activate_platform(:osx).xcconfig.should == { 'OTHER_LDFLAGS' => '-lObjC -all_load -lz -lxml -framework QuartzCore -framework CoreData' }
:osx => { 'OTHER_LDFLAGS' => '-lObjC -all_load -lz -lxml -framework QuartzCore -framework CoreData' }
}
end end
it "returns the list of the supported platfroms and deployment targets" do it "returns the list of the supported platfroms and deployment targets" do
...@@ -356,17 +373,13 @@ describe "A Pod::Specification, concerning its attributes that support different ...@@ -356,17 +373,13 @@ describe "A Pod::Specification, concerning its attributes that support different
end end
it "returns the same list of compiler flags for each platform" do it "returns the same list of compiler flags for each platform" do
@spec.compiler_flags.should == { @spec.activate_platform(:ios).compiler_flags.should == ' -fobjc-arc -Wdeprecated-implementations'
:ios => ' -fobjc-arc -Wdeprecated-implementations', @spec.activate_platform(:osx).compiler_flags.should == ' -fobjc-arc -Wfloat-equal'
:osx => ' -fobjc-arc -Wfloat-equal'
}
end end
it "returns the same list of dependencies for each platform" do it "returns the same list of dependencies for each platform" do
@spec.dependencies.should == { @spec.activate_platform(:ios).dependencies.should == [Pod::Dependency.new('JSONKit')]
:ios => [Pod::Dependency.new('JSONKit')], @spec.activate_platform(:osx).dependencies.should == [Pod::Dependency.new('SSZipArchive')]
:osx => [Pod::Dependency.new('SSZipArchive')]
}
end end
end 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