Commit 1801ce2d authored by Fabio Pelosin's avatar Fabio Pelosin

Merge pull request #253 from CocoaPods/spec-refactor

Specification refactor
parents 2f9a5fad 9511cc44
...@@ -4,6 +4,10 @@ module Pod ...@@ -4,6 +4,10 @@ module Pod
VERSION = '0.6.0rc1' VERSION = '0.6.0rc1'
class Informative < StandardError class Informative < StandardError
def message
#TODO: remove formatting from raise calls and remove conditional
super !~ /\[!\]/ ? "[!] #{super}\n".red : super
end
end end
autoload :Command, 'cocoapods/command' autoload :Command, 'cocoapods/command'
......
...@@ -27,7 +27,6 @@ module Pod ...@@ -27,7 +27,6 @@ module Pod
[ [
["--no-clean", "Leave SCM dirs like `.git' and `.svn' intact after downloading"], ["--no-clean", "Leave SCM dirs like `.git' and `.svn' intact after downloading"],
["--no-doc", "Skip documentation generation with appledoc"], ["--no-doc", "Skip documentation generation with appledoc"],
["--force-doc", "Force the generation of documentation"],
["--no-integrate", "Skip integration of the Pods libraries in the Xcode project(s)"], ["--no-integrate", "Skip integration of the Pods libraries in the Xcode project(s)"],
["--no-update", "Skip running `pod repo update` before install"], ["--no-update", "Skip running `pod repo update` before install"],
].concat(super) ].concat(super)
...@@ -36,7 +35,6 @@ module Pod ...@@ -36,7 +35,6 @@ module Pod
def initialize(argv) def initialize(argv)
config.clean = !argv.option('--no-clean') config.clean = !argv.option('--no-clean')
config.generate_docs = !argv.option('--no-doc') config.generate_docs = !argv.option('--no-doc')
config.force_doc = argv.option('--force-doc')
config.integrate_targets = !argv.option('--no-integrate') config.integrate_targets = !argv.option('--no-integrate')
@update_repo = !argv.option('--no-update') @update_repo = !argv.option('--no-update')
super unless argv.empty? super unless argv.empty?
......
...@@ -23,7 +23,7 @@ module Pod ...@@ -23,7 +23,7 @@ module Pod
# specification information # specification information
def spec def spec
@spec ||= @set.specification.part_of_other_pod? ? @set.specification.part_of_specification : @set.specification @set.specification
end end
def authors def authors
...@@ -47,7 +47,7 @@ module Pod ...@@ -47,7 +47,7 @@ module Pod
end end
def platform def platform
spec.platform.to_s spec.available_platforms.sort { |a,b| a.to_s.downcase <=> b.to_s.downcase }.join(' - ')
end end
def license def license
...@@ -98,6 +98,7 @@ module Pod ...@@ -98,6 +98,7 @@ module Pod
end end
def distance_from_now_in_words(from_time) def distance_from_now_in_words(from_time)
return nil unless from_time
from_time = Time.parse(from_time) from_time = Time.parse(from_time)
to_time = Time.now to_time = Time.now
distance_in_days = (((to_time - from_time).abs)/60/60/24).round distance_in_days = (((to_time - from_time).abs)/60/60/24).round
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ module Pod ...@@ -12,7 +12,7 @@ module Pod
attr_accessor :repos_dir, :project_root, :project_pods_root attr_accessor :repos_dir, :project_root, :project_pods_root
attr_accessor :clean, :verbose, :silent attr_accessor :clean, :verbose, :silent
attr_accessor :generate_docs, :doc_install, :force_doc attr_accessor :generate_docs, :doc_install
attr_accessor :integrate_targets attr_accessor :integrate_targets
attr_accessor :git_cache_size attr_accessor :git_cache_size
...@@ -21,12 +21,11 @@ module Pod ...@@ -21,12 +21,11 @@ module Pod
alias_method :silent?, :silent alias_method :silent?, :silent
alias_method :generate_docs?, :generate_docs alias_method :generate_docs?, :generate_docs
alias_method :doc_install?, :doc_install alias_method :doc_install?, :doc_install
alias_method :force_doc?, :force_doc
alias_method :integrate_targets?, :integrate_targets alias_method :integrate_targets?, :integrate_targets
def initialize def initialize
@repos_dir = Pathname.new(File.expand_path("~/.cocoapods")) @repos_dir = Pathname.new(File.expand_path("~/.cocoapods"))
@verbose = @silent = @force_doc = false @verbose = @silent = false
@clean = @generate_docs = @doc_install = @integrate_targets = true @clean = @generate_docs = @doc_install = @integrate_targets = true
end end
......
...@@ -5,8 +5,6 @@ require 'open-uri' ...@@ -5,8 +5,6 @@ require 'open-uri'
module Pod module Pod
class Dependency < Gem::Dependency class Dependency < Gem::Dependency
attr_accessor :only_part_of_other_pod
alias_method :only_part_of_other_pod?, :only_part_of_other_pod
attr_reader :external_source attr_reader :external_source
attr_accessor :specification attr_accessor :specification
...@@ -27,13 +25,10 @@ module Pod ...@@ -27,13 +25,10 @@ module Pod
raise Informative, "A dependency needs either a name and version requirements, " \ raise Informative, "A dependency needs either a name and version requirements, " \
"a source hash, or a block which defines a podspec." "a source hash, or a block which defines a podspec."
end end
@only_part_of_other_pod = false
end end
def ==(other) def ==(other)
super && super && (@specification ? @specification == other.specification : @external_source == other.external_source)
@only_part_of_other_pod == other.only_part_of_other_pod &&
(@specification ? @specification == other.specification : @external_source == other.external_source)
end end
def subspec_dependency? def subspec_dependency?
...@@ -138,12 +133,12 @@ module Pod ...@@ -138,12 +133,12 @@ module Pod
def specification_from_sandbox(sandbox, platform) def specification_from_sandbox(sandbox, platform)
if local_pod = sandbox.installed_pod_named(name, platform) if local_pod = sandbox.installed_pod_named(name, platform)
local_pod.specification local_pod.top_specification
else else
copy_external_source_into_sandbox(sandbox) copy_external_source_into_sandbox(sandbox)
local_pod = sandbox.installed_pod_named(name, platform) local_pod = sandbox.installed_pod_named(name, platform)
local_pod.clean if config.clean? local_pod.clean if config.clean?
local_pod.specification local_pod.top_specification
end end
end end
......
...@@ -11,8 +11,7 @@ module Pod ...@@ -11,8 +11,7 @@ module Pod
extend Executable extend Executable
def self.for_pod(pod) def self.for_pod(pod)
spec = pod.specification spec = pod.top_specification
spec = spec.part_of_specification if spec.part_of_other_pod?
for_target(pod.root, spec.source.dup) for_target(pod.root, spec.source.dup)
end end
......
...@@ -13,7 +13,7 @@ module Pod ...@@ -13,7 +13,7 @@ module Pod
def download def download
prepare_cache prepare_cache
puts '->'.green << ' Cloning git repo' if config.verbose? puts '-> Cloning git repo' if config.verbose?
if options[:tag] if options[:tag]
download_tag download_tag
elsif options[:commit] elsif options[:commit]
...@@ -26,7 +26,7 @@ module Pod ...@@ -26,7 +26,7 @@ module Pod
def prepare_cache def prepare_cache
unless cache_exist? unless cache_exist?
puts '->'.green << " Creating cache git repo (#{cache_path})" if config.verbose? puts "-> Creating cache git repo (#{cache_path})" if config.verbose?
cache_path.rmtree if cache_path.exist? cache_path.rmtree if cache_path.exist?
cache_path.mkpath cache_path.mkpath
git "clone '#{url}' #{cache_path}" git "clone '#{url}' #{cache_path}"
...@@ -71,7 +71,7 @@ module Pod ...@@ -71,7 +71,7 @@ module Pod
end end
def update_cache def update_cache
puts '->'.green << " Updating cache git repo (#{cache_path})" if config.verbose? puts "-> Updating cache git repo (#{cache_path})" if config.verbose?
Dir.chdir(cache_path) do Dir.chdir(cache_path) do
git "reset --hard HEAD" git "reset --hard HEAD"
git "clean -d -x -f" git "clean -d -x -f"
......
...@@ -7,8 +7,14 @@ module Pod ...@@ -7,8 +7,14 @@ module Pod
raise Informative, "Unable to locate the executable `#{name}'" raise Informative, "Unable to locate the executable `#{name}'"
end end
if Config.instance.verbose? if Config.instance.verbose?
puts "-> #{bin} #{command}" print " $ #{name}...\r"
`#{bin} #{command} 1>&2` $stdout.flush
output = `#{bin} #{command} 2>&1`
puts " #{$?.exitstatus.zero? ? '-' : '!'.red} #{name} #{command}"
output = output.gsub(/ */,' ').gsub(/^ */,' ')
puts output unless output.strip.empty?
else else
`#{bin} #{command} 2> /dev/null` `#{bin} #{command} 2> /dev/null`
end end
......
...@@ -12,9 +12,9 @@ module Pod ...@@ -12,9 +12,9 @@ module Pod
def initialize(pod) def initialize(pod)
@pod = pod @pod = pod
@specification = pod.specification @specification = pod.top_specification
@target_path = pod.sandbox.root + 'Documentation' + pod.name @target_path = pod.sandbox.root + 'Documentation' + pod.name
@options = pod.specification.documentation || {} @options = @specification.documentation || {}
end end
def name def name
...@@ -42,13 +42,11 @@ module Pod ...@@ -42,13 +42,11 @@ module Pod
end end
def files def files
@pod.absolute_source_files.map(&:to_s) @pod.all_specs_public_header_files.map{ |f| f.relative_path_from(@pod.root).to_s }
end end
def index_file def index_file
@pod.chdir do @pod.readme_file.relative_path_from(@pod.root).to_s if @pod.readme_file
Dir.glob('README*', File::FNM_CASEFOLD).first
end
end end
def spec_appledoc_options def spec_appledoc_options
...@@ -66,11 +64,9 @@ module Pod ...@@ -66,11 +64,9 @@ module Pod
'--keep-undocumented-objects', '--keep-undocumented-objects',
'--keep-undocumented-members', '--keep-undocumented-members',
'--keep-intermediate-files', '--keep-intermediate-files',
'--exit-threshold', '2' '--exit-threshold', '2' # appledoc terminates with an exits status of 1 if a warning was logged
# appledoc exits with 1 if a warning was logged
] ]
index = index_file options += ['--index-desc', index_file] if index_file
options += ['--index-desc', index] if index
options += spec_appledoc_options options += spec_appledoc_options
end end
...@@ -82,6 +78,8 @@ module Pod ...@@ -82,6 +78,8 @@ module Pod
options = appledoc_options options = appledoc_options
options += ['--output', @target_path.to_s] options += ['--output', @target_path.to_s]
options += install ? ['--create-docset'] : ['--no-create-docset'] options += install ? ['--create-docset'] : ['--no-create-docset']
# TODO: passing the files explicitly clutters output and chokes on very long list (AWSiOSSDK Spec).
# It is possible to just pass the dir of the pod, however this would include other files like demo projects.
options += files options += files
@target_path.mkpath @target_path.mkpath
......
...@@ -26,7 +26,7 @@ module Pod ...@@ -26,7 +26,7 @@ module Pod
return @project if @project return @project if @project
@project = Pod::Project.new @project = Pod::Project.new
@project.user_build_configurations = @podfile.user_build_configurations @project.user_build_configurations = @podfile.user_build_configurations
activated_pods.each do |pod| pods.each do |pod|
# Add all source files to the project grouped by pod # Add all source files to the project grouped by pod
group = @project.add_pod_group(pod.name) group = @project.add_pod_group(pod.name)
pod.source_files.each do |path| pod.source_files.each do |path|
...@@ -45,32 +45,32 @@ module Pod ...@@ -45,32 +45,32 @@ module Pod
end end
def install_dependencies! def install_dependencies!
activated_pods.each do |pod| pods.each do |pod|
unless config.silent?
marker = config.verbose ? "\n-> ".green : '' marker = config.verbose ? "\n-> ".green : ''
name = pod.top_specification.preferred_dependency ? "#{pod.top_specification.name}/#{pod.top_specification.preferred_dependency} (#{pod.top_specification.version})" : pod.to_s
puts marker << ( pod.exists? ? "Using #{name}" : "Installing #{name}".green )
end
unless should_install = !pod.exists? && !pod.specification.local? unless pod.exists?
puts marker + "Using #{pod}" unless config.silent?
else
puts marker + "Installing #{pod.specification}".green unless config.silent?
downloader = Downloader.for_pod(pod) downloader = Downloader.for_pod(pod)
downloader.download downloader.download
# The docs need to be generated before cleaning because
if config.clean # the documentation is created for all the subspecs.
downloader.clean generate_docs(pod)
pod.clean pod.clean if config.clean
end
end end
end end
if (should_install && config.generate_docs?) || config.force_doc? #TODO: move to generator ?
def generate_docs(pod)
doc_generator = Generator::Documentation.new(pod) doc_generator = Generator::Documentation.new(pod)
if doc_generator.already_installed? if ( config.generate_docs? && !doc_generator.already_installed? )
puts "Using Existing Documentation for #{pod.specification}".green if config.verbose? puts "-> Installing documentation" if config.verbose?
else
puts "Installing Documentation for #{pod.specification}".green if config.verbose?
doc_generator.generate(config.doc_install?) doc_generator.generate(config.doc_install?)
end else
end puts "-> Using existing documentation" if config.verbose?
end end
end end
...@@ -83,21 +83,20 @@ module Pod ...@@ -83,21 +83,20 @@ module Pod
print_title "Installing dependencies" print_title "Installing dependencies"
install_dependencies! install_dependencies!
pods = activated_pods
print_title("Generating support files\n", false) print_title("Generating support files\n", false)
target_installers.each do |target_installer| target_installers.each do |target_installer|
pods_for_target = activated_pods_by_target[target_installer.target_definition] pods_for_target = pods_by_target[target_installer.target_definition]
target_installer.install!(pods_for_target, @sandbox) target_installer.install!(pods_for_target, @sandbox)
end end
generate_lock_file!(pods) generate_lock_file!(specifications)
generate_dummy_source generate_dummy_source
puts "* Running post install hooks" if config.verbose? puts "- Running post install hooks" if config.verbose?
# Post install hooks run _before_ saving of project, so that they can alter it before saving. # Post install hooks run _before_ saving of project, so that they can alter it before saving.
run_post_install_hooks run_post_install_hooks
puts "* Writing Xcode project file to `#{@sandbox.project_path}'\n\n" if config.verbose? puts "- Writing Xcode project file to `#{@sandbox.project_path}'\n\n" if config.verbose?
project.save_as(@sandbox.project_path) project.save_as(@sandbox.project_path)
UserProjectIntegrator.new(@podfile).integrate! if config.integrate_targets? UserProjectIntegrator.new(@podfile).integrate! if config.integrate_targets?
...@@ -107,7 +106,7 @@ module Pod ...@@ -107,7 +106,7 @@ module Pod
# we loop over target installers instead of pods, because we yield the target installer # we loop over target installers instead of pods, because we yield the target installer
# to the spec post install hook. # to the spec post install hook.
target_installers.each do |target_installer| target_installers.each do |target_installer|
activated_specifications_for_target(target_installer.target_definition).each do |spec| specs_by_target[target_installer.target_definition].each do |spec|
spec.post_install(target_installer) spec.post_install(target_installer)
end end
end end
...@@ -115,28 +114,28 @@ module Pod ...@@ -115,28 +114,28 @@ module Pod
@podfile.post_install!(self) @podfile.post_install!(self)
end end
def generate_lock_file!(pods) def generate_lock_file!(specs)
lock_file.open('w') do |file| lock_file.open('w') do |file|
file.puts "PODS:" file.puts "PODS:"
# Get list of [name, dependencies] pairs. # Get list of [name, dependencies] pairs.
activated_pods = pods.map do |pod| pod_and_deps = specs.map do |spec|
[pod.specification.to_s, pod.dependencies.map(&:to_s).sort] [spec.to_s, spec.dependencies.map(&:to_s).sort]
end.uniq end.uniq
# Merge dependencies of ios and osx version of the same pod. # Merge dependencies of ios and osx version of the same pod.
tmp = {} tmp = {}
activated_pods.each do |name, deps| pod_and_deps.each do |name, deps|
if tmp[name] if tmp[name]
tmp[name].concat(deps).uniq! tmp[name].concat(deps).uniq!
else else
tmp[name] = deps tmp[name] = deps
end end
end end
activated_pods = tmp pod_and_deps = tmp
# Sort by name and print # Sort by name and print
activated_pods.sort_by(&:first).each do |name, deps| pod_and_deps.sort_by(&:first).each do |name, deps|
if deps.empty? if deps.empty?
file.puts " - #{name}" file.puts " - #{name}"
else else
...@@ -145,14 +144,6 @@ module Pod ...@@ -145,14 +144,6 @@ module Pod
end end
end end
unless download_only_specifications.empty?
file.puts
file.puts "DOWNLOAD_ONLY:"
download_only_specifications.map(&:to_s).sort.each do |name|
file.puts " - #{name}"
end
end
file.puts file.puts
file.puts "DEPENDENCIES:" file.puts "DEPENDENCIES:"
@podfile.dependencies.map(&:to_s).sort.each do |dep| @podfile.dependencies.map(&:to_s).sort.each do |dep|
...@@ -179,49 +170,36 @@ module Pod ...@@ -179,49 +170,36 @@ module Pod
end end
# @return [Array<Specification>] All dependencies that have been resolved. # @return [Array<Specification>] All dependencies that have been resolved.
def dependency_specifications def specifications
specs_by_target.values.flatten specs_by_target.values.flatten
end end
# @return [Array<LocalPod>] A list of LocalPod instances for each # @return [Array<LocalPod>] A list of LocalPod instances for each
# dependency that is not a download-only one. # dependency that is not a download-only one.
def activated_pods def pods
activated_pods_by_target.values.flatten pods_by_target.values.flatten
end end
def activated_pods_by_target def pods_by_target
@pods_by_spec = {}
result = {} result = {}
specs_by_target.each do |target_definition, specs| specs_by_target.each do |target_definition, specs|
@pods_by_spec[target_definition.platform] = {}
result[target_definition] = specs.map do |spec| result[target_definition] = specs.map do |spec|
LocalPod.new(spec, @sandbox, target_definition.platform) if activated_spec?(spec) pod = pod_for_spec(spec, target_definition.platform)
end.compact pod.add_specification(spec)
pod
end.uniq.compact
end end
result result
end end
# @return [Array<Specification>] A list of specifications for each def pod_for_spec(spec, platform)
# dependency that is not a download-only @pods_by_spec[platform][spec.top_level_parent.name] ||= LocalPod.new(spec, @sandbox, platform)
# one.
def activated_specifications
dependency_specifications.select { |spec| activated_spec?(spec) }
end
def activated_specifications_for_target(target_definition)
specs_by_target[target_definition].select { |spec| activated_spec?(spec) }
end
def download_only_specifications
dependency_specifications - activated_specifications
end end
private private
def activated_spec?(spec)
# Don't activate specs which are only wrappers of subspecs, or share
# source with another pod but aren't activated themselves.
!spec.wrapper? && !@resolver.cached_sets[spec.name].only_part_of_other_pod?
end
def print_title(title, only_verbose = true) def print_title(title, only_verbose = true)
if config.verbose? if config.verbose?
puts "\n" + title.yellow puts "\n" + title.yellow
......
...@@ -41,7 +41,7 @@ module Pod ...@@ -41,7 +41,7 @@ module Pod
header.puts "#import #{@target_definition.platform == :ios ? '<UIKit/UIKit.h>' : '<Cocoa/Cocoa.h>'}" header.puts "#import #{@target_definition.platform == :ios ? '<UIKit/UIKit.h>' : '<Cocoa/Cocoa.h>'}"
header.puts "#endif" header.puts "#endif"
pods.each do |pod| pods.each do |pod|
if prefix_header_contents = pod.specification.prefix_header_contents if prefix_header_contents = pod.top_specification.prefix_header_contents
header.puts header.puts
header.puts prefix_header_contents header.puts prefix_header_contents
elsif prefix_header = pod.prefix_header_file elsif prefix_header = pod.prefix_header_file
...@@ -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.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
...@@ -93,15 +92,15 @@ module Pod ...@@ -93,15 +92,15 @@ module Pod
def create_files(pods, sandbox) def create_files(pods, sandbox)
if @podfile.generate_bridge_support? if @podfile.generate_bridge_support?
bridge_support_metadata_path = sandbox.root + @target_definition.bridge_support_name bridge_support_metadata_path = sandbox.root + @target_definition.bridge_support_name
puts "* Generating BridgeSupport metadata file at `#{bridge_support_metadata_path}'" if config.verbose? puts "- Generating BridgeSupport metadata file at `#{bridge_support_metadata_path}'" if config.verbose?
bridge_support_generator_for(pods, sandbox).save_as(bridge_support_metadata_path) bridge_support_generator_for(pods, sandbox).save_as(bridge_support_metadata_path)
copy_resources_script_for(pods).resources << @target_definition.bridge_support_name copy_resources_script_for(pods).resources << @target_definition.bridge_support_name
end end
puts "* Generating xcconfig file at `#{sandbox.root + @target_definition.xcconfig_name}'" if config.verbose? puts "- Generating xcconfig file at `#{sandbox.root + @target_definition.xcconfig_name}'" if config.verbose?
xcconfig.save_as(sandbox.root + @target_definition.xcconfig_name) xcconfig.save_as(sandbox.root + @target_definition.xcconfig_name)
puts "* Generating prefix header at `#{sandbox.root + @target_definition.prefix_header_name}'" if config.verbose? puts "- Generating prefix header at `#{sandbox.root + @target_definition.prefix_header_name}'" if config.verbose?
save_prefix_header_as(sandbox.root + @target_definition.prefix_header_name, pods) save_prefix_header_as(sandbox.root + @target_definition.prefix_header_name, pods)
puts "* Generating copy resources script at `#{sandbox.root + @target_definition.copy_resources_script_name}'" if config.verbose? puts "- Generating copy resources script at `#{sandbox.root + @target_definition.copy_resources_script_name}'" if config.verbose?
copy_resources_script_for(pods).save_as(sandbox.root + @target_definition.copy_resources_script_name) copy_resources_script_for(pods).save_as(sandbox.root + @target_definition.copy_resources_script_name)
end end
......
module Pod module Pod
class LocalPod class LocalPod
attr_reader :specification attr_reader :top_specification, :specifications
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 @top_specification, @sandbox = specification.top_level_parent, sandbox
@top_specification.activate_platform(platform)
@specifications = [] << specification
end end
def self.from_podspec(podspec, sandbox, platform) def self.from_podspec(podspec, sandbox, platform)
new(Specification.from_file(podspec), sandbox, platform) new(Specification.from_file(podspec), sandbox, platform)
end end
# Method to add the specifications sharing the same top level
# parent. With this information the local pod can determine the
# paths to clean and avoid duplication in file processing.
# Adding specifications is idempotent.
def add_specification(spec)
raise Informative, "[Local Pod] Attempt to add a specification from another pod" unless spec.top_level_parent == top_specification
spec.activate_platform(platform)
@specifications << spec unless @specifications.include?(spec)
end
def root def root
@sandbox.root + specification.name @sandbox.root + top_specification.name
end end
def to_s def subspecs
if specification.local? specifications.reject{|s| s.parent.nil? }
"#{specification} [LOCAL]"
else
specification.to_s
end end
def to_s
result = top_specification.to_s
result << " [LOCAL]" if top_specification.local?
result
end end
def name def name
specification.name top_specification.name
end
def platform
top_specification.active_platform
end end
# Installation methods
def create def create
root.mkpath unless exists? root.mkpath unless exists?
end end
...@@ -45,36 +64,75 @@ module Pod ...@@ -45,36 +64,75 @@ module Pod
root.rmtree if exists? root.rmtree if exists?
end end
# It deletes all the files identified by clean_paths, then it removes
# all the empty folders or symlinks.
def clean def clean
clean_paths.each { |path| FileUtils.rm_rf(path) } clean_paths.each { |path| FileUtils.rm_rf(path) }
Dir.glob("#{root}/**/{*,.*}").
sort_by(&:length).reverse. # Clean the deepest paths first to determine if the containing folders are empty
reject { |d| d =~ /\/\.\.?$/ }. # Remove the `.` and `..` paths
select { |d| File.directory?(d) }. # Get only directories or symlinks to directories
each do |d|
FileUtils.rm_rf(d) if File.symlink?(d) || (Dir.entries(d) == %w[ . .. ]) # Remove the symlink and the empty dirs
end end
end
# File attributes
def prefix_header_file def prefix_header_file
if prefix_header = specification.prefix_header_file if prefix_header = top_specification.prefix_header_file
@sandbox.root + specification.name + prefix_header @sandbox.root + top_specification.name + prefix_header
end end
end end
def source_files def source_files(relative = true)
expanded_paths(specification.source_files, :glob => '*.{h,m,mm,c,cpp}', :relative_to_sandbox => true) chained_expanded_paths(:source_files, :glob => '*.{h,m,mm,c,cpp}', :relative_to_sandbox => relative)
end end
def absolute_source_files def resources(relative = true)
expanded_paths(specification.source_files, :glob => '*.{h,m,mm,c,cpp}') chained_expanded_paths(:resources, :relative_to_sandbox => relative)
end end
def clean_paths def clean_paths
expanded_paths(specification.clean_paths) expanded_paths('**/{*,.*}').reject { |p| p.directory? } - used_files
end
def used_files
source_files(false) + resources(false) + [ readme_file, license_file, prefix_header_file ] + preserve_paths
end
def readme_file
expanded_paths(%w[ README{*,.*} readme{*,.*} ]).first
end
def license_file
file = top_specification.license[:file] if top_specification.license
file || expanded_paths(%w[ LICENSE{*,.*} licence{*,.*} ]).first
end end
def resources # TODO: implement case insensitive search
expanded_paths(specification.resources, :relative_to_sandbox => true) def preserve_paths
chained_expanded_paths(:preserve_paths) + expanded_paths(%w[ *.podspec notice* NOTICE* CREDITS* ])
end end
def header_files def header_files
source_files.select { |f| f.extname == '.h' } source_files.select { |f| f.extname == '.h' }
end end
def xcconfig
specifications.map { |s| s.xcconfig }.reduce(:merge)
end
# Method used by documentation generator. It return the source files
# of all the specs.
def all_specs_public_header_files
#TODO: merge with #221
specs = top_specification.recursive_subspecs << top_specification
specs.map { |s| expanded_paths(s.source_files, :glob => '*.{h}') }.compact.flatten.select { |f| f.extname == '.h' }.uniq
end
# Integration methods
def link_headers def link_headers
copy_header_mappings.each do |namespaced_path, files| copy_header_mappings.each do |namespaced_path, files|
@sandbox.add_header_files(namespaced_path, files) @sandbox.add_header_files(namespaced_path, files)
...@@ -82,17 +140,17 @@ module Pod ...@@ -82,17 +140,17 @@ module Pod
end end
def add_to_target(target) def add_to_target(target)
implementation_files.each do |file| sources_files_by_specification.each do | spec, files |
target.add_source_file(file, nil, specification.compiler_flags[@platform.name].strip) files.each do |file|
# TODO: Xcodeproj::Project::Object::PBXNativeTarget#add_source_file is quite slow
# The issus appears to be related to the find call in line 107.
target.add_source_file(file, nil, spec.compiler_flags.strip)
end end
end end
def requires_arc?
specification.requires_arc
end end
def dependencies def requires_arc?
specification.dependencies[@platform.name] top_specification.requires_arc
end end
private private
...@@ -107,17 +165,46 @@ module Pod ...@@ -107,17 +165,46 @@ module Pod
# TODO this is being overriden in the RestKit 0.9.4 spec, need to do # TODO this is being overriden in the RestKit 0.9.4 spec, need to do
# something with that, and this method also still exists in Specification. # something with that, and this method also still exists in Specification.
#
# This is not overriden anymore in specification refactor and the code
# Pod::Specification#copy_header_mapping can be moved here.
def copy_header_mappings def copy_header_mappings
header_files.inject({}) do |mappings, from| search_path_headers = header_files - headers_excluded_from_search_paths
search_path_headers.inject({}) do |mappings, from|
from_without_prefix = from.relative_path_from(relative_root) from_without_prefix = from.relative_path_from(relative_root)
to = specification.header_dir + specification.copy_header_mapping(from_without_prefix) to = top_specification.header_dir + top_specification.copy_header_mapping(from_without_prefix)
(mappings[to.dirname] ||= []) << from (mappings[to.dirname] ||= []) << from
mappings mappings
end end
end end
def expanded_paths(platforms_with_patterns, options = {}) # returns an hash where the source_files are groupped by specification.
patterns = platforms_with_patterns.is_a?(Hash) ? platforms_with_patterns[@platform.name] : platforms_with_patterns # If the same file is required by two specifications the one at the
# higher level in the inheritance chain wins.
def sources_files_by_specification
files_by_spec = {}
processed_files = []
specifications.sort_by { |s| s.name.length }.each do |spec|
files = []
expanded_paths(spec.source_files, :glob => '*.{h,m,mm,c,cpp}', :relative_to_sandbox => true).each do | file |
files << file unless processed_files.include?(file)
end
files_by_spec[spec] = files
processed_files += files
end
files_by_spec
end
def headers_excluded_from_search_paths
chained_expanded_paths(:exclude_header_search_paths, :relative_to_sandbox => true)
end
def chained_expanded_paths(accessor, options = {})
specifications.map { |s| expanded_paths(s.send(accessor), options) }.compact.flatten.uniq
end
def expanded_paths(patterns, options = {})
patterns = [ patterns ] if patterns.is_a? String
patterns.map do |pattern| patterns.map do |pattern|
pattern = root + pattern pattern = root + pattern
......
...@@ -10,7 +10,7 @@ module Pod ...@@ -10,7 +10,7 @@ module Pod
attr_reader :deployment_target attr_reader :deployment_target
def initialize(symbolic_name, deployment_target = nil) def initialize(symbolic_name = nil, deployment_target = nil)
@symbolic_name = symbolic_name @symbolic_name = symbolic_name
if deployment_target if deployment_target
version = deployment_target.is_a?(Hash) ? deployment_target[:deployment_target] : deployment_target # backwards compatibility from 0.6 version = deployment_target.is_a?(Hash) ? deployment_target[:deployment_target] : deployment_target # backwards compatibility from 0.6
...@@ -34,9 +34,11 @@ module Pod ...@@ -34,9 +34,11 @@ 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) os_check = @symbolic_name == other.name
version_check = (deployment_target.nil? || other.deployment_target.nil? || deployment_target >= other.deployment_target)
os_check && version_check
end end
def to_s def to_s
......
...@@ -22,26 +22,19 @@ module Pod ...@@ -22,26 +22,19 @@ module Pod
@podfile.target_definitions.values.each do |target_definition| @podfile.target_definitions.values.each do |target_definition|
puts "\nResolving dependencies for target `#{target_definition.name}' (#{target_definition.platform})".green if config.verbose? puts "\nResolving dependencies for target `#{target_definition.name}' (#{target_definition.platform})".green if config.verbose?
@loaded_specs = [] @loaded_specs = []
# TODO @podfile.platform will change to target_definition.platform find_dependency_specs(@podfile, target_definition.dependencies, target_definition)
find_dependency_sets(@podfile, target_definition.dependencies, target_definition)
targets_and_specs[target_definition] = @specs.values_at(*@loaded_specs).sort_by(&:name) targets_and_specs[target_definition] = @specs.values_at(*@loaded_specs).sort_by(&:name)
end end
# Specification doesn't need to know more about the context, so we assign @specs.values.sort_by(&:name)
# the other specification, of which this pod is a part, to the spec.
@specs.values.sort_by(&:name).each do |spec|
if spec.part_of_other_pod?
spec.part_of_specification = @cached_sets[spec.part_of.name].specification
end
end
targets_and_specs targets_and_specs
end end
private private
def find_cached_set(dependency, platform) def find_cached_set(dependency, platform)
@cached_sets[dependency.name] ||= begin set_name = dependency.name.split('/').first
@cached_sets[set_name] ||= begin
if dependency.specification if dependency.specification
Specification::Set::External.new(dependency.specification) Specification::Set::External.new(dependency.specification)
elsif external_source = dependency.external_source elsif external_source = dependency.external_source
...@@ -60,7 +53,7 @@ module Pod ...@@ -60,7 +53,7 @@ module Pod
end end
end end
def find_dependency_sets(dependent_specification, dependencies, target_definition) def find_dependency_specs(dependent_specification, dependencies, target_definition)
@log_indent += 1 @log_indent += 1
dependencies.each do |dependency| dependencies.each do |dependency|
puts ' ' * @log_indent + "- #{dependency}" if config.verbose? puts ' ' * @log_indent + "- #{dependency}" if config.verbose?
...@@ -68,19 +61,12 @@ module Pod ...@@ -68,19 +61,12 @@ module Pod
set.required_by(dependent_specification) set.required_by(dependent_specification)
# Ensure we don't resolve the same spec twice for one target # Ensure we don't resolve the same spec twice for one target
unless @loaded_specs.include?(dependency.name) unless @loaded_specs.include?(dependency.name)
# Get a reference to the spec that’s actually being loaded. spec = set.specification_by_name(dependency.name)
# If it’s a subspec dependency, e.g. 'RestKit/Network', then
# find that subspec.
spec = set.specification
if dependency.subspec_dependency?
spec = spec.subspec_by_name(dependency.name)
end
@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.
# TODO fix the need to return an empty arrayf if there are no deps for the given platform find_dependency_specs(spec, spec.dependencies, target_definition) if spec.dependencies
find_dependency_sets(spec, (spec.dependencies[target_definition.platform.to_sym] || []), target_definition)
end end
validate_platform!(spec || @specs[dependency.name], target_definition) validate_platform!(spec || @specs[dependency.name], target_definition)
end end
...@@ -88,8 +74,8 @@ module Pod ...@@ -88,8 +74,8 @@ module Pod
end end
def validate_platform!(spec, target) def validate_platform!(spec, target)
unless spec.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.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
end end
......
...@@ -68,7 +68,7 @@ module Pod ...@@ -68,7 +68,7 @@ module Pod
set.name == dependency.top_level_spec_name && set.name == dependency.top_level_spec_name &&
# Now either check if it's a dependency on the top level spec, or if it's not # Now either check if it's a dependency on the top level spec, or if it's not
# check if the requested subspec exists in the top level spec. # check if the requested subspec exists in the top level spec.
(!dependency.subspec_dependency? || !set.specification.subspec_by_name(dependency.name).nil?) set.specification.subspec_by_name(dependency.name)
end end
end end
......
This diff is collapsed.
...@@ -9,6 +9,9 @@ module Pod ...@@ -9,6 +9,9 @@ module Pod
end end
def required_by(specification) def required_by(specification)
# Skip subspecs because the can't require a different version of the top level parent
return if !specification.podfile? && specification.top_level_parent.name == name
dependency = specification.dependency_by_top_level_spec_name(name) dependency = specification.dependency_by_top_level_spec_name(name)
# TODO we don’t actually do anything in our Version subclass. Maybe we should just remove that. # TODO we don’t actually do anything in our Version subclass. Maybe we should just remove that.
unless @required_by.empty? || dependency.requirement.satisfied_by?(Gem::Version.new(required_version.to_s)) unless @required_by.empty? || dependency.requirement.satisfied_by?(Gem::Version.new(required_version.to_s))
...@@ -21,16 +24,16 @@ module Pod ...@@ -21,16 +24,16 @@ module Pod
@required_by << specification @required_by << specification
end end
def specification_by_name(name)
specification.top_level_parent.subspec_by_name(name)
end
def dependency def dependency
@required_by.inject(Dependency.new(name)) do |previous, spec| @required_by.inject(Dependency.new(name)) do |previous, spec|
previous.merge(spec.dependency_by_top_level_spec_name(name).to_top_level_spec_dependency) previous.merge(spec.dependency_by_top_level_spec_name(name).to_top_level_spec_dependency)
end end
end end
def only_part_of_other_pod?
@required_by.all? { |spec| spec.dependency_by_top_level_spec_name(name).only_part_of_other_pod? }
end
def name def name
@pod_dir.basename.to_s @pod_dir.basename.to_s
end end
...@@ -74,7 +77,7 @@ module Pod ...@@ -74,7 +77,7 @@ module Pod
end end
def name def name
@specification.name @specification.top_level_parent.name
end end
def ==(other) def ==(other)
...@@ -88,10 +91,6 @@ module Pod ...@@ -88,10 +91,6 @@ module Pod
@specification = before @specification = before
end end
def only_part_of_other_pod?
false
end
def specification_path def specification_path
raise "specification_path" raise "specification_path"
end end
......
...@@ -81,7 +81,7 @@ module Pod ...@@ -81,7 +81,7 @@ module Pod
def github_stats_if_needed(set) def github_stats_if_needed(set)
return if get_value(set, :gh_date) && get_value(set, :gh_date) > Time.now - cache_expiration return if get_value(set, :gh_date) && get_value(set, :gh_date) > Time.now - cache_expiration
spec = set.specification.part_of_other_pod? ? set.specification.part_of_specification : set.specification spec = set.specification
url = spec.source.reject {|k,_| k == :commit || k == :tag }.values.first url = spec.source.reject {|k,_| k == :commit || k == :tag }.values.first
repo_id = url[/github.com\/([^\/\.]*\/[^\/\.]*)\.*/, 1] repo_id = url[/github.com\/([^\/\.]*\/[^\/\.]*)\.*/, 1]
return unless repo_id return unless repo_id
......
Subproject commit 7e96b1af54872aba6e474ea5860e84f1ce534fb1 Subproject commit 7aec148979834c795a0c7f3108b4d48a9f1c0f5c
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Install" do describe "Pod::Command::Install" do
extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "should include instructions on how to reference the xcode project" do it "should include instructions on how to reference the xcode project" do
Pod::Command::Install.banner.should.match %r{xcodeproj 'path/to/XcodeProject'} Pod::Command::Install.banner.should.match %r{xcodeproj 'path/to/XcodeProject'}
end end
end
it "tells the user that no Podfile or podspec was found in the current working dir" do
exception = lambda { run_command('install','--no-update') }.should.raise Pod::Informative
exception.message.should.include "No `Podfile' found in the current working directory."
end
end
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::List" do describe "Pod::Command::List" do
extend SpecHelper::Git extend SpecHelper::TemporaryRepos
before do before do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
end end
after do
config.repos_dir = tmp_repos_path
end
def command(arguments = argv) def command(arguments = argv)
command = Pod::Command::List.new(arguments) command = Pod::Command::List.new(arguments)
end end
......
...@@ -2,8 +2,12 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,8 +2,12 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe Pod::Command::Push do describe Pod::Command::Push do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::Git
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
def master_repo
fixture('spec-repos/master')
end
it "complains for wrong parameters" do it "complains for wrong parameters" do
lambda { run_command('push') }.should.raise Pod::Command::Help lambda { run_command('push') }.should.raise Pod::Command::Help
...@@ -12,19 +16,19 @@ describe Pod::Command::Push do ...@@ -12,19 +16,19 @@ describe Pod::Command::Push do
end end
it "complains if it can't find the repo" do it "complains if it can't find the repo" do
repo1 = add_repo('repo1', fixture('spec-repos/master')) repo1 = add_repo('repo1', master_repo)
Dir.chdir(fixture('banana-lib')) do Dir.chdir(fixture('banana-lib')) do
lambda { run_command('push', 'repo2') }.should.raise Pod::Informative lambda { run_command('push', 'repo2') }.should.raise Pod::Informative
end end
end end
it "complains if it can't find a spec" do it "complains if it can't find a spec" do
repo1 = add_repo('repo1', fixture('spec-repos/master')) repo1 = add_repo('repo1', master_repo)
lambda { run_command('push', 'repo1') }.should.raise Pod::Informative lambda { run_command('push', 'repo1') }.should.raise Pod::Informative
end end
it "it raises if the pod is not validated" do it "it raises if the pod is not validated" do
repo1 = add_repo('repo1', fixture('spec-repos/master')) repo1 = add_repo('repo1', master_repo)
git('repo1', 'checkout master') # checkout master, because the fixture is a submodule git('repo1', 'checkout master') # checkout master, because the fixture is a submodule
repo2 = add_repo('repo2', repo1.dir) repo2 = add_repo('repo2', repo1.dir)
git_config('repo2', 'remote.origin.url').should == (tmp_repos_path + 'repo1').to_s git_config('repo2', 'remote.origin.url').should == (tmp_repos_path + 'repo1').to_s
...@@ -36,7 +40,7 @@ describe Pod::Command::Push do ...@@ -36,7 +40,7 @@ describe Pod::Command::Push do
before do before do
# prepare the repos # prepare the repos
@upstream = add_repo('upstream', fixture('spec-repos/master')) @upstream = add_repo('upstream', master_repo)
git('upstream', 'checkout -b master') # checkout master, because the fixture is a submodule git('upstream', 'checkout -b master') # checkout master, because the fixture is a submodule
@local_repo = add_repo('local_repo', @upstream.dir) @local_repo = add_repo('local_repo', @upstream.dir)
git_config('local_repo', 'remote.origin.url').should == (tmp_repos_path + 'upstream').to_s git_config('local_repo', 'remote.origin.url').should == (tmp_repos_path + 'upstream').to_s
......
...@@ -2,8 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,8 +2,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Repo" do describe "Pod::Command::Repo" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::Git
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "runs with correct parameters" do it "runs with correct parameters" do
lambda { run_command('repo', 'add', 'NAME', 'URL') }.should.not.raise lambda { run_command('repo', 'add', 'NAME', 'URL') }.should.not.raise
...@@ -42,6 +42,7 @@ describe "Pod::Command::Repo" do ...@@ -42,6 +42,7 @@ describe "Pod::Command::Repo" do
before do before do
add_repo('repo1', fixture('spec-repos/master')) add_repo('repo1', fixture('spec-repos/master'))
FileUtils.rm_rf(versions_file)
versions_file.should.not.exist? versions_file.should.not.exist?
end end
......
...@@ -2,18 +2,13 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -2,18 +2,13 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Search" do describe "Pod::Command::Search" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::Git
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
before do before do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
end end
after do
config.repos_dir = tmp_repos_path
end
it "runs with correct parameters" do it "runs with correct parameters" do
lambda { run_command('search', 'table') }.should.not.raise lambda { run_command('search', 'table') }.should.not.raise
lambda { run_command('search', 'table', '--full') }.should.not.raise lambda { run_command('search', 'table', '--full') }.should.not.raise
......
...@@ -3,8 +3,8 @@ require File.expand_path('../../../spec_helper', __FILE__) ...@@ -3,8 +3,8 @@ require File.expand_path('../../../spec_helper', __FILE__)
describe "Pod::Command::Setup" do describe "Pod::Command::Setup" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::Git
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
it "runs with correct parameters" do it "runs with correct parameters" do
lambda { run_command('setup') }.should.not.raise lambda { run_command('setup') }.should.not.raise
......
...@@ -18,12 +18,13 @@ describe "Pod::Command::Spec#create" do ...@@ -18,12 +18,13 @@ describe "Pod::Command::Spec#create" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::Github extend SpecHelper::Github
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::Git extend SpecHelper::TemporaryRepos
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
...@@ -93,16 +94,12 @@ end ...@@ -93,16 +94,12 @@ end
describe "Pod::Command::Spec#lint" do describe "Pod::Command::Spec#lint" do
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::Git extend SpecHelper::TemporaryRepos
before do before do
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
end end
after do
config.repos_dir = tmp_repos_path
end
it "lints a repo" do it "lints a repo" do
# The fixture has an error due to a name mismatch # The fixture has an error due to a name mismatch
cmd = command('spec', 'lint', 'master') cmd = command('spec', 'lint', 'master')
...@@ -124,17 +121,23 @@ describe "Pod::Command::Spec#lint" do ...@@ -124,17 +121,23 @@ describe "Pod::Command::Spec#lint" do
end end
end end
before do
text = (fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec').read
text.gsub!(/.*license.*/, "")
file = temporary_directory + 'JSONKit.podspec'
File.open(file, 'w') {|f| f.write(text) }
@spec_path = file.to_s
end
it "lints a givent podspec" do it "lints a givent podspec" do
spec_file = fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec' cmd = command('spec', 'lint', '--quick', @spec_path)
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 type"
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' cmd = command('spec', 'lint', '--quick', '--only-errors', @spec_path)
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 type"
end end
end end
...@@ -2,8 +2,8 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,8 +2,8 @@ require File.expand_path('../../spec_helper', __FILE__)
# describe "Pod::Command" do # describe "Pod::Command" do
# extend SpecHelper::Command # extend SpecHelper::Command
# extend SpecHelper::Git
# extend SpecHelper::TemporaryDirectory # extend SpecHelper::TemporaryDirectory
# extend SpecHelper::TemporaryRepos
# #
# TODO: # TODO:
# it "raises help informative if an unknown parameter is passed" # it "raises help informative if an unknown parameter is passed"
......
...@@ -9,7 +9,7 @@ describe "Pod::Downloader" do ...@@ -9,7 +9,7 @@ describe "Pod::Downloader" do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
it "check's out a specific commit" do it "check's out a specific commit" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:git => fixture('banana-lib'), :commit => 'fd56054' :git => fixture('banana-lib'), :commit => 'fd56054'
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -19,7 +19,7 @@ describe "Pod::Downloader" do ...@@ -19,7 +19,7 @@ describe "Pod::Downloader" do
end end
it "check's out a specific tag" do it "check's out a specific tag" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:git => fixture('banana-lib'), :tag => 'v1.0' :git => fixture('banana-lib'), :tag => 'v1.0'
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -28,7 +28,7 @@ describe "Pod::Downloader" do ...@@ -28,7 +28,7 @@ describe "Pod::Downloader" do
end end
it "removes the .git directory when cleaning" do it "removes the .git directory when cleaning" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:git => fixture('banana-lib') :git => fixture('banana-lib')
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -42,7 +42,7 @@ describe "Pod::Downloader" do ...@@ -42,7 +42,7 @@ describe "Pod::Downloader" do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
it "downloads HEAD with no other options specified" do it "downloads HEAD with no other options specified" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:git => "git://github.com/lukeredpath/libPusher.git", :download_only => true :git => "git://github.com/lukeredpath/libPusher.git", :download_only => true
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -54,7 +54,7 @@ describe "Pod::Downloader" do ...@@ -54,7 +54,7 @@ describe "Pod::Downloader" do
end end
it "downloads a specific tag when specified" do it "downloads a specific tag when specified" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:git => "git://github.com/lukeredpath/libPusher.git", :tag => 'v1.1', :download_only => true :git => "git://github.com/lukeredpath/libPusher.git", :tag => 'v1.1', :download_only => true
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -66,7 +66,7 @@ describe "Pod::Downloader" do ...@@ -66,7 +66,7 @@ describe "Pod::Downloader" do
end end
it "downloads a specific commit when specified" do it "downloads a specific commit when specified" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:git => "git://github.com/lukeredpath/libPusher.git", :commit => 'eca89998d5', :download_only => true :git => "git://github.com/lukeredpath/libPusher.git", :commit => 'eca89998d5', :download_only => true
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -78,7 +78,7 @@ describe "Pod::Downloader" do ...@@ -78,7 +78,7 @@ describe "Pod::Downloader" do
end end
it 'deletes the downloaded tarball after unpacking it' do it 'deletes the downloaded tarball after unpacking it' do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:git => "git://github.com/lukeredpath/libPusher.git", :download_only => true :git => "git://github.com/lukeredpath/libPusher.git", :download_only => true
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -90,7 +90,7 @@ describe "Pod::Downloader" do ...@@ -90,7 +90,7 @@ describe "Pod::Downloader" do
end end
it "removes the .git directory when cleaning" do it "removes the .git directory when cleaning" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:git => "git://github.com/lukeredpath/libPusher.git", :download_only => false :git => "git://github.com/lukeredpath/libPusher.git", :download_only => false
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -103,7 +103,7 @@ describe "Pod::Downloader" do ...@@ -103,7 +103,7 @@ describe "Pod::Downloader" do
describe "for Mercurial" do describe "for Mercurial" do
it "check's out a specific revision" do it "check's out a specific revision" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:hg => fixture('mercurial-repo'), :revision => '46198bb3af96' :hg => fixture('mercurial-repo'), :revision => '46198bb3af96'
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -112,7 +112,7 @@ describe "Pod::Downloader" do ...@@ -112,7 +112,7 @@ describe "Pod::Downloader" do
end end
it "removes the .hg directory when cleaning" do it "removes the .hg directory when cleaning" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:hg => fixture('mercurial-repo') :hg => fixture('mercurial-repo')
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -124,7 +124,7 @@ describe "Pod::Downloader" do ...@@ -124,7 +124,7 @@ describe "Pod::Downloader" do
describe "for Subversion" do describe "for Subversion" do
it "check's out a specific revision" do it "check's out a specific revision" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:svn => "file://#{fixture('subversion-repo')}", :revision => '1' :svn => "file://#{fixture('subversion-repo')}", :revision => '1'
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -133,7 +133,7 @@ describe "Pod::Downloader" do ...@@ -133,7 +133,7 @@ describe "Pod::Downloader" do
end end
it "check's out a specific tag" do it "check's out a specific tag" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:svn => "file://#{fixture('subversion-repo')}/tags/tag-1" :svn => "file://#{fixture('subversion-repo')}/tags/tag-1"
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -142,7 +142,7 @@ describe "Pod::Downloader" do ...@@ -142,7 +142,7 @@ describe "Pod::Downloader" do
end end
it "removes the .svn directories when cleaning" do it "removes the .svn directories when cleaning" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:svn => "file://#{fixture('subversion-repo')}/trunk" :svn => "file://#{fixture('subversion-repo')}/trunk"
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -156,7 +156,7 @@ describe "Pod::Downloader" do ...@@ -156,7 +156,7 @@ describe "Pod::Downloader" do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
it "download file and unzip it" do it "download file and unzip it" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:http => 'http://dl.google.com/googleadmobadssdk/googleadmobsearchadssdkios.zip' :http => 'http://dl.google.com/googleadmobadssdk/googleadmobsearchadssdkios.zip'
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
...@@ -167,7 +167,7 @@ describe "Pod::Downloader" do ...@@ -167,7 +167,7 @@ describe "Pod::Downloader" do
end end
it "removes the .zip when cleaning" do it "removes the .zip when cleaning" do
@pod.specification.stubs(:source).returns( @pod.top_specification.stubs(:source).returns(
:http => 'http://dl.google.com/googleadmobadssdk/googleadmobsearchadssdkios.zip' :http => 'http://dl.google.com/googleadmobadssdk/googleadmobsearchadssdkios.zip'
) )
downloader = Pod::Downloader.for_pod(@pod) downloader = Pod::Downloader.for_pod(@pod)
......
...@@ -29,10 +29,6 @@ describe Pod::Installer::UserProjectIntegrator do ...@@ -29,10 +29,6 @@ describe Pod::Installer::UserProjectIntegrator do
@sample_project = Xcodeproj::Project.new(@sample_project_path) @sample_project = Xcodeproj::Project.new(@sample_project_path)
end end
after do
config.project_root = nil
end
it 'creates a workspace with a name matching the project' do it 'creates a workspace with a name matching the project' do
workspace_path = @sample_project_path.dirname + "SampleProject.xcworkspace" workspace_path = @sample_project_path.dirname + "SampleProject.xcworkspace"
workspace_path.should.exist workspace_path.should.exist
......
...@@ -9,7 +9,6 @@ module SpecHelper ...@@ -9,7 +9,6 @@ module SpecHelper
def specs_by_target def specs_by_target
@specs_by_target ||= super.tap do |hash| @specs_by_target ||= super.tap do |hash|
hash.values.flatten.each do |spec| hash.values.flatten.each do |spec|
unless spec.part_of_other_pod?
source = spec.source source = spec.source
source[:git] = SpecHelper.fixture("integration/#{spec.name}").to_s source[:git] = SpecHelper.fixture("integration/#{spec.name}").to_s
spec.source = source spec.source = source
...@@ -17,7 +16,6 @@ module SpecHelper ...@@ -17,7 +16,6 @@ module SpecHelper
end end
end end
end end
end
end end
unless SpecHelper.fixture('integration/ASIHTTPRequest/Classes').exist? unless SpecHelper.fixture('integration/ASIHTTPRequest/Classes').exist?
...@@ -28,37 +26,14 @@ else ...@@ -28,37 +26,14 @@ else
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
def create_config! def create_config!
Pod::Config.instance = nil
if ENV['VERBOSE_SPECS']
config.verbose = true
else
config.silent = true
end
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
config.project_root = temporary_directory config.project_root = temporary_directory
config.doc_install = false
config.integrate_targets = false config.integrate_targets = false
end end
before do before do
fixture('spec-repos/master') # ensure the archive is unpacked fixture('spec-repos/master') # ensure the archive is unpacked
@config_before = config
create_config! create_config!
config.generate_docs = false
end
after do
Pod::Config.instance = @config_before
end
# This is so we can run at least the specs that don't use xcodebuild on Travis.
def with_xcodebuild_available
unless `which xcodebuild`.strip.empty?
yield
else
puts "\n[!] Skipping xcodebuild, because it can't be found."
end
end end
def should_successfully_perform(command) def should_successfully_perform(command)
...@@ -67,11 +42,14 @@ else ...@@ -67,11 +42,14 @@ else
$?.should.be.success $?.should.be.success
end end
puts " ! ".red << "Skipping xcodebuild based checks, because it can't be found." if `which xcodebuild`.strip.empty?
def should_xcodebuild(target_definition) def should_xcodebuild(target_definition)
return if `which xcodebuilda`.strip.empty?
target = target_definition target = target_definition
with_xcodebuild_available do with_xcodebuild_available do
Dir.chdir(config.project_pods_root) do Dir.chdir(config.project_pods_root) do
puts "\n[!] Compiling #{target.label} static library..." print "[!] Compiling #{target.label}...\r"
should_successfully_perform "xcodebuild -target '#{target.label}'" should_successfully_perform "xcodebuild -target '#{target.label}'"
lib_path = config.project_pods_root + "build/Release#{'-iphoneos' if target.platform == :ios}" + target.lib_name lib_path = config.project_pods_root + "build/Release#{'-iphoneos' if target.platform == :ios}" + target.lib_name
`lipo -info '#{lib_path}'`.should.include "architecture: #{target.platform == :ios ? 'armv7' : 'x86_64'}" `lipo -info '#{lib_path}'`.should.include "architecture: #{target.platform == :ios ? 'armv7' : 'x86_64'}"
...@@ -113,13 +91,13 @@ else ...@@ -113,13 +91,13 @@ else
installer.install! installer.install!
YAML.load(installer.lock_file.read).should == { YAML.load(installer.lock_file.read).should == {
'PODS' => [{ 'Reachability (1.2.3)' => ["ASIHTTPRequest (>= 1.8)"] }], 'PODS' => [ 'Reachability (1.2.3)' ],
'DOWNLOAD_ONLY' => ["ASIHTTPRequest (1.8.1)"], # 'DOWNLOAD_ONLY' => ["ASIHTTPRequest (1.8.1)"],
'DEPENDENCIES' => ["Reachability (from `#{url}')"] 'DEPENDENCIES' => ["Reachability (from `#{url}')"]
} }
end end
it "install a dummy source file" do it "installs a dummy source file" do
create_config! create_config!
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform :ios self.platform :ios
...@@ -157,6 +135,7 @@ else ...@@ -157,6 +135,7 @@ else
end end
end end
Pod::Specification.any_instance.stubs(:preserve_paths).returns(['CHANGELOG.md'])
installer = SpecHelper::Installer.new(podfile) installer = SpecHelper::Installer.new(podfile)
installer.install! installer.install!
...@@ -199,7 +178,16 @@ else ...@@ -199,7 +178,16 @@ else
unless `which appledoc`.strip.empty? unless `which appledoc`.strip.empty?
it "generates documentation of all pods by default" do it "generates documentation of all pods by default" do
create_config! ::Pod::Config.instance = nil
::Pod::Config.instance.tap do |c|
ENV['VERBOSE_SPECS'] ? c.verbose = true : c.silent = true
c.doc_install = false
c.repos_dir = fixture('spec-repos')
c.project_root = temporary_directory
c.integrate_targets = false
end
Pod::Generator::Documentation.any_instance.stubs(:already_installed?).returns(false)
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform :ios self.platform :ios
...@@ -207,9 +195,6 @@ else ...@@ -207,9 +195,6 @@ else
dependency 'JSONKit', '1.4' dependency 'JSONKit', '1.4'
dependency 'SSToolkit' dependency 'SSToolkit'
end end
Pod::Generator::Documentation.any_instance.stubs(:already_installed?).returns(false)
installer = SpecHelper::Installer.new(podfile) installer = SpecHelper::Installer.new(podfile)
installer.install! installer.install!
...@@ -219,7 +204,7 @@ else ...@@ -219,7 +204,7 @@ else
doc.should.include?('<title>SSToolkit 0.1.2 Reference</title>') doc.should.include?('<title>SSToolkit 0.1.2 Reference</title>')
end end
else else
puts "[!] Skipping documentation generation specs, because appledoc can't be found." puts " ! ".red << "Skipping documentation generation specs, because appledoc can't be found."
end end
end end
...@@ -249,12 +234,13 @@ else ...@@ -249,12 +234,13 @@ else
end end
# TODO add a simple source file which uses the compiled lib to check that it really really works # TODO add a simple source file which uses the compiled lib to check that it really really works
# TODO update for specification refactor
it "activates required pods and create a working static library xcode project" do it "activates required pods and create a working static library xcode project" do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
self.platform platform self.platform platform
xcodeproj 'dummy' xcodeproj 'dummy'
dependency 'Reachability', '> 2.0.5' if platform == :ios dependency 'Reachability', '> 2.0.5' if platform == :ios
dependency 'ASIWebPageRequest', '>= 1.8.1' # dependency 'ASIWebPageRequest', '>= 1.8.1'
dependency 'JSONKit', '>= 1.0' dependency 'JSONKit', '>= 1.0'
dependency 'SSZipArchive', '< 2' dependency 'SSZipArchive', '< 2'
end end
...@@ -264,14 +250,14 @@ else ...@@ -264,14 +250,14 @@ else
lock_file_contents = { lock_file_contents = {
'PODS' => [ 'PODS' => [
{ 'ASIHTTPRequest (1.8.1)' => ["Reachability"] }, # { 'ASIHTTPRequest (1.8.1)' => ["Reachability"] },
{ 'ASIWebPageRequest (1.8.1)' => ["ASIHTTPRequest (= 1.8.1)"] }, # { 'ASIWebPageRequest (1.8.1)' => ["ASIHTTPRequest (= 1.8.1)"] },
'JSONKit (1.5pre)', 'JSONKit (1.5pre)',
'Reachability (3.0.0)', 'Reachability (3.0.0)',
'SSZipArchive (0.1.2)', 'SSZipArchive (0.1.2)',
], ],
'DEPENDENCIES' => [ 'DEPENDENCIES' => [
"ASIWebPageRequest (>= 1.8.1)", # "ASIWebPageRequest (>= 1.8.1)",
"JSONKit (>= 1.0)", "JSONKit (>= 1.0)",
"Reachability (> 2.0.5)", "Reachability (> 2.0.5)",
"SSZipArchive (< 2)", "SSZipArchive (< 2)",
...@@ -279,9 +265,9 @@ else ...@@ -279,9 +265,9 @@ else
} }
unless platform == :ios unless platform == :ios
# No Reachability is required by ASIHTTPRequest on OSX # No Reachability is required by ASIHTTPRequest on OSX
lock_file_contents['DEPENDENCIES'].delete_at(2) lock_file_contents['DEPENDENCIES'].delete_at(1)
lock_file_contents['PODS'].delete_at(3) lock_file_contents['PODS'].delete_at(1)
lock_file_contents['PODS'][0] = 'ASIHTTPRequest (1.8.1)' # lock_file_contents['PODS'][0] = 'ASIHTTPRequest (1.8.1)'
end end
YAML.load(installer.lock_file.read).should == lock_file_contents YAML.load(installer.lock_file.read).should == lock_file_contents
...@@ -294,6 +280,7 @@ else ...@@ -294,6 +280,7 @@ else
end end
if platform == :ios if platform == :ios
# TODO: update for Specification Refactor
it "does not activate pods that are only part of other pods" do it "does not activate pods that are only part of other pods" do
spec = Pod::Podfile.new do spec = Pod::Podfile.new do
self.platform platform self.platform platform
...@@ -305,8 +292,9 @@ else ...@@ -305,8 +292,9 @@ else
installer.install! installer.install!
YAML.load(installer.lock_file.read).should == { YAML.load(installer.lock_file.read).should == {
'PODS' => [{ 'Reachability (2.0.4)' => ["ASIHTTPRequest (>= 1.8)"] }], # 'PODS' => [{ 'Reachability (2.0.4)' => ["ASIHTTPRequest (>= 1.8)"] }],
'DOWNLOAD_ONLY' => ["ASIHTTPRequest (1.8.1)"], 'PODS' => [ 'Reachability (2.0.4)' ],
# 'DOWNLOAD_ONLY' => ["ASIHTTPRequest (1.8.1)"],
'DEPENDENCIES' => ["Reachability (= 2.0.4)"] 'DEPENDENCIES' => ["Reachability (= 2.0.4)"]
} }
end end
...@@ -321,7 +309,7 @@ else ...@@ -321,7 +309,7 @@ else
installer = SpecHelper::Installer.new(spec) installer = SpecHelper::Installer.new(spec)
target_definition = installer.target_installers.first.target_definition target_definition = installer.target_installers.first.target_definition
installer.activated_specifications_for_target(target_definition).first.resources = 'LICEN*', 'Readme.*' installer.specs_by_target[target_definition].first.resources = 'LICEN*', 'Readme.*'
installer.install! installer.install!
contents = (config.project_pods_root + 'Pods-resources.sh').read contents = (config.project_pods_root + 'Pods-resources.sh').read
......
...@@ -12,47 +12,30 @@ $:.unshift((ROOT + 'lib').to_s) ...@@ -12,47 +12,30 @@ $:.unshift((ROOT + 'lib').to_s)
require 'cocoapods' require 'cocoapods'
$:.unshift((ROOT + 'spec').to_s) $:.unshift((ROOT + 'spec').to_s)
require 'spec_helper/color_output' require 'spec_helper/bacon'
require 'spec_helper/command' require 'spec_helper/command'
require 'spec_helper/fixture' require 'spec_helper/fixture'
require 'spec_helper/git'
require 'spec_helper/github' require 'spec_helper/github'
require 'spec_helper/temporary_directory' require 'spec_helper/temporary_directory'
require 'spec_helper/temporary_repos'
require 'spec_helper/config'
module Bacon module Bacon
extend ColorOutput
summary_at_exit
module FilterBacktraces
def handle_summary
ErrorLog.replace(ErrorLog.split("\n").reject do |line|
line =~ %r{(gems/mocha|spec_helper)}
end.join("\n").lstrip << "\n\n")
super
end
end
extend FilterBacktraces
class Context class Context
include Pod::Config::Mixin include Pod::Config::Mixin
include SpecHelper::Fixture include SpecHelper::Fixture
def argv(*argv) def argv(*argv)
Pod::Command::ARGV.new(argv) Pod::Command::ARGV.new(argv)
end end
require 'colored'
def xit(description, *args)
puts "- #{description} [DISABLED]".yellow
ErrorLog << "[DISABLED] #{self.name} #{description}\n\n"
end
end end
end end
config = Pod::Config.instance config = Pod::Config.instance
config.silent = true config.silent = true
config.repos_dir = SpecHelper.tmp_repos_path config.repos_dir = SpecHelper.tmp_repos_path
config.project_root = SpecHelper.temporary_directory
Pod::Specification::Statistics.instance.cache_file = nil
require 'tmpdir' require 'tmpdir'
...@@ -85,5 +68,3 @@ VCR.configure do |c| ...@@ -85,5 +68,3 @@ VCR.configure do |c|
c.allow_http_connections_when_no_cassette = true c.allow_http_connections_when_no_cassette = true
end end
Pod::Specification::Statistics.instance.cache_file = nil
module Bacon
summary_at_exit
@needs_first_put = true
module ColorOutput
# Graciously yanked from https://github.com/zen-cms/Zen-Core and subsequently modified
# MIT License
# Thanks, YorickPeterse! #:nodoc:
def handle_specification(name)
if @needs_first_put
@needs_first_put = false
puts
end
@specs_depth = @specs_depth || 0
puts spaces + name
@specs_depth += 1
yield
@specs_depth -= 1
puts if @specs_depth.zero?
end
#:nodoc:
def handle_requirement(description, disabled = false)
error = yield
if !error.empty?
puts "#{spaces}\e[31m- #{description} [FAILED]\e[0m"
elsif disabled
puts "#{spaces}\e[33m- #{description} [DISABLED]\e[0m"
else
puts "#{spaces}\e[32m- #{description}\e[0m"
end
end
#:nodoc:
def handle_summary
print ErrorLog if Backtraces
puts "\e[33m#{Counter[:disabled]} disabled specifications\n\e[0m" unless Counter[:disabled].zero?
puts "%d specifications (%d requirements), %d failures, %d errors" %
Counter.values_at(:specifications, :requirements, :failed, :errors)
end
#:nodoc:
def spaces
return ' ' * @specs_depth
end
end
extend ColorOutput
module FilterBacktraces
def handle_summary
ErrorLog.replace(ErrorLog.split("\n").reject do |line|
line =~ %r{(gems/mocha|spec_helper)}
end.join("\n").lstrip << "\n\n")
super
end
end
extend FilterBacktraces
class Context
def xit(description, *args)
Counter[:disabled] += 1
Bacon.handle_requirement(description, true) {[]}
end
end
end
# Graciously yanked from https://github.com/zen-cms/Zen-Core
# MIT License
# Thanks, YorickPeterse!
#:nodoc:
module Bacon
#:nodoc:
module ColorOutput
#:nodoc:
def handle_specification(name)
puts spaces + name
yield
puts if Counter[:context_depth] == 1
end
#:nodoc:
def handle_requirement(description)
error = yield
if !error.empty?
puts "#{spaces} \e[31m- #{description} [FAILED]\e[0m"
else
puts "#{spaces} \e[32m- #{description}\e[0m"
end
end
#:nodoc:
def handle_summary
print ErrorLog if Backtraces
puts "%d specifications (%d requirements), %d failures, %d errors" %
Counter.values_at(:specifications, :requirements, :failed, :errors)
end
#:nodoc:
def spaces
if Counter[:context_depth] == 0
Counter[:context_depth] = 1
end
return ' ' * (Counter[:context_depth] - 1)
end
end # ColorOutput
end # Bacon
# Restores the config to the default state before each requirement
module Bacon
class Context
old_run_requirement = instance_method(:run_requirement)
define_method(:run_requirement) do |description, spec|
::Pod::Config.instance = nil
::Pod::Config.instance.tap do |c|
ENV['VERBOSE_SPECS'] ? c.verbose = true : c.silent = true
c.repos_dir = SpecHelper.tmp_repos_path
c.project_root = SpecHelper.temporary_directory
c.doc_install = false
c.generate_docs = false
end
old_run_requirement.bind(self).call(description, spec)
end
end
end
...@@ -2,22 +2,18 @@ require 'spec_helper/temporary_directory' ...@@ -2,22 +2,18 @@ require 'spec_helper/temporary_directory'
module SpecHelper module SpecHelper
def self.tmp_repos_path def self.tmp_repos_path
Git.tmp_repos_path TemporaryRepos.tmp_repos_path
end end
module Git module TemporaryRepos
extend Pod::Executable
executable :git
def tmp_repos_path def tmp_repos_path
SpecHelper.temporary_directory + 'cocoapods' SpecHelper.temporary_directory + 'cocoapods'
end end
module_function :tmp_repos_path module_function :tmp_repos_path
def tmp_master_repo_path
tmp_repos_path + 'master'
end
extend Pod::Executable
executable :git
alias_method :git_super, :git alias_method :git_super, :git
def git(repo, command) def git(repo, command)
Dir.chdir(tmp_repos_path + repo) do Dir.chdir(tmp_repos_path + repo) do
...@@ -42,5 +38,12 @@ module SpecHelper ...@@ -42,5 +38,12 @@ module SpecHelper
git(name, 'add README') git(name, 'add README')
git(name, 'commit -m "changed"') git(name, 'commit -m "changed"')
end end
def self.extended(base)
base.before do
tmp_repos_path.mkpath
end
end
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
...@@ -53,8 +53,8 @@ describe "Pod::Command::Spec::Linter" do ...@@ -53,8 +53,8 @@ describe "Pod::Command::Spec::Linter" do
end end
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(/.*license.*/, ""))
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
...@@ -62,8 +62,8 @@ describe "Pod::Command::Spec::Linter" do ...@@ -62,8 +62,8 @@ describe "Pod::Command::Spec::Linter" do
end end
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(/.*license.*/, ""))
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,16 +83,16 @@ describe "Pod::Command::Spec::Linter" do ...@@ -83,16 +83,16 @@ 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
linter.warnings.join(' | ').should =~ /`config.ios\?' and `config.osx\?' are deprecated and will be removed in version 0.7/ linter.warnings.join(' | ').should =~ /`config.ios\?' and `config.osx\?' are deprecated/
end end
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,10 +100,10 @@ describe "Pod::Command::Spec::Linter" do ...@@ -100,10 +100,10 @@ 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 "The resources did not match any file"
end end
end end
...@@ -15,12 +15,3 @@ describe "Pod::Command::Repo" do ...@@ -15,12 +15,3 @@ describe "Pod::Command::Repo" do
end end
end end
describe "Pod::Command::Install" do
it "tells the user that no Podfile or podspec was found in the current working dir" do
command = Pod::Command::Install.new(argv)
exception = lambda {
command.run
}.should.raise Pod::Informative
exception.message.should.include "No `Podfile' found in the current working directory."
end
end
...@@ -2,14 +2,9 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,14 +2,9 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Config" do describe "Pod::Config" do
before do before do
@original_config = config
Pod::Config.instance = nil Pod::Config.instance = nil
end end
after do
Pod::Config.instance = @original_config
end
it "returns the singleton config instance" do it "returns the singleton config instance" do
config.should.be.instance_of Pod::Config config.should.be.instance_of Pod::Config
end end
...@@ -22,7 +17,9 @@ describe "Pod::Config" do ...@@ -22,7 +17,9 @@ describe "Pod::Config" do
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
it "returns the path to the project root" do it "returns the path to the project root" do
config.project_root = nil
config.project_root.should == Pathname.pwd config.project_root.should == Pathname.pwd
config.project_root = temporary_directory
end end
it "returns the path to the project Podfile if it exists" do it "returns the path to the project Podfile if it exists" do
......
...@@ -7,15 +7,6 @@ describe "Pod::Dependency" do ...@@ -7,15 +7,6 @@ describe "Pod::Dependency" do
dep1.merge(dep2).should == Pod::Dependency.new('bananas', '>= 1.8', '1.9') dep1.merge(dep2).should == Pod::Dependency.new('bananas', '>= 1.8', '1.9')
end end
it "is equal to another dependency if `part_of_other_pod' is the same" do
dep1 = Pod::Dependency.new('bananas', '>= 1')
dep1.only_part_of_other_pod = true
dep2 = Pod::Dependency.new('bananas', '>= 1')
dep1.should.not == dep2
dep2.only_part_of_other_pod = true
dep1.should == dep2
end
it "returns the name of the dependency, or the name of the pod of which this is a subspec" do it "returns the name of the dependency, or the name of the pod of which this is a subspec" do
dep = Pod::Dependency.new('RestKit') dep = Pod::Dependency.new('RestKit')
dep.top_level_spec_name.should == 'RestKit' dep.top_level_spec_name.should == 'RestKit'
......
...@@ -2,12 +2,11 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,12 +2,11 @@ require File.expand_path('../../spec_helper', __FILE__)
def stub_pod_with_source(source_options) def stub_pod_with_source(source_options)
specification = stub( specification = stub(
:part_of_other_pod? => false,
:source => source_options :source => source_options
) )
stub('pod') do stub('pod') do
stubs(:root).returns(temporary_sandbox.root) stubs(:root).returns(temporary_sandbox.root)
stubs(:specification).returns(specification) stubs(:top_specification).returns(specification)
end end
end end
...@@ -22,7 +21,7 @@ describe "Pod::Downloader" do ...@@ -22,7 +21,7 @@ describe "Pod::Downloader" do
it 'returns a github downloader when the :git URL is on github' do it 'returns a github downloader when the :git URL is on github' do
pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), temporary_sandbox, Pod::Platform.ios) pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), temporary_sandbox, Pod::Platform.ios)
pod.specification.stubs(:source).returns(:git => "git://github.com/CocoaPods/CocoaPods") pod.top_specification.stubs(:source).returns(:git => "git://github.com/CocoaPods/CocoaPods")
downloader = Pod::Downloader.for_pod(pod) downloader = Pod::Downloader.for_pod(pod)
downloader.should.be.instance_of Pod::Downloader::GitHub downloader.should.be.instance_of Pod::Downloader::GitHub
end end
......
...@@ -18,11 +18,8 @@ describe Pod::Generator::Documentation do ...@@ -18,11 +18,8 @@ describe Pod::Generator::Documentation do
} }
end end
it 'returns the Pod documentation documentation files' do it 'returns the Pod documentation header files' do
@doc_installer.files.sort.should == [ @doc_installer.files.sort.should == %w[ Classes/Banana.h ].sort
(@pod.root + "Classes/Banana.m").to_s,
(@pod.root + "Classes/Banana.h").to_s,
].sort
end end
it 'returns the Pod documentation options' do it 'returns the Pod documentation options' do
......
...@@ -2,12 +2,11 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,12 +2,11 @@ require File.expand_path('../../spec_helper', __FILE__)
def stub_pod_with_source(source_options) def stub_pod_with_source(source_options)
specification = stub( specification = stub(
:part_of_other_pod? => false,
:source => source_options :source => source_options
) )
stub('pod') do stub('pod') do
stubs(:root).returns(temporary_sandbox.root) stubs(:root).returns(temporary_sandbox.root)
stubs(:specification).returns(specification) stubs(:top_specification).returns(specification)
end end
end end
......
...@@ -21,10 +21,6 @@ describe Pod::Installer::UserProjectIntegrator do ...@@ -21,10 +21,6 @@ describe Pod::Installer::UserProjectIntegrator do
@integrator = Pod::Installer::UserProjectIntegrator.new(@podfile) @integrator = Pod::Installer::UserProjectIntegrator.new(@podfile)
end end
after do
config.project_root = nil
end
it "returns the path to the workspace from the Podfile" do it "returns the path to the workspace from the Podfile" do
@integrator.workspace_path.should == config.project_root + 'SampleProject.xcworkspace' @integrator.workspace_path.should == config.project_root + 'SampleProject.xcworkspace'
end end
......
...@@ -2,18 +2,11 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,18 +2,11 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Installer" do describe "Pod::Installer" do
before do before do
@config_before = config
Pod::Config.instance = nil
config.silent = true
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
config.project_pods_root = fixture('integration') config.project_pods_root = fixture('integration')
end end
after do describe "by default" do
Pod::Config.instance = @config_before
end
describe ", by default," do
before do before do
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
platform :ios platform :ios
...@@ -42,7 +35,7 @@ describe "Pod::Installer" do ...@@ -42,7 +35,7 @@ describe "Pod::Installer" do
dependency 'ASIHTTPRequest' dependency 'ASIHTTPRequest'
end end
installer = Pod::Installer.new(podfile) installer = Pod::Installer.new(podfile)
pods = installer.activated_specifications.map do |spec| pods = installer.specifications.map do |spec|
Pod::LocalPod.new(spec, installer.sandbox, podfile.target_definitions[:default].platform) Pod::LocalPod.new(spec, installer.sandbox, podfile.target_definitions[:default].platform)
end end
expected = pods.map { |pod| pod.header_files }.flatten.map { |header| config.project_pods_root + header } expected = pods.map { |pod| pod.header_files }.flatten.map { |header| config.project_pods_root + header }
......
...@@ -3,7 +3,7 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -3,7 +3,7 @@ require File.expand_path('../../spec_helper', __FILE__)
describe Pod::LocalPod do describe Pod::LocalPod do
# a LocalPod represents a local copy of the dependency, inside the pod root, built from a spec # a LocalPod represents a local copy of the dependency, inside the pod root, built from a spec
describe "in general" do
before do before do
@sandbox = temporary_sandbox @sandbox = temporary_sandbox
@pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), @sandbox, Pod::Platform.new(:ios)) @pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), @sandbox, Pod::Platform.new(:ios))
...@@ -38,7 +38,8 @@ describe Pod::LocalPod do ...@@ -38,7 +38,8 @@ describe Pod::LocalPod do
end end
it 'returns an expanded list of absolute clean paths' do it 'returns an expanded list of absolute clean paths' do
@pod.clean_paths.should == [@sandbox.root + "BananaLib/sub-dir"] #TODO: there are some temporary files that prevent a complete check
@pod.clean_paths.map { |p| p.relative_path_from(@sandbox.root).to_s }.should.include 'BananaLib/sub-dir/sub-dir-2/somefile.txt'
end end
it 'returns an expanded list of resources, relative to the sandbox root' do it 'returns an expanded list of resources, relative to the sandbox root' do
...@@ -49,16 +50,6 @@ describe Pod::LocalPod do ...@@ -49,16 +50,6 @@ describe Pod::LocalPod do
@pod.header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")] @pod.header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")]
end end
it 'can clean up after itself' do
@pod.clean_paths.tap do |paths|
@pod.clean
paths.each do |path|
path.should.not.exist
end
end
end
it "can link it's headers into the sandbox" do it "can link it's headers into the sandbox" do
@pod.link_headers @pod.link_headers
expected_header_path = @sandbox.headers_root + "BananaLib/Banana.h" expected_header_path = @sandbox.headers_root + "BananaLib/Banana.h"
...@@ -68,19 +59,24 @@ describe Pod::LocalPod do ...@@ -68,19 +59,24 @@ describe Pod::LocalPod do
it "can add it's source files to an Xcode project target" do it "can add it's source files to an Xcode project target" do
target = mock('target') target = mock('target')
target.expects(:add_source_file).with(Pathname.new("BananaLib/Classes/Banana.h"), anything, anything)
target.expects(:add_source_file).with(Pathname.new("BananaLib/Classes/Banana.m"), anything, anything) target.expects(:add_source_file).with(Pathname.new("BananaLib/Classes/Banana.m"), anything, anything)
@pod.add_to_target(target) @pod.add_to_target(target)
end end
it "can add it's source files to a target with any specially configured compiler flags" do it "can add it's source files to a target with any specially configured compiler flags" do
@pod.specification.compiler_flags = '-d some_flag' @pod.top_specification.compiler_flags = '-d some_flag'
target = mock('target') target = mock('target')
target.expects(:add_source_file).with(anything, anything, "-d some_flag") target.expects(:add_source_file).twice.with(anything, anything, "-d some_flag")
@pod.add_to_target(target) @pod.add_to_target(target)
end end
end
describe "A Pod::LocalPod, with installed source," do it "returns the platform" do
@pod.platform.should == :ios
end
end
describe "with installed source," do
#before do #before do
#config.project_pods_root = fixture('integration') #config.project_pods_root = fixture('integration')
#podspec = fixture('spec-repos/master/SSZipArchive/0.1.0/SSZipArchive.podspec') #podspec = fixture('spec-repos/master/SSZipArchive/0.1.0/SSZipArchive.podspec')
...@@ -88,10 +84,6 @@ describe "A Pod::LocalPod, with installed source," do ...@@ -88,10 +84,6 @@ describe "A Pod::LocalPod, with installed source," do
#@destroot = fixture('integration/SSZipArchive') #@destroot = fixture('integration/SSZipArchive')
#end #end
#after do
#config.project_pods_root = nil
#end
xit "returns the list of files that the source_files pattern expand to" do xit "returns the list of files that the source_files pattern expand to" do
files = @destroot.glob('**/*.{h,c,m}') files = @destroot.glob('**/*.{h,c,m}')
files = files.map { |file| file.relative_path_from(config.project_pods_root) } files = files.map { |file| file.relative_path_from(config.project_pods_root) }
...@@ -173,4 +165,83 @@ describe "A Pod::LocalPod, with installed source," do ...@@ -173,4 +165,83 @@ describe "A Pod::LocalPod, with installed source," do
@spec.expanded_resources[:ios].map(&:to_s).should == %w{ SSZipArchive/LICENSE SSZipArchive/Readme.markdown } @spec.expanded_resources[:ios].map(&:to_s).should == %w{ SSZipArchive/LICENSE SSZipArchive/Readme.markdown }
@spec.expanded_resources[:osx].map(&:to_s).should == %w{ SSZipArchive/LICENSE SSZipArchive/Readme.markdown } @spec.expanded_resources[:osx].map(&:to_s).should == %w{ SSZipArchive/LICENSE SSZipArchive/Readme.markdown }
end end
end
describe "regarding multiple subspecs" do
before do
# specification with only some subspecs activated
# to check that only the needed files are being activated
# A fixture is needed.
#
# specification = Pod::Spec.new do |s|
# ...
# s.xcconfig = ...
# s.compiler_flags = ...
# s.subspec 's1' do |s1|
# s1.xcconfig = ...
# s1.compiler_flags = ...
# s1.ns.source_files = 's1.{h,m}'
# end
#
# s.subspec 's2' do |s2|
# s2.ns.source_files = 's2.{h,m}'
# end
#
# Add only s1 to the localPod
# s1 = specification.subspec_by_name(s1)
# @pod = Pod::LocalPod.new(s1, @sandbox, Pod::Platform.new(:ios))
# @pod.add_specification(specification)
end
xit "returns the subspecs" do
@pod.subspecs.map{ |s| name }.should == %w[ s1 ]
end
xit "resolve the source files" do
@pod.source_files.should == %w[ s1.h s1.m ]
end
xit "resolve the resources" do
end
xit "resolve the clean paths" do
@pod.clean_paths.should == %w[ s2.h s2.m ]
end
xit "resolves the used files" do
@pod.used_files.should == %w[ s1.h s1.m README.md ]
end
xit "resolved the header files" do
@pod.header_files.should == %w[ s1.h ]
end
xit "resolves the header files of every subspec" do
@pod.all_specs_public_header_files.should == %w[ s1.h s2.h ]
end
xit "merges the xcconfigs" do
end
xit "adds each file to a target with the compiler flags of its specification" do
# @pod.add_to_target(target)
end
xit "can provide the source files of all the subspecs" do
sources = @pod.all_specs_source_files.map { |p| p.relative_path_from(@sandbox.root).to_s }
sources.should == %w[ s1.h s1.m s2.h s2.m ]
end
xit 'can clean the unused files' do
# copy fixture to another folder
@pod.clean
@pod.clean_paths.tap do |paths|
paths.each do |path|
path.should.not.exist
end
end
end
end
end end
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
describe Pod::Platform do describe Pod::Platform do
describe "by default" do
it "returns a new Platform instance" do it "returns a new Platform instance" do
Pod::Platform.ios.should == Pod::Platform.new(:ios) Pod::Platform.ios.should == Pod::Platform.new(:ios)
Pod::Platform.osx.should == Pod::Platform.new(:osx) Pod::Platform.osx.should == Pod::Platform.new(:osx)
...@@ -56,9 +57,9 @@ describe Pod::Platform do ...@@ -56,9 +57,9 @@ describe Pod::Platform do
p.deployment_target = Pod::Version.new('4.0.0') p.deployment_target = Pod::Version.new('4.0.0')
p.deployment_target.should == Pod::Version.new('4.0.0') p.deployment_target.should == Pod::Version.new('4.0.0')
end end
end end
describe "Pod::Platform with a nil value" do describe "with a nil value" do
before do before do
@platform = Pod::Platform.new(nil) @platform = Pod::Platform.new(nil)
end end
...@@ -66,36 +67,43 @@ describe "Pod::Platform with a nil value" do ...@@ -66,36 +67,43 @@ describe "Pod::Platform with a nil value" do
it "behaves like a nil object" do it "behaves like a nil object" do
@platform.should.be.nil @platform.should.be.nil
end end
end end
describe "Pod::Platform#support?" do describe "regarding supporting platforms" do
it "supports another platform is with the same operating system" do it "supports platforms 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
it "doesn't supports a platform with a different operating system" do
p1 = Pod::Platform.new(:ios)
p2 = Pod::Platform.new(:osx)
p1.should.not.supports?(p2)
end
end end
end end
...@@ -2,34 +2,28 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -2,34 +2,28 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Resolver" do describe "Pod::Resolver" do
before do before do
@config_before = config
Pod::Config.instance = nil
config.silent = true
config.repos_dir = fixture('spec-repos') config.repos_dir = fixture('spec-repos')
@podfile = Pod::Podfile.new do @podfile = Pod::Podfile.new do
platform :ios platform :ios
dependency 'ASIWebPageRequest' dependency 'BlocksKit'
# dependency 'ASIWebPageRequest'
end end
@resolver = Pod::Resolver.new(@podfile, stub('sandbox')) @resolver = Pod::Resolver.new(@podfile, stub('sandbox'))
end end
after do
Pod::Config.instance = @config_before
end
it "holds the context state, such as cached specification sets" do it "holds the context state, such as cached specification sets" do
@resolver.resolve @resolver.resolve
@resolver.cached_sets.values.sort_by(&:name).should == [ @resolver.cached_sets.values.sort_by(&:name).should == [
Pod::Spec::Set.new(config.repos_dir + 'master/ASIHTTPRequest'), Pod::Spec::Set.new(config.repos_dir + 'master/A2DynamicDelegate'),
Pod::Spec::Set.new(config.repos_dir + 'master/ASIWebPageRequest'), Pod::Spec::Set.new(config.repos_dir + 'master/BlocksKit'),
Pod::Spec::Set.new(config.repos_dir + 'master/Reachability'),
].sort_by(&:name) ].sort_by(&:name)
end end
it "returns all specs needed for the dependency" do it "returns all specs needed for the dependency" do
specs = @resolver.resolve.values.flatten specs = @resolver.resolve.values.flatten
specs.map(&:class).uniq.should == [Pod::Specification] specs.map(&:class).uniq.should == [Pod::Specification]
specs.map(&:name).sort.should == %w{ ASIHTTPRequest ASIWebPageRequest Reachability } specs.map(&:name).sort.should == %w{ A2DynamicDelegate BlocksKit }
end end
it "does not raise if all dependencies match the platform of the root spec (Podfile)" do it "does not raise if all dependencies match the platform of the root spec (Podfile)" do
...@@ -40,8 +34,8 @@ describe "Pod::Resolver" do ...@@ -40,8 +34,8 @@ describe "Pod::Resolver" do
end end
it "raises once any of the dependencies does not match the platform of its podfile target" do it "raises once any of the dependencies does not match the platform of its podfile target" do
set = Pod::Spec::Set.new(config.repos_dir + 'master/ASIHTTPRequest') set = Pod::Spec::Set.new(config.repos_dir + 'master/BlocksKit')
@resolver.cached_sets['ASIHTTPRequest'] = set @resolver.cached_sets['BlocksKit'] = set
def set.stub_platform=(platform); @stubbed_platform = platform; end def set.stub_platform=(platform); @stubbed_platform = platform; end
def set.specification; spec = super; spec.platform = @stubbed_platform; spec; end def set.specification; spec = super; spec.platform = @stubbed_platform; spec; end
...@@ -60,14 +54,14 @@ describe "Pod::Resolver" do ...@@ -60,14 +54,14 @@ describe "Pod::Resolver" do
end end
it "raises once any of the dependencies does not have a deployment_target compatible with its podfile target" do it "raises once any of the dependencies does not have a deployment_target compatible with its podfile target" do
set = Pod::Spec::Set.new(config.repos_dir + 'master/ASIHTTPRequest') set = Pod::Spec::Set.new(config.repos_dir + 'master/BlocksKit')
@resolver.cached_sets['ASIHTTPRequest'] = set @resolver.cached_sets['BlocksKit'] = set
@podfile.platform :ios, "4.0" @podfile.platform :ios, "4.0"
Pod::Specification.any_instance.stubs(:platforms).returns([ Pod::Platform.new(:ios, '4.0'), Pod::Platform.new(:osx, '10.7') ]) Pod::Specification.any_instance.stubs(:available_platforms).returns([ Pod::Platform.new(:ios, '4.0'), Pod::Platform.new(:osx, '10.7') ])
lambda { @resolver.resolve }.should.not.raise lambda { @resolver.resolve }.should.not.raise
Pod::Specification.any_instance.stubs(:platforms).returns([ Pod::Platform.new(:ios, '5.0'), Pod::Platform.new(:osx, '10.7') ]) Pod::Specification.any_instance.stubs(:available_platforms).returns([ Pod::Platform.new(:ios, '5.0'), Pod::Platform.new(:osx, '10.7') ])
lambda { @resolver.resolve }.should.raise Pod::Informative lambda { @resolver.resolve }.should.raise Pod::Informative
end end
...@@ -75,7 +69,7 @@ describe "Pod::Resolver" do ...@@ -75,7 +69,7 @@ describe "Pod::Resolver" do
@podfile = Pod::Podfile.new do @podfile = Pod::Podfile.new do
platform :ios platform :ios
dependency 'RestKit/Network' dependency 'RestKit/Network'
dependency 'RestKit/ObjectMapping' dependency 'RestKit/ObjectMapping/XML'
end end
resolver = Pod::Resolver.new(@podfile, stub('sandbox')) resolver = Pod::Resolver.new(@podfile, stub('sandbox'))
resolver.resolve.values.flatten.map(&:name).sort.should == %w{ resolver.resolve.values.flatten.map(&:name).sort.should == %w{
...@@ -83,14 +77,79 @@ describe "Pod::Resolver" do ...@@ -83,14 +77,79 @@ describe "Pod::Resolver" do
ISO8601DateFormatter ISO8601DateFormatter
LibComponentLogging-Core LibComponentLogging-Core
LibComponentLogging-NSLog LibComponentLogging-NSLog
NSData+Base64
RestKit/Network
RestKit/ObjectMapping/XML
SOCKit
XMLReader
cocoa-oauth
}
end
it "includes all the subspecs of a specification node" do
@podfile = Pod::Podfile.new do
platform :ios
dependency 'RestKit'
end
resolver = Pod::Resolver.new(@podfile, stub('sandbox'))
resolver.resolve.values.flatten.map(&:name).sort.should == %w{
FileMD5Hash
ISO8601DateFormatter
JSONKit
LibComponentLogging-Core
LibComponentLogging-NSLog
NSData+Base64
RestKit RestKit
RestKit/JSON
RestKit/Network RestKit/Network
RestKit/ObjectMapping RestKit/ObjectMapping/CoreData
RestKit/ObjectMapping/JSON
RestKit/UI
SOCKit SOCKit
UDTableView
cocoa-oauth cocoa-oauth
} }
end end
it "if defined it includes only the main subspec of of a specification node" do
@podfile = Pod::Podfile.new do
platform :ios
dependency do |s|
s.name = 'RestKit'
s.version = '0.10.0'
s.preferred_dependency = 'JSON'
s.subspec 'JSON' do |js|
js.dependency 'RestKit/Network'
js.dependency 'RestKit/UI'
js.dependency 'RestKit/ObjectMapping/JSON'
js.dependency 'RestKit/ObjectMapping/CoreData'
end
s.subspec 'Network' do |ns|
ns.dependency 'LibComponentLogging-NSLog', '>= 1.0.4'
end
s.subspec 'UI'
s.subspec 'ObjectMapping' do |os|
os.subspec 'JSON'
os.subspec 'XML'
os.subspec 'CoreData'
end
end
end
resolver = Pod::Resolver.new(@podfile, stub('sandbox'))
resolver.resolve.values.flatten.map(&:name).sort.should == %w{
LibComponentLogging-Core
LibComponentLogging-NSLog
RestKit
RestKit/JSON
RestKit/Network
RestKit/ObjectMapping/CoreData
RestKit/ObjectMapping/JSON
RestKit/UI
}
it "resolves subspecs with external constraints" do it "resolves subspecs with external constraints" do
@podfile = Pod::Podfile.new do @podfile = Pod::Podfile.new do
platform :ios platform :ios
...@@ -108,17 +167,13 @@ describe "Pod::Resolver" do ...@@ -108,17 +167,13 @@ describe "Pod::Resolver" do
s.subspec 'FirstSubSpec' do |fss| s.subspec 'FirstSubSpec' do |fss|
fss.source_files = 'some/file' fss.source_files = 'some/file'
fss.subspec 'SecondSubSpec'
fss.subspec 'SecondSubSpec' do |sss|
end
end end
end end
@podfile.dependencies.first.external_source.stubs(:specification_from_sandbox).returns(spec) @podfile.dependencies.first.external_source.stubs(:specification_from_sandbox).returns(spec)
resolver = Pod::Resolver.new(@podfile, stub('sandbox')) resolver = Pod::Resolver.new(@podfile, stub('sandbox'))
resolver.resolve.values.flatten.map(&:name).sort.should == %w{ resolver.resolve.values.flatten.map(&:name).sort.should == %w{ MainSpec/FirstSubSpec MainSpec/FirstSubSpec/SecondSubSpec }
MainSpec end
MainSpec/FirstSubSpec
}
end end
end end
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
require 'tmpdir' require 'tmpdir'
TMP_POD_ROOT = ROOT + "tmp" + "podroot" TMP_POD_ROOT = ROOT + "tmp" + "podroot" unless defined? TMP_POD_ROOT
describe Pod::Sandbox do describe Pod::Sandbox do
......
require File.expand_path('../../spec_helper', __FILE__) require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Source" do describe "Pod::Source" do
extend SpecHelper::Git
extend SpecHelper::Command extend SpecHelper::Command
extend SpecHelper::TemporaryDirectory extend SpecHelper::TemporaryDirectory
extend SpecHelper::TemporaryRepos
before do before do
add_repo('repo1', fixture('spec-repos/master')) add_repo('repo1', fixture('spec-repos/master'))
......
...@@ -29,12 +29,6 @@ describe "Pod::Specification::Set" do ...@@ -29,12 +29,6 @@ describe "Pod::Specification::Set" do
lambda { @set.required_version }.should.raise Pod::Informative lambda { @set.required_version }.should.raise Pod::Informative
end end
it "returns that this set is only part for other pods" do
@set.required_by(Pod::Spec.new { |s| s.part_of = 'CocoaLumberjack' })
@set.required_by(Pod::Spec.new { |s| s.part_of = 'CocoaLumberjack' })
@set.should.be.only_part_of_other_pod
end
before do before do
@set.required_by(Pod::Spec.new { |s| s.dependency 'CocoaLumberjack', '< 1.2.1' }) @set.required_by(Pod::Spec.new { |s| s.dependency 'CocoaLumberjack', '< 1.2.1' })
end end
...@@ -51,11 +45,6 @@ describe "Pod::Specification::Set" do ...@@ -51,11 +45,6 @@ describe "Pod::Specification::Set" do
@set.specification.should == Pod::Spec.new { |s| s.name = 'CocoaLumberjack'; s.version = '1.2' } @set.specification.should == Pod::Spec.new { |s| s.name = 'CocoaLumberjack'; s.version = '1.2' }
end end
it "returns that this set is not only part for other pods" do
@set.required_by(Pod::Spec.new { |s| s.part_of = 'CocoaLumberjack' })
@set.should.not.be.only_part_of_other_pod
end
it "ignores dotfiles when getting the version directories" do it "ignores dotfiles when getting the version directories" do
`touch #{fixture('spec-repos/master/CocoaLumberjack/.DS_Store')}` `touch #{fixture('spec-repos/master/CocoaLumberjack/.DS_Store')}`
lambda { @set.versions }.should.not.raise lambda { @set.versions }.should.not.raise
......
This diff is collapsed.
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