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

Speficiation#activate_for_platform and collateral improvements.

parent 8b505899
...@@ -62,26 +62,25 @@ module Pod ...@@ -62,26 +62,25 @@ module Pod
def lint def lint
puts puts
invalid_count = lint_podspecs invalid_count = lint_podspecs
count = specs_to_lint.count
if invalid_count == 0 if invalid_count == 0
puts lint_passed_message unless config.silent? lint_passed_message = count == 1 ? "#{podspecs_to_lint.first.basename} passed validation" : "All the #{count} specs passed validation"
puts lint_passed_message.green << "\n\n" unless config.silent?
else else
raise Informative, lint_failed_message(invalid_count) raise Informative, count == 1 ? "The spec did not pass validation" : "#{invalid_count} out of #{count} specs failed validation"
end end
end end
private private
def lint_podspecs def lint_podspecs
specs_count, invalid_count = 0, 0 invalid_count = 0
podspecs_to_lint.each do |podspec_file| specs_to_lint.each do |spec|
root_spec = Specification.from_file(podspec_file)
specs = root_spec.recursive_subspecs.any? ? root_spec.recursive_subspecs : [root_spec]
specs.each do |spec|
# Show immediatly which pod is being processed. # Show immediatly which pod is being processed.
print " -> #{spec}\r" unless config.silent? || is_repo? print " -> #{spec}\r" unless config.silent? || is_repo?
$stdout.flush $stdout.flush
linter = Linter.new(spec, podspec_file) linter = Linter.new(spec)
linter.lenient = @only_errors linter.lenient = @only_errors
linter.quick = @quick || is_repo? linter.quick = @quick || is_repo?
invalid_count += 1 unless linter.lint invalid_count += 1 unless linter.lint
...@@ -94,9 +93,7 @@ module Pod ...@@ -94,9 +93,7 @@ module Pod
puts unless config.silent? || should_skip?(linter) puts unless config.silent? || should_skip?(linter)
end end
specs_count += specs.count puts "Analyzed #{specs_to_lint.count} specs in #{podspecs_to_lint.count} podspecs files.\n\n" if is_repo? && !config.silent?
end
puts "Analyzed #{specs_count} specs in #{podspecs_to_lint.count} podspecs files.\n\n" if is_repo? && !config.silent?
invalid_count invalid_count
end end
...@@ -116,55 +113,35 @@ module Pod ...@@ -116,55 +113,35 @@ module Pod
def print_messages(spec, type, messages) def print_messages(spec, type, messages)
return if config.silent? return if config.silent?
if spec.platform.name
messages = clean_platfrom_messages(messages)
else
messages = clean_duplicate_platfrom_messages(messages)
end
messages.each {|msg| puts " - #{type.ljust(5)} | #{msg}"} messages.each {|msg| puts " - #{type.ljust(5)} | #{msg}"}
end end
def clean_platfrom_messages(messages)
messages.map { |l| l.gsub(/ios: /,'').gsub(/osx: /,'') }
end
def clean_duplicate_platfrom_messages(messages)
duplicate_candiates = messages.select {|l| l.include?("ios: ")}
duplicated = duplicate_candiates.select {|l| messages.include?(l.gsub(/ios: /,'osx: ')) }
duplicated.uniq.each do |l|
clean = l.gsub(/ios: /,'')
messages.insert(messages.index(l), clean)
messages.delete(l)
messages.delete('osx: ' + clean)
end
messages
end
def podspecs_to_lint def podspecs_to_lint
@podspecs_to_lint ||= begin @podspecs_to_lint ||= begin
if (is_repo?) if (is_repo?)
files = (config.repos_dir + @repo_or_podspec).glob('**/*.podspec') files = (config.repos_dir + @repo_or_podspec).glob('**/*.podspec')
elsif @repo_or_podspec elsif @repo_or_podspec
files = [Pathname.new(@repo_or_podspec)] files = [Pathname.new(@repo_or_podspec)]
raise Informative, "[!] Unable to find a spec named #{@repo_or_podspec}".red << "\n\n" unless files[0].exist? && @repo_or_podspec.include?('.podspec') raise Informative, "Unable to find a spec named #{@repo_or_podspec}" unless files[0].exist? && @repo_or_podspec.include?('.podspec')
else else
files = Pathname.pwd.glob('*.podspec') files = Pathname.pwd.glob('*.podspec')
raise Informative, "[!] No specs found in the current directory".red << "\n\n" if files.empty? raise Informative, "No specs found in the current directory" if files.empty?
end end
files files
end end
end end
def is_repo? def specs_to_lint
@is_repo ||= @repo_or_podspec && (config.repos_dir + @repo_or_podspec).exist? && !@repo_or_podspec.include?('/') @specs_to_lint ||= begin
podspecs_to_lint.map do |podspec|
root_spec = Specification.from_file(podspec)
root_spec.recursive_subspecs.any? ? root_spec.recursive_subspecs : root_spec
end.flatten
end end
def lint_passed_message
( podspecs_to_lint.count == 1 ? "#{podspecs_to_lint.first.basename} passed validation" : "All the specs passed validation" ).green << "\n\n"
end end
def lint_failed_message(count) def is_repo?
( podspecs_to_lint.count == 1 ? "[!] The spec did not pass validation" : "[!] #{count} specs failed validation" ).red << "\n\n" @is_repo ||= @repo_or_podspec && (config.repos_dir + @repo_or_podspec).exist? && !@repo_or_podspec.include?('/')
end end
# Linter class # Linter class
...@@ -174,10 +151,11 @@ module Pod ...@@ -174,10 +151,11 @@ module Pod
attr_accessor :quick, :lenient attr_accessor :quick, :lenient
attr_reader :spec, :file attr_reader :spec, :file
attr_reader :errors, :warnings, :notes
def initialize(spec, podspec_file) def initialize(spec)
@spec = spec @spec = spec
@file = podspec_file.realpath @file = spec.defined_in_file.realpath
end end
# Takes an array of podspec files and lints them all # Takes an array of podspec files and lints them all
...@@ -185,66 +163,71 @@ module Pod ...@@ -185,66 +163,71 @@ module Pod
# It returns true if the spec passed validation # It returns true if the spec passed validation
# #
def lint def lint
# If the spec doesn't validate it raises and informative @platform_errors, @platform_warnings, @platform_notes = {}, {}, {}
# TODO: consider raising the informative in the clients of Pod::Specification#validate!
# and just report the errors here platforms = @spec.available_platforms
peform_multiplatform_analysis unless quick platforms.each do |platform|
@platform_errors[platform], @platform_warnings[platform], @platform_notes[platform] = [], [], []
@spec.activate_platform(platform)
@platform = platform
puts "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed if config.verbose? && !@quick
# Skip validation if there are errors in the podspec as it would result in a crash # Skip validation if there are errors in the podspec as it would result in a crash
unless podspec_errors.empty? if !podspec_errors.empty?
@errors, @warnings, @notes = podspec_errors, [], ['[!] Fatal errors found skipping the rest of the validation'] @platform_errors[platform] += podspec_errors
return false @platform_notes[platform] << "#{platform.name} [!] Fatal errors found skipping the rest of the validation"
else
@platform_warnings[platform] += podspec_warnings + deprecation_warnings
peform_extensive_analysis unless quick
end end
valid?
end end
def valid? # Get common messages
lenient ? errors.empty? : errors.empty? && warnings.empty? @errors = @platform_errors.values.reduce(:&)
end @warnings = @platform_warnings.values.reduce(:&)
@notes = @platform_notes.values.reduce(:&)
def errors platforms.each do |platform|
@errors ||= file_patterns_errors + build_errors # Mark platform specific messages
@errors += (@platform_errors[platform] - @errors).map {|m| "[#{platform}] #{m}"}
@warnings += (@platform_warnings[platform] - @warnings).map {|m| "[#{platform}] #{m}"}
@notes += (@platform_notes[platform] - @notes).map {|m| "[#{platform}] #{m}"}
end end
def warnings valid?
@warnings ||= podspec_warnings + deprecation_warnings
end end
def notes def valid?
@notes ||= build_warnings lenient ? errors.empty? : ( errors.empty? && warnings.empty? )
end end
# Performs platform specific analysis. # Performs platform specific analysis.
# It requires to download the source at each iteration # It requires to download the source at each iteration
# #
def peform_multiplatform_analysis def peform_extensive_analysis
platform_names.each do |platform_name|
set_up_lint_environment set_up_lint_environment
puts "\n\n#{spec} - Analyzing on #{Platform.new platform_name} platform.".green.reversed if config.verbose? install_pod
install_pod(platform_name)
puts "Building with xcodebuild.\n".yellow if config.verbose? puts "Building with xcodebuild.\n".yellow if config.verbose?
xcodebuild_output.concat(xcodebuild_output_for_platfrom(platform_name)) # treat xcodebuild warnings as notes because the spec maintainer might not be the author of the library
file_patterns_errors.concat(file_patterns_errors_for_platfrom(platform_name)) xcodebuild_output.each { |msg| ( msg.include?('error') ? @platform_errors[@platform] : @platform_notes[@platform] ) << msg }
@platform_errors[@platform] += file_patterns_errors
tear_down_lint_environment tear_down_lint_environment
end end
end
def platform_names def install_pod
spec.platform.name ? [spec.platform.name] : [:ios, :osx] podfile = podfile_from_spec
end
def install_pod(platform_name)
podfile = podfile_from_spec(platform_name)
config.verbose config.verbose
Installer.new(podfile).install! Installer.new(podfile).install!
config.silent config.silent
end end
def podfile_from_spec(platform_name) def podfile_from_spec
name = spec.name name = spec.name
podspec = file.realpath.to_s podspec = file.realpath.to_s
platform_sym = @platform.to_sym
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
platform platform_name platform(platform_sym)
dependency name, :podspec => podspec dependency name, :podspec => podspec
end end
end end
...@@ -276,16 +259,18 @@ module Pod ...@@ -276,16 +259,18 @@ module Pod
# @return [Array<String>] List of the fatal defects detected in a podspec # @return [Array<String>] List of the fatal defects detected in a podspec
def podspec_errors def podspec_errors
messages = [] messages = []
messages << "The name of the spec should match the name of the file" unless names_match?
messages << "Unrecognized platfrom" unless platform_valid?
messages << "Missing name" unless spec.name messages << "Missing name" unless spec.name
messages << "Missing version" unless spec.version messages << "Missing version" unless spec.version
messages << "Missing summary" unless spec.summary messages << "Missing summary" unless spec.summary
messages << "Missing homepage" unless spec.homepage messages << "Missing homepage" unless spec.homepage
messages << "Missing author(s)" unless spec.authors messages << "Missing author(s)" unless spec.authors
messages << "Missing source or part_of" unless spec.source || spec.part_of messages << "Missing source" unless spec.source
messages << "Missing source_files" if spec.source_files.empty? && spec.subspecs.empty?
messages << "The name of the spec should match the name of the file" unless names_match? # attributes with multiplatform values
messages << "Unrecognized platfrom (no value, :ios, :osx)" unless [nil, :ios, :osx].include?(spec.platform.name) return messages unless platform_valid?
messages << "Missing source_files" if spec.source_files.empty? && spec.subspecs.empty? && spec.dependencies.empty?
messages += paths_starting_with_a_slash_errors messages += paths_starting_with_a_slash_errors
messages messages
end end
...@@ -296,6 +281,10 @@ module Pod ...@@ -296,6 +281,10 @@ module Pod
file.basename.to_s == root_name + '.podspec' file.basename.to_s == root_name + '.podspec'
end end
def platform_valid?
[nil, :ios, :osx].include?(spec.platform.name)
end
def paths_starting_with_a_slash_errors def paths_starting_with_a_slash_errors
messages = [] messages = []
%w[source_files resources clean_paths].each do |accessor| %w[source_files resources clean_paths].each do |accessor|
...@@ -322,8 +311,8 @@ module Pod ...@@ -322,8 +311,8 @@ module Pod
source = @spec.source || {} source = @spec.source || {}
text = @file.read text = @file.read
messages = [] messages = []
messages << "Missing license[:type]" unless license[:type] messages << "Missing license type" unless license[:type]
messages << "Missing license[:file] or [:text]" unless license[:file] || license[:text] messages << "Missing license file or text" unless license[:file] || license[:text]
messages << "The summary is not meaningful" if spec.summary =~ /A short description of/ messages << "The summary is not meaningful" if spec.summary =~ /A short description of/
messages << "The description is not meaningful" if spec.description && spec.description =~ /An optional longer description of/ messages << "The description is not meaningful" if spec.description && spec.description =~ /An optional longer description of/
messages << "The summary should end with a dot" if @spec.summary !~ /.*\./ messages << "The summary should end with a dot" if @spec.summary !~ /.*\./
...@@ -351,28 +340,16 @@ module Pod ...@@ -351,28 +340,16 @@ module Pod
deprecations deprecations
end end
def build_errors
@build_errors ||= xcodebuild_output.select {|msg| msg.include?('error')}
end
def build_warnings
@build_warnings ||= xcodebuild_output - build_errors
end
def xcodebuild_output
@xcodebuild_output ||= []
end
# It creates a podfile in memory and builds a library containing # It creates a podfile in memory and builds a library containing
# the pod for all available platfroms with xcodebuild. # the pod for all available platfroms with xcodebuild.
# #
# It returns a array of strings # It returns a array of strings
# #
def xcodebuild_output_for_platfrom(platform_name) def xcodebuild_output
return [] if `which xcodebuild`.strip.empty? return [] if `which xcodebuild`.strip.empty?
messages = [] messages = []
output = Dir.chdir(config.project_pods_root) { `xcodebuild 2>&1` } output = Dir.chdir(config.project_pods_root) { `xcodebuild 2>&1` }
clean_output = process_xcode_build_output(output).map {|l| "#{platform_name}: #{l}"} clean_output = process_xcode_build_output(output)
messages += clean_output messages += clean_output
puts(output) if config.verbose? puts(output) if config.verbose?
messages messages
...@@ -392,35 +369,31 @@ module Pod ...@@ -392,35 +369,31 @@ module Pod
end end
end end
def file_patterns_errors
@file_patterns_errors ||= []
end
# It checks that every file pattern specified in a spec yields # It checks that every file pattern specified in a spec yields
# at least one file. It requires the pods to be alredy present # at least one file. It requires the pods to be alredy present
# in the current working directory under Pods/spec.name # in the current working directory under Pods/spec.name
# #
# It returns a array of messages # It returns a array of messages
# #
def file_patterns_errors_for_platfrom(platform_name) def file_patterns_errors
Dir.chdir(config.project_pods_root + spec.name ) do Dir.chdir(config.project_pods_root + spec.name ) do
messages = [] messages = []
messages += check_spec_files_exists(:source_files, platform_name, '*.{h,m,mm,c,cpp}') messages += check_spec_files_exists(:source_files, '*.{h,m,mm,c,cpp}')
messages += check_spec_files_exists(:resources, platform_name) messages += check_spec_files_exists(:resources)
messages << "#{platform_name}: license[:file] = '#{spec.license[:file]}' -> did not match any file" if spec.license[:file] && pod_dir.glob(spec.license[:file]).empty? messages << "#{platform_name}: license[:file] = '#{spec.license[:file]}' -> did not match any file" if spec.license[:file] && pod_dir.glob(spec.license[:file]).empty?
messages.compact messages.compact
end end
end end
def check_spec_files_exists(accessor, platform_name, options = {}) def check_spec_files_exists(accessor, options = {})
result = [] result = []
patterns = spec.send(accessor)[platform_name] patterns = spec.send(accessor)
patterns.each do |original_pattern| patterns.each do |original_pattern|
pattern = pod_dir + original_pattern pattern = pod_dir + original_pattern
if pattern.directory? && options[:glob] if pattern.directory? && options[:glob]
pattern += options[:glob] pattern += options[:glob]
end end
result << "#{platform_name}: [#{accessor} = '#{original_pattern}'] -> did not match any file" if pattern.glob.empty? result << "#{@platform}: [#{accessor} = '#{original_pattern}'] -> did not match any file" if pattern.glob.empty?
end end
result result
end end
......
...@@ -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