Commit d1cf0b99 authored by Marin Usalj's avatar Marin Usalj

still refactoring. still lots of broken places

parent 7d7a92b6
...@@ -81,7 +81,7 @@ PROFILE_ERB_TEMPLATE = <<-EOS ...@@ -81,7 +81,7 @@ PROFILE_ERB_TEMPLATE = <<-EOS
#"^<%= ruby_prefix %>" #"^<%= ruby_prefix %>"
#"^<%= pod_prefix %>" #"^<%= pod_prefix %>"
#"^<%= xcode_app_path %>" #"^<%= xcode_app_path %>"
#"^<%= Pod::Config.instance.repos_dir %>" #"^<%= Pod::Config::ConfigEnvironment.repos_dir %>"
<% prefixes.each do |prefix| %> <% prefixes.each do |prefix| %>
#"^<%= prefix %>/*" #"^<%= prefix %>/*"
<% end %> <% end %>
...@@ -94,8 +94,8 @@ PROFILE_ERB_TEMPLATE = <<-EOS ...@@ -94,8 +94,8 @@ PROFILE_ERB_TEMPLATE = <<-EOS
"/dev/null" "/dev/null"
) )
(regex (regex
#"^<%= Pod::Config.instance.project_root %>" #"^<%= Pod::Config::ConfigEnvironment.instance.project_root %>"
#"^<%= Pod::Config.instance.repos_dir %>" #"^<%= Pod::Config::ConfigEnvironment.instance.repos_dir %>"
#"^/Users/[^.]+/Library/Caches/CocoaPods/*" #"^/Users/[^.]+/Library/Caches/CocoaPods/*"
#"^/dev/tty" #"^/dev/tty"
#"^/private/var" #"^/private/var"
......
...@@ -23,6 +23,8 @@ module Pod ...@@ -23,6 +23,8 @@ module Pod
require 'cocoapods/command/spec' require 'cocoapods/command/spec'
require 'cocoapods/command/init' require 'cocoapods/command/init'
include Pod::Config::Manager
self.abstract_command = true self.abstract_command = true
self.default_subcommand = 'install' self.default_subcommand = 'install'
self.command = 'pod' self.command = 'pod'
...@@ -56,7 +58,7 @@ module Pod ...@@ -56,7 +58,7 @@ module Pod
def self.report_error(exception) def self.report_error(exception)
if exception.is_a?(Interrupt) if exception.is_a?(Interrupt)
puts "[!] Cancelled".red puts "[!] Cancelled".red
Pod::Config.instance.verbose? ? raise : exit(1) config.verbose? ? raise : exit(1)
else else
if ENV['COCOA_PODS_ENV'] != 'development' if ENV['COCOA_PODS_ENV'] != 'development'
puts UI::ErrorReport.report(exception) puts UI::ErrorReport.report(exception)
...@@ -88,7 +90,6 @@ module Pod ...@@ -88,7 +90,6 @@ module Pod
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
include Pod::Config::Mixin
private private
......
module Pod module Pod
# Stores the global configuration of CocoaPods. # Contains the configuration manager and environment modules.
# Also provides dependency injection for downloader and
# statistics provider
# #
class Config # This module is not intented to be included - you probably
# want to include Config::Manager and/or Config::Enironment
autoload :ConfigManager, 'cocoapods/config/config_manager'
public
#-------------------------------------------------------------------------#
# @!group Initialization
# Sets the values of the attributes with the given hash.
#
# @param [Hash{String,Symbol => Object}] values_by_key
# The values of the attributes grouped by key.
#
# @return [void]
#
def initialize(settings = {})
settings.each do |key, value|
self.instance_variable_set("@#{key}", value)
end
end
def verbose
@verbose && !silent
end
public
#-------------------------------------------------------------------------#
# @!group Paths
# @return [Pathname] the directory where the CocoaPods sources are stored.
#
def repos_dir
@repos_dir ||= Pathname.new(ENV['CP_REPOS_DIR'] || "~/.cocoapods/repos").expand_path
end
attr_writer :repos_dir
# @return [Pathname] the directory where the CocoaPods templates are stored.
#
def templates_dir
@templates_dir ||= Pathname.new(ENV['CP_TEMPLATES_DIR'] || "~/.cocoapods/templates").expand_path
end
# @return [Pathname] the root of the CocoaPods installation where the
# Podfile is located.
#
def installation_root
current_path = Pathname.pwd
unless @installation_root
while(!current_path.root?)
if podfile_path_in_dir(current_path)
@installation_root = current_path
unless current_path == Pathname.pwd
UI.puts("[in #{current_path}]")
end
break
else
current_path = current_path.parent
end
end
@installation_root ||= Pathname.pwd
end
@installation_root
end
attr_writer :installation_root
alias :project_root :installation_root
# @return [Pathname] The root of the sandbox.
# #
def sandbox_root module Config
@sandbox_root ||= installation_root + 'Pods'
end
attr_writer :sandbox_root autoload :ConfigManager, 'cocoapods/config/config_manager'
alias :project_pods_root :sandbox_root autoload :ConfigEnvironment, 'cocoapods/config/environment'
# @return [Sandbox] The sandbox of the current project.
#
def sandbox
@sandbox ||= Sandbox.new(sandbox_root)
end
# @return [Podfile] The Podfile to use for the current execution.
# @return [Nil] If no Podfile is available.
#
def podfile
@podfile ||= Podfile.from_file(podfile_path) if podfile_path
end
attr_writer :podfile
# @return [Lockfile] The Lockfile to use for the current execution.
# @return [Nil] If no Lockfile is available.
#
def lockfile
@lockfile ||= Lockfile.from_file(lockfile_path) if lockfile_path
end
# Returns the path of the Podfile.
#
# @note The Podfile can be named either `CocoaPods.podfile.yaml`,
# `CocoaPods.podfile` or `Podfile`. The first two are preferred as
# they allow to specify an OS X UTI.
#
# @return [Pathname]
# @return [Nil]
#
def podfile_path
@podfile_path ||= podfile_path_in_dir(installation_root)
end
# Returns the path of the Lockfile.
#
# @note The Lockfile is named `Podfile.lock`.
#
def lockfile_path
@lockfile_path ||= installation_root + 'Podfile.lock'
end
# Returns the path of the default Podfile pods. # Provides support for accessing the configuration manager
# # instance in other scopes.
# @note The file is expected to be named Podfile.default
#
# @return [Pathname]
# #
def default_podfile_path module Manager
@default_podfile_path ||= templates_dir + "Podfile.default" def config
ConfigManager.instance
end end
# Returns the path of the default Podfile test pods.
#
# @note The file is expected to be named Podfile.test
#
# @return [Pathname]
#
def default_test_podfile_path
@default_test_podfile_path ||= templates_dir + "Podfile.test"
end end
# @return [Pathname] The file to use a cache of the statistics provider. # Provides support for accessing the environment instance in other
# scopes.
# #
def statistics_cache_file module Environment
cache_root + 'statistics.yml' def environment
ConfigEnvironment.instance
end end
# @return [Pathname] The file to use to cache the search data.
#
def search_index_file
cache_root + 'search_index.yaml'
end end
public public
extend Environment
extend Manager
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
# @!group Dependency Injection # @!group Dependency Injection
...@@ -167,100 +42,21 @@ module Pod ...@@ -167,100 +42,21 @@ module Pod
# @return [Downloader] The downloader to use for the retrieving remote # @return [Downloader] The downloader to use for the retrieving remote
# source. # source.
# #
def downloader(target_path, options) def self.downloader(target_path, options)
downloader = Downloader.for_target(target_path, options) downloader = Downloader.for_target(target_path, options)
downloader.cache_root = cache_root downloader.cache_root = environment.cache_root
downloader.max_cache_size = max_cache_size downloader.max_cache_size = config.max_cache_size
downloader.aggressive_cache = aggressive_cache? downloader.aggressive_cache = config.aggressive_cache?
downloader downloader
end end
# @return [Specification::Set::Statistics] The statistic provider to use # @return [Specification::Set::Statistics] The statistic provider to use
# for specifications. # for specifications.
# #
def spec_statistics_provider def self.spec_statistics_provider
Specification::Set::Statistics.new(statistics_cache_file) Specification::Set::Statistics.new(environment.statistics_cache_file)
end
private
#-------------------------------------------------------------------------#
# @!group Private helpers
# @return [Array<String>] The filenames that the Podfile can have ordered
# by priority.
#
PODFILE_NAMES = [
'CocoaPods.podfile.yaml',
'CocoaPods.podfile',
'Podfile',
]
# Returns the path of the Podfile in the given dir if any exists.
#
# @param [Pathname] dir
# The directory where to look for the Podfile.
#
# @return [Pathname] The path of the Podfile.
# @return [Nil] If not Podfile was found in the given dir
#
def podfile_path_in_dir(dir)
PODFILE_NAMES.each do |filename|
candidate = dir + filename
if candidate.exist?
return candidate
end
end
nil
end
public
#-------------------------------------------------------------------------#
# @!group Local repos
#
#
public
#-------------------------------------------------------------------------#
# @!group Singleton
# @return [Config] the current config instance creating one if needed.
#
def self.instance
@instance ||= new
end end
# Sets the current config instance. If set to nil the config will be
# recreated when needed.
#
# @param [Config, Nil] the instance.
#
# @return [void]
#
def self.instance=(instance)
@instance = instance
end end
# Provides support for accessing the configuration instance in other
# scopes.
#
module Mixin
def config
Config.instance
end
end
end
end end
class Hash
def delete_blank
delete_if { |k, v| v.empty? or v.instance_of?(Hash) && v.delete_blank.empty? }
end
end
module Pod module Pod
class Config module Config
require 'yaml' require 'yaml'
...@@ -9,6 +9,7 @@ module Pod ...@@ -9,6 +9,7 @@ module Pod
# #
class ConfigManager class ConfigManager
# The default settings for the configuration. # The default settings for the configuration.
# #
# Users can specify custom settings in `~/.cocoapods/config.yaml`. # Users can specify custom settings in `~/.cocoapods/config.yaml`.
...@@ -19,17 +20,16 @@ module Pod ...@@ -19,17 +20,16 @@ module Pod
# new_version_message: false # new_version_message: false
# #
DEFAULTS = { DEFAULTS = {
:verbose => false, 'verbose' => false,
:silent => false, 'silent' => false,
:skip_repo_update => false, 'skip_repo_update' => false,
:clean => true, 'clean' => true,
:integrate_targets => true, 'integrate_targets' => true,
:new_version_message => true, 'new_version_message' => true,
:cache_root => Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods')), 'max_cache_size' => 500,
:max_cache_size => 500, 'aggressive_cache' => false,
:aggressive_cache => false,
} }
DEFAULTS.each do |key, value| DEFAULTS.each do |key, value|
...@@ -50,9 +50,8 @@ module Pod ...@@ -50,9 +50,8 @@ module Pod
@instance ||= new @instance ||= new
end end
def get_setting(keypath) def get_setting(keypath)
value = global_config[keypath] || get_environment(keypath) || DEFAULTS[keypath.to_sym] value = global_config[keypath] || value_from_env(keypath) || DEFAULTS[keypath]
if value.nil? if value.nil?
raise NoKeyError, "Unrecognized keypath for configuration `#{keypath}`. " \ raise NoKeyError, "Unrecognized keypath for configuration `#{keypath}`. " \
"\nSupported ones are:\n - #{DEFAULTS.keys.join("\n - ")}" "\nSupported ones are:\n - #{DEFAULTS.keys.join("\n - ")}"
...@@ -65,7 +64,6 @@ module Pod ...@@ -65,7 +64,6 @@ module Pod
if value == 'true' if value == 'true'
value = true value = true
end end
hash[keypath] = value hash[keypath] = value
store_configuration(hash) store_configuration(hash)
end end
...@@ -74,6 +72,14 @@ module Pod ...@@ -74,6 +72,14 @@ module Pod
end end
# @group Helpers
#
#
def verbose?
get_setting('verbose') && !silent?
end
private private
def global_config def global_config
...@@ -91,8 +97,8 @@ module Pod ...@@ -91,8 +97,8 @@ module Pod
end end
def store_configuration(hash) def store_configuration(hash)
@global_config = hash
yaml = YAML.dump(hash) yaml = YAML.dump(hash)
global_config_filepath
File.open(global_config_filepath, 'w') { |f| f.write(yaml) } File.open(global_config_filepath, 'w') { |f| f.write(yaml) }
end end
...@@ -100,23 +106,14 @@ module Pod ...@@ -100,23 +106,14 @@ module Pod
# @return [Pathname] The path of the file which contains the user settings. # @return [Pathname] The path of the file which contains the user settings.
# #
def global_config_filepath def global_config_filepath
home_dir + "config.yaml" Config::ConfigEnvironment.instance.home_dir + "config.yaml"
end end
def local_config_filepath def local_config_filepath
end end
# @return [Pathname] the directory where repos, templates and configuration def value_from_env(keypath)
# files are stored.
#
def home_dir
# TODO: test ENV
# @home_dir ||= Pathname.new(ENV['CP_HOME_DIR'] || "~/.cocoapods").expand_path
@home_dir ||= Pathname.new("~/.cocoapods").expand_path
end
def get_environment(keypath)
value = ENV["CP_#{keypath.upcase}"] value = ENV["CP_#{keypath.upcase}"]
if value == 'TRUE' if value == 'TRUE'
true true
...@@ -130,3 +127,4 @@ module Pod ...@@ -130,3 +127,4 @@ module Pod
end end
end end
module Pod
module Config
require 'yaml'
# The config manager is responsible for reading and writing the config.yaml
# file.
#
class ConfigEnvironment
# @!group Singleton
# @return [Config] the current config instance creating one if needed.
#
def self.instance
@instance ||= new
end
public
#-------------------------------------------------------------------------#
# @!group Paths
# @return [Pathname] the directory where repos, templates and configuration
# files are stored.
#
def home_dir
@home_dir ||= Pathname.new(ENV['CP_HOME_DIR'] || "~/.cocoapods").expand_path
end
# @return [Pathname] the directory where the CocoaPods sources are stored.
#
def repos_dir
@repos_dir ||= Pathname.new(ENV['CP_REPOS_DIR'] || "~/.cocoapods/repos").expand_path
end
attr_writer :repos_dir
# @return [Pathname] the directory where the CocoaPods templates are stored.
#
def templates_dir
@templates_dir ||= Pathname.new(ENV['CP_TEMPLATES_DIR'] || "~/.cocoapods/templates").expand_path
end
# @return [Pathname] the directory where Cocoapods
def cache_root
@cache_root ||= Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods'))
end
# @return [Pathname] the root of the CocoaPods installation where the
# Podfile is located.
#
def installation_root
current_path = Pathname.pwd
unless @installation_root
while(!current_path.root?)
if podfile_path_in_dir(current_path)
@installation_root = current_path
unless current_path == Pathname.pwd
UI.puts("[in #{current_path}]")
end
break
else
current_path = current_path.parent
end
end
@installation_root ||= Pathname.pwd
end
@installation_root
end
attr_writer :installation_root
alias :project_root :installation_root
# @return [Pathname] The root of the sandbox.
#
def sandbox_root
@sandbox_root ||= installation_root + 'Pods'
end
attr_writer :sandbox_root
alias :project_pods_root :sandbox_root
# @return [Sandbox] The sandbox of the current project.
#
def sandbox
@sandbox ||= Sandbox.new(sandbox_root)
end
# @return [Podfile] The Podfile to use for the current execution.
# @return [Nil] If no Podfile is available.
#
def podfile
@podfile ||= Podfile.from_file(podfile_path) if podfile_path
end
attr_writer :podfile
# @return [Lockfile] The Lockfile to use for the current execution.
# @return [Nil] If no Lockfile is available.
#
def lockfile
@lockfile ||= Lockfile.from_file(lockfile_path) if lockfile_path
end
# Returns the path of the Podfile.
#
# @note The Podfile can be named either `CocoaPods.podfile.yaml`,
# `CocoaPods.podfile` or `Podfile`. The first two are preferred as
# they allow to specify an OS X UTI.
#
# @return [Pathname]
# @return [Nil]
#
def podfile_path
@podfile_path ||= podfile_path_in_dir(installation_root)
end
# Returns the path of the Lockfile.
#
# @note The Lockfile is named `Podfile.lock`.
#
def lockfile_path
@lockfile_path ||= installation_root + 'Podfile.lock'
end
# Returns the path of the default Podfile pods.
#
# @note The file is expected to be named Podfile.default
#
# @return [Pathname]
#
def default_podfile_path
@default_podfile_path ||= templates_dir + "Podfile.default"
end
# Returns the path of the default Podfile test pods.
#
# @note The file is expected to be named Podfile.test
#
# @return [Pathname]
#
def default_test_podfile_path
@default_test_podfile_path ||= templates_dir + "Podfile.test"
end
# @return [Pathname] The file to use a cache of the statistics provider.
#
def statistics_cache_file
cache_root + 'statistics.yml'
end
# @return [Pathname] The file to use to cache the search data.
#
def search_index_file
cache_root + 'search_index.yaml'
end
private
#-------------------------------------------------------------------------#
# @!group Private helpers
# @return [Array<String>] The filenames that the Podfile can have ordered
# by priority.
#
PODFILE_NAMES = [
'CocoaPods.podfile.yaml',
'CocoaPods.podfile',
'Podfile',
]
# Returns the path of the Podfile in the given dir if any exists.
#
# @param [Pathname] dir
# The directory where to look for the Podfile.
#
# @return [Pathname] The path of the Podfile.
# @return [Nil] If not Podfile was found in the given dir
#
def podfile_path_in_dir(dir)
PODFILE_NAMES.each do |filename|
candidate = dir + filename
if candidate.exist?
return candidate
end
end
nil
end
end
end
end
...@@ -13,6 +13,8 @@ module Pod ...@@ -13,6 +13,8 @@ module Pod
# #
module Executable module Executable
extend Pod::Config::Manager
# Creates the methods for the executable with the given name. # Creates the methods for the executable with the given name.
# #
# @param [Symbol] name # @param [Symbol] name
...@@ -59,7 +61,7 @@ module Pod ...@@ -59,7 +61,7 @@ module Pod
full_command = "#{bin} #{command}" full_command = "#{bin} #{command}"
if Config.instance.verbose? if config.verbose?
UI.message("$ #{full_command}") UI.message("$ #{full_command}")
stdout, stderr = Indenter.new(STDOUT), Indenter.new(STDERR) stdout, stderr = Indenter.new(STDOUT), Indenter.new(STDERR)
else else
......
...@@ -136,7 +136,7 @@ module Pod ...@@ -136,7 +136,7 @@ module Pod
UI.titled_section("Pre-downloading: `#{name}` #{description}", { :verbose_prefix => "-> " }) do UI.titled_section("Pre-downloading: `#{name}` #{description}", { :verbose_prefix => "-> " }) do
target = sandbox.root + name target = sandbox.root + name
target.rmtree if target.exist? target.rmtree if target.exist?
downloader = Config.instance.downloader(target, params) downloader = Config::downloader(target, params)
downloader.download downloader.download
store_podspec(sandbox, target + "#{name}.podspec") store_podspec(sandbox, target + "#{name}.podspec")
sandbox.store_pre_downloaded_pod(name) sandbox.store_pre_downloaded_pod(name)
......
...@@ -36,10 +36,9 @@ module Pod ...@@ -36,10 +36,9 @@ module Pod
autoload :PodTargetInstaller, 'cocoapods/installer/target_installer/pod_target_installer' autoload :PodTargetInstaller, 'cocoapods/installer/target_installer/pod_target_installer'
autoload :UserProjectIntegrator, 'cocoapods/installer/user_project_integrator' autoload :UserProjectIntegrator, 'cocoapods/installer/user_project_integrator'
# include Config::Mixin include Config::Manager
def config include Config::Environment
Config::ConfigManager.instance
end
# @return [Sandbox] The sandbox where the Pods should be installed. # @return [Sandbox] The sandbox where the Pods should be installed.
# #
...@@ -301,8 +300,8 @@ module Pod ...@@ -301,8 +300,8 @@ module Pod
@pods_project.add_pod_group(pod_name, path, local) @pods_project.add_pod_group(pod_name, path, local)
end end
if config.podfile_path if environment.podfile_path
@pods_project.add_podfile(config.podfile_path) @pods_project.add_podfile(environment.podfile_path)
end end
sandbox.project = @pods_project sandbox.project = @pods_project
...@@ -417,8 +416,8 @@ module Pod ...@@ -417,8 +416,8 @@ module Pod
# checkout_options = sandbox.checkout_options # checkout_options = sandbox.checkout_options
@lockfile = Lockfile.generate(podfile, analysis_result.specifications) @lockfile = Lockfile.generate(podfile, analysis_result.specifications)
UI.message "- Writing Lockfile in #{UI.path config.lockfile_path}" do UI.message "- Writing Lockfile in #{UI.path environment.lockfile_path}" do
@lockfile.write_to_disk(config.lockfile_path) @lockfile.write_to_disk(environment.lockfile_path)
end end
UI.message "- Writing Manifest in #{UI.path sandbox.manifest_path}" do UI.message "- Writing Manifest in #{UI.path sandbox.manifest_path}" do
...@@ -440,7 +439,7 @@ module Pod ...@@ -440,7 +439,7 @@ module Pod
# #
def integrate_user_project def integrate_user_project
UI.section "Integrating client #{'project'.pluralize(aggregate_targets.map(&:user_project_path).uniq.count) }" do UI.section "Integrating client #{'project'.pluralize(aggregate_targets.map(&:user_project_path).uniq.count) }" do
installation_root = config.installation_root installation_root = environment.installation_root
integrator = UserProjectIntegrator.new(podfile, sandbox, installation_root, aggregate_targets) integrator = UserProjectIntegrator.new(podfile, sandbox, installation_root, aggregate_targets)
integrator.integrate! integrator.integrate!
end end
......
...@@ -6,7 +6,8 @@ module Pod ...@@ -6,7 +6,8 @@ module Pod
# #
class Analyzer class Analyzer
include Config::Mixin include Config::Manager
include Config::Environment
autoload :SandboxAnalyzer, 'cocoapods/installer/analyzer/sandbox_analyzer' autoload :SandboxAnalyzer, 'cocoapods/installer/analyzer/sandbox_analyzer'
...@@ -179,7 +180,7 @@ module Pod ...@@ -179,7 +180,7 @@ module Pod
target.user_build_configurations = compute_user_build_configurations(target_definition, native_targets) target.user_build_configurations = compute_user_build_configurations(target_definition, native_targets)
target.archs = @archs_by_target_def[target_definition] target.archs = @archs_by_target_def[target_definition]
else else
target.client_root = config.installation_root target.client_root = environment.installation_root
target.user_target_uuids = [] target.user_target_uuids = []
target.user_build_configurations = {} target.user_build_configurations = {}
end end
...@@ -339,7 +340,7 @@ module Pod ...@@ -339,7 +340,7 @@ module Pod
# #
def compute_user_project_path(target_definition) def compute_user_project_path(target_definition)
if target_definition.user_project_path if target_definition.user_project_path
path = config.installation_root + target_definition.user_project_path path = environment.installation_root + target_definition.user_project_path
path = "#{path}.xcodeproj" unless File.extname(path) == '.xcodeproj' path = "#{path}.xcodeproj" unless File.extname(path) == '.xcodeproj'
path = Pathname.new(path) path = Pathname.new(path)
unless path.exist? unless path.exist?
...@@ -348,7 +349,7 @@ module Pod ...@@ -348,7 +349,7 @@ module Pod
end end
else else
xcodeprojs = Pathname.glob(config.installation_root + '*.xcodeproj') xcodeprojs = Pathname.glob(environment.installation_root + '*.xcodeproj')
if xcodeprojs.size == 1 if xcodeprojs.size == 1
path = xcodeprojs.first path = xcodeprojs.first
else else
...@@ -479,6 +480,7 @@ module Pod ...@@ -479,6 +480,7 @@ module Pod
project_path = compute_user_project_path(target_definition) project_path = compute_user_project_path(target_definition)
user_project = Xcodeproj::Project.open(project_path) user_project = Xcodeproj::Project.open(project_path)
targets = compute_user_project_targets(target_definition, user_project) targets = compute_user_project_targets(target_definition, user_project)
# TODO: this is unused
platform = compute_platform_for_target_definition(target_definition, targets) platform = compute_platform_for_target_definition(target_definition, targets)
archs = compute_archs_for_target_definition(target_definition, targets) archs = compute_archs_for_target_definition(target_definition, targets)
@archs_by_target_def[target_definition] = archs @archs_by_target_def[target_definition] = archs
......
...@@ -206,3 +206,4 @@ module Pod ...@@ -206,3 +206,4 @@ module Pod
end end
end end
end end
...@@ -213,3 +213,4 @@ module Pod ...@@ -213,3 +213,4 @@ module Pod
end end
end end
...@@ -6,13 +6,14 @@ module Pod ...@@ -6,13 +6,14 @@ module Pod
class << self class << self
include Config::Mixin include Config::Manager
include Config::Environment
# @return [Source::Aggregate] the aggregate of all the sources known to # @return [Source::Aggregate] the aggregate of all the sources known to
# this installation of CocoaPods. # this installation of CocoaPods.
# #
def aggregate def aggregate
Source::Aggregate.new(config.repos_dir) Source::Aggregate.new(environment.repos_dir)
end end
# @return [Array<Source>] the list of all the sources known to this # @return [Array<Source>] the list of all the sources known to this
...@@ -120,7 +121,7 @@ module Pod ...@@ -120,7 +121,7 @@ module Pod
# @return [Pathname] The path where the search index should be stored. # @return [Pathname] The path where the search index should be stored.
# #
def search_index_path def search_index_path
Config.instance.search_index_file environment.search_index_file
end end
public public
...@@ -256,7 +257,7 @@ module Pod ...@@ -256,7 +257,7 @@ module Pod
# @return [Pathname] The path of the master repo. # @return [Pathname] The path of the master repo.
# #
def master_repo_dir def master_repo_dir
config.repos_dir + 'master' environment.repos_dir + 'master'
end end
# @return [Bool] Checks if the master repo is usable. # @return [Bool] Checks if the master repo is usable.
......
...@@ -17,6 +17,9 @@ module Pod ...@@ -17,6 +17,9 @@ module Pod
class << self class << self
include Config::Manager
include Config::Environment
attr_accessor :indentation_level attr_accessor :indentation_level
attr_accessor :title_level attr_accessor :title_level
attr_accessor :warnings attr_accessor :warnings
...@@ -147,7 +150,7 @@ module Pod ...@@ -147,7 +150,7 @@ module Pod
# #
def path(pathname) def path(pathname)
if pathname if pathname
path = pathname.relative_path_from((config.podfile_path.dirname if config.podfile_path) || Pathname.pwd) path = pathname.relative_path_from((environment.podfile_path.dirname if environment.podfile_path) || Pathname.pwd)
"`#{path}`" "`#{path}`"
else else
'' ''
...@@ -279,15 +282,10 @@ module Pod ...@@ -279,15 +282,10 @@ module Pod
end end
end end
def config # @return [bool] whatever ConfigurationManager returns
Config::ConfigManager.instance #
end
def verbose? def verbose?
Config::ConfigManager.instance.verbose? && !silent? config.verbose?
end
def silent?
Config::ConfigManager.instance.silent?
end end
end end
......
...@@ -2,16 +2,17 @@ module Pod ...@@ -2,16 +2,17 @@ module Pod
# Validates a Specification. # Validates a Specification.
# #
# Extends the Linter from the Core to add additional which require the # Extends Linter from Core to add some additional functionality which requires
# LocalPod and the Installer. # LocalPod and Installer.
# #
# In detail it checks that the file patterns defined by the user match # In detail it checks that file patterns defined by the user
# actually do match at least a file and that the Pod builds, by installing # actually match at least a file and that the Pod builds, by installing
# it without integration and building the project with xcodebuild. # it without integration and building the project with xcodebuild.
# #
class Validator class Validator
include Config::Mixin include Config::Manager
include Config::Environment
# @return [Specification::Linter] the linter instance from CocoaPods # @return [Specification::Linter] the linter instance from CocoaPods
# Core. # Core.
...@@ -183,13 +184,20 @@ module Pod ...@@ -183,13 +184,20 @@ module Pod
attr_accessor :consumer attr_accessor :consumer
# Currently, this method swizzles the singleton implementation,
# and changes some values.
# Maybe we'd want to make another config for this purposes
#
def setup_validation_environment def setup_validation_environment
validation_dir.rmtree if validation_dir.exist? validation_dir.rmtree if validation_dir.exist?
validation_dir.mkpath validation_dir.mkpath
@original_config = Config.instance.clone @original_config = config.clone
config.installation_root = validation_dir @original_environment = environment.clone
config.sandbox_root = validation_dir + 'Pods'
config.silent = !config.verbose environment.installation_root = validation_dir
environment.sandbox_root = validation_dir + 'Pods'
config.silent = !config.verbose?
config.integrate_targets = false config.integrate_targets = false
config.skip_repo_update = true config.skip_repo_update = true
end end
...@@ -204,7 +212,7 @@ module Pod ...@@ -204,7 +212,7 @@ module Pod
# #
def install_pod def install_pod
podfile = podfile_from_spec(consumer.platform_name, spec.deployment_target(consumer.platform_name)) podfile = podfile_from_spec(consumer.platform_name, spec.deployment_target(consumer.platform_name))
sandbox = Sandbox.new(config.sandbox_root) sandbox = Sandbox.new(environment.sandbox_root)
installer = Installer.new(sandbox, podfile) installer = Installer.new(sandbox, podfile)
installer.install! installer.install!
...@@ -213,7 +221,7 @@ module Pod ...@@ -213,7 +221,7 @@ module Pod
end.flatten end.flatten
@file_accessor = file_accessors.find { |accessor| accessor.spec.root.name == spec.root.name } @file_accessor = file_accessors.find { |accessor| accessor.spec.root.name == spec.root.name }
config.silent #config.silent
end end
# Performs platform specific analysis. It requires to download the source # Performs platform specific analysis. It requires to download the source
...@@ -229,7 +237,7 @@ module Pod ...@@ -229,7 +237,7 @@ module Pod
UI.warn "Skipping compilation with `xcodebuild' because it can't be found.\n".yellow UI.warn "Skipping compilation with `xcodebuild' because it can't be found.\n".yellow
else else
UI.message "\nBuilding with xcodebuild.\n".yellow do UI.message "\nBuilding with xcodebuild.\n".yellow do
output = Dir.chdir(config.sandbox_root) { xcodebuild } output = Dir.chdir(environment.sandbox_root) { xcodebuild }
UI.puts output UI.puts output
parsed_output = parse_xcodebuild_output(output) parsed_output = parse_xcodebuild_output(output)
parsed_output.each do |message| parsed_output.each do |message|
......
...@@ -11,14 +11,14 @@ module Pod ...@@ -11,14 +11,14 @@ module Pod
pod_path = '~/code/OSS/ObjectiveSugar' pod_path = '~/code/OSS/ObjectiveSugar'
project_name = 'SampleProject' project_name = 'SampleProject'
before do @config_file_path = temporary_directory + 'config.yaml'
# Dir.stubs(:pwd).returns('~/code/OSS/SampleProject')
@config_file_path = temporary_directory + "mock_config.yaml" before do
Pod::Config.instance.stubs(:user_settings_file).returns(@config_file_path) FileUtils.rm_rf(@config_file_path)
@subject = Config::ConfigManager.new
# TODO: stub the file accessor
end end
it "writes local repos for each project" do it "writes local repos for each project" do
run_command('config', "--local", pod_name, pod_path) run_command('config', "--local", pod_name, pod_path)
yaml = YAML.load(File.open(@config_file_path)) yaml = YAML.load(File.open(@config_file_path))
...@@ -72,16 +72,3 @@ module Pod ...@@ -72,16 +72,3 @@ module Pod
end end
end end
# ===================
# Config file format
# ===================
#
# ---
# LOCAL_OVERRIDES:
# SampleApp:
# ARAnalytics: ~/code/ARAnalytics
#
# GLOBAL_OVERRIDES:
# ObjectiveRecord: ~/code/OSS/ObjectiveRecord
# ObjectiveSugar: ~/code/OSS/ObjectiveSugar
#
...@@ -79,7 +79,8 @@ Bacon.summary_at_exit ...@@ -79,7 +79,8 @@ Bacon.summary_at_exit
module Bacon module Bacon
class Context class Context
include Pod::Config::Mixin include Pod::Config::Manager
include Pod::Config::Environment
include SpecHelper::Fixture include SpecHelper::Fixture
include SpecHelper::Command include SpecHelper::Command
......
...@@ -5,16 +5,13 @@ module Bacon ...@@ -5,16 +5,13 @@ module Bacon
old_run_requirement = instance_method(:run_requirement) old_run_requirement = instance_method(:run_requirement)
define_method(:run_requirement) do |description, spec| define_method(:run_requirement) do |description, spec|
::Pod::Config.instance = nil
::Pod::Config.instance.tap do |c|
# c.verbose = false
# c.silent = true
# c.skip_repo_update = true
environment.stubs(:repos_dir).returns(fixture('spec-repos'))
environment.stubs(:installation_root).returns(SpecHelper.temporary_directory)
environment.stubs(:home_dir).returns(SpecHelper.temporary_directory)
c.repos_dir = fixture('spec-repos') config.stubs(:silent).returns(true)
c.installation_root = SpecHelper.temporary_directory config.stubs('skip_repo_update').returns(true)
end
::Pod::UI.output = '' ::Pod::UI.output = ''
# The following prevents a nasty behaviour where the increments are not # The following prevents a nasty behaviour where the increments are not
......
...@@ -10,38 +10,42 @@ module Pod ...@@ -10,38 +10,42 @@ module Pod
@config_file_path = temporary_directory + 'config.yaml' @config_file_path = temporary_directory + 'config.yaml'
before do before do
@subject = Config::ConfigManager.instance FileUtils.rm_rf(@config_file_path)
@subject.stubs(:home_dir).returns(temporary_directory) @subject = Config::ConfigManager.new
end
it "has a singleton" do
Config::ConfigManager.instance.should === Config::ConfigManager.instance
end end
it "creates a global config file if one didn't exist" do it "creates a global config file if one didn't exist" do
FileUtils.rm_rf(@config_file_path) FileUtils.rm_rf(@config_file_path)
@subject.set_global('verbose', 'true') @subject.set_global('verbose', true)
@config_file_path.should.exist @config_file_path.should.exist
end end
it "stores a global setting" do it "stores a global setting" do
@subject.set_global('verbose', 'true') @subject.set_global('verbose', true)
yaml = YAML.load_file(@config_file_path) yaml = YAML.load_file(@config_file_path)
yaml['verbose'].should == true yaml['verbose'].should == true
end end
it "preserves the existing settings of the configuration file" do it "preserves the existing settings of the configuration file" do
@subject.set_global('silent', 'true') @subject.set_global('silent', true)
@subject.set_global('verbose', 'true') @subject.set_global('verbose', true)
yaml = YAML.load_file(@config_file_path) yaml = YAML.load_file(@config_file_path)
yaml['silent'].should == true yaml['silent'].should == true
end end
xit "allows to store a development pod" do it "allows to store a development pod" do
@subject.set_global('development.ObjectiveSugar', '~/code/OS') @subject.set_global('development.ObjectiveSugar', '~/code/OS')
yaml = YAML.load_file(@config_file_path) yaml = YAML.load_file(@config_file_path)
yaml['development.ObjectiveSugar'].should == '~/code/OS' yaml['development.ObjectiveSugar'].should == '~/code/OS'
end end
it "returns a globally decided setting" do it "returns a globally decided setting" do
@subject.set_global('user_name', 'Super Marin') @subject.set_global('silent', true)
@subject.get_setting('user_name').should == 'Super Marin' @subject.should.be.silent
end end
it "verbose by default is false" do it "verbose by default is false" do
...@@ -52,8 +56,15 @@ module Pod ...@@ -52,8 +56,15 @@ module Pod
@subject.should.not.be.silent @subject.should.not.be.silent
end end
it "is verbose only if silent is false and verbose is true" do
@subject.set_global('silent', true)
@subject.set_global('verbose', true)
@subject.should.not.be.verbose
end
it "skips repo update by default is false" do it "skips repo update by default is false" do
@subject.should.not.skip_repo_update @subject.should.not.skip_repo_update?
end end
it "clean by default is true" do it "clean by default is true" do
...@@ -68,10 +79,6 @@ module Pod ...@@ -68,10 +79,6 @@ module Pod
@subject.should.new_version_message @subject.should.new_version_message
end end
it "cache_root returns the cache root by default" do
@subject.cache_root.to_s.should.include('Library/Caches/CocoaPods')
end
it "max_cache_size is 500 MB by default" do it "max_cache_size is 500 MB by default" do
@subject.max_cache_size.should == 500 @subject.max_cache_size.should == 500
end end
...@@ -87,17 +94,23 @@ module Pod ...@@ -87,17 +94,23 @@ module Pod
end end
it "can accept aggressive cache from ENV" do it "can accept aggressive cache from ENV" do
ENV.stubs(:[]).returns('TRUE') @subject.set_global('aggressive_cache', false)
ENV['CP_AGGRESSIVE_CACHE'] = 'TRUE'
@subject.get_setting('aggressive_cache').should == true @subject.get_setting('aggressive_cache').should == true
ENV.delete('CP_AGGRESSIVE_CACHE')
end end
describe "development repos" do
xit "has a friendly API for development repos" do
@subject.set_global('development.ObjectiveSugar', '~/code/OS')
@subject.devevelopment_pod('ObjectiveSugar').should.equal '~/code/OS'
end end
xit "writes local repos for each project" do end
@subject.set_local('verbose', 'true')
yaml['verbose'].should == true
end end
end end
end end
require File.expand_path('../../../spec_helper', __FILE__)
module Pod
describe Config::ConfigEnvironment do
before do
@sut = Config::ConfigEnvironment.new
end
describe "In general" do
it "returns the path to the home dir" do
@sut.home_dir.should == Pathname.new("~/.cocoapods").expand_path
end
it "returns the path to the spec-repos dir" do
@sut.repos_dir.should == Pathname.new("~/.cocoapods/repos").expand_path
end
it "returns the path to the templates dir" do
@sut.templates_dir.should == Pathname.new("~/.cocoapods/templates").expand_path
end
it "returns the path of the default podfiles" do
@sut.default_podfile_path.should == Pathname.new("~/.cocoapods/templates/Podfile.default").expand_path
@sut.default_test_podfile_path.should == Pathname.new("~/.cocoapods/templates/Podfile.test").expand_path
end
it "allows to specify the home dir with an environment variable" do
ENV['CP_HOME_DIR'] = '~/custom_home_dir'
@sut.home_dir.should == Pathname.new("~/custom_home_dir").expand_path
ENV.delete('CP_HOME_DIR')
end
it "allows to specify the repos dir with an environment variable" do
ENV['CP_REPOS_DIR'] = '~/custom_repos_dir'
@sut.repos_dir.should == Pathname.new("~/custom_repos_dir").expand_path
ENV.delete('CP_REPOS_DIR')
end
end
#-------------------------------------------------------------------------#
describe "Paths" do
it "returns the working directory as the installation root if a Podfile can be found" do
Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {}
@sut.installation_root.should == temporary_directory
end
end
it "returns the parent directory which contains the Podfile if it can be found" do
Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {}
sub_dir = temporary_directory + 'sub_dir'
sub_dir.mkpath
Dir.chdir(sub_dir) do
@sut.installation_root.should == temporary_directory
end
end
end
it "it returns the working directory as the installation root if no Podfile can be found" do
Dir.chdir(temporary_directory) do
@sut.installation_root.should == temporary_directory
end
end
before do
@sut.installation_root = temporary_directory
end
it "returns the path to the project root" do
@sut.installation_root.should == temporary_directory
end
it "returns the path to the project Podfile if it exists" do
(temporary_directory + 'Podfile').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'Podfile'
end
it "can detect yaml Podfiles" do
(temporary_directory + 'CocoaPods.podfile.yaml').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile.yaml'
end
it "can detect files named `CocoaPods.podfile`" do
(temporary_directory + 'CocoaPods.podfile').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile'
end
it "returns the path to the Pods directory that holds the dependencies" do
@sut.sandbox_root.should == temporary_directory + 'Pods'
end
it "returns the Podfile path" do
Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {}
@sut.podfile_path.should == temporary_directory + "Podfile"
end
end
it "returns nils if the Podfile if no paths exists" do
Dir.chdir(temporary_directory) do
@sut.podfile_path.should == nil
end
end
it "returns the Lockfile path" do
Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {}
File.open("Podfile.lock", "w") {}
@sut.lockfile_path.should == temporary_directory + "Podfile.lock"
end
end
it "cache_root returns the cache root by default" do
@sut.cache_root.to_s.should.include('Library/Caches/CocoaPods')
end
it "returns the statistics cache file" do
@sut.statistics_cache_file.to_s.should.end_with?('statistics.yml')
end
it "returns the search index file" do
@sut.search_index_file.to_s.should.end_with?('search_index.yaml')
end
end
#-------------------------------------------------------------------------#
describe "Private helpers" do
describe "#podfile_path_in_dir" do
it "detects the CocoaPods.podfile.yaml file" do
expected = temporary_directory + "CocoaPods.podfile.yaml"
File.open(expected, "w") {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it "detects the CocoaPods.podfile file" do
expected = temporary_directory + "CocoaPods.podfile"
File.open(expected, "w") {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it "detects the Podfile file" do
expected = temporary_directory + "Podfile"
File.open(expected, "w") {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it "returns nils if the Podfile is not available" do
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == nil
end
end
#-----------------------------------------------------------------------#
end
end
end
...@@ -3,211 +3,24 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -3,211 +3,24 @@ require File.expand_path('../../spec_helper', __FILE__)
module Pod module Pod
describe Config do describe Config do
before do
@sut = Config.new(false)
end
#-------------------------------------------------------------------------#
describe "In general" do
it "returns the singleton config instance" do
@sut.should.be.instance_of Config
end
it "returns the path to the home dir" do
@sut.home_dir.should == Pathname.new("~/.cocoapods").expand_path
end
it "returns the path to the spec-repos dir" do
@sut.repos_dir.should == Pathname.new("~/.cocoapods/repos").expand_path
end
it "returns the path to the templates dir" do
@sut.templates_dir.should == Pathname.new("~/.cocoapods/templates").expand_path
end
it "returns the path of the default podfiles" do
@sut.default_podfile_path.should == Pathname.new("~/.cocoapods/templates/Podfile.default").expand_path
@sut.default_test_podfile_path.should == Pathname.new("~/.cocoapods/templates/Podfile.test").expand_path
end
it "allows to specify whether the aggressive cache should be used with an environment variable" do
@sut.aggressive_cache = false
ENV['CP_AGGRESSIVE_CACHE'] = 'TRUE'
@sut.aggressive_cache?.should.be.true
ENV.delete('CP_AGGRESSIVE_CACHE')
end
it "allows to specify the home dir with an environment variable" do
ENV['CP_HOME_DIR'] = '~/custom_home_dir'
@sut.home_dir.should == Pathname.new("~/custom_home_dir").expand_path
ENV.delete('CP_HOME_DIR')
end
it "allows to specify the repos dir with an environment variable" do
ENV['CP_REPOS_DIR'] = '~/custom_repos_dir'
@sut.repos_dir.should == Pathname.new("~/custom_repos_dir").expand_path
ENV.delete('CP_REPOS_DIR')
end
end
#-------------------------------------------------------------------------#
describe "Paths" do
it "returns the working directory as the installation root if a Podfile can be found" do
Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {}
@sut.installation_root.should == temporary_directory
end
end
it "returns the parent directory which contains the Podfile if it can be found" do
Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {}
sub_dir = temporary_directory + 'sub_dir'
sub_dir.mkpath
Dir.chdir(sub_dir) do
@sut.installation_root.should == temporary_directory
end
end
end
it "it returns the working directory as the installation root if no Podfile can be found" do
Dir.chdir(temporary_directory) do
@sut.installation_root.should == temporary_directory
end
end
before do
@sut.installation_root = temporary_directory
end
it "returns the path to the project root" do
@sut.installation_root.should == temporary_directory
end
it "returns the path to the project Podfile if it exists" do
(temporary_directory + 'Podfile').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'Podfile'
end
it "can detect yaml Podfiles" do
(temporary_directory + 'CocoaPods.podfile.yaml').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile.yaml'
end
it "can detect files named `CocoaPods.podfile`" do
(temporary_directory + 'CocoaPods.podfile').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile'
end
it "returns the path to the Pods directory that holds the dependencies" do
@sut.sandbox_root.should == temporary_directory + 'Pods'
end
it "returns the Podfile path" do
Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {}
@sut.podfile_path.should == temporary_directory + "Podfile"
end
end
it "returns nils if the Podfile if no paths exists" do
Dir.chdir(temporary_directory) do
@sut.podfile_path.should == nil
end
end
it "returns the Lockfile path" do
Dir.chdir(temporary_directory) do
File.open("Podfile", "w") {}
File.open("Podfile.lock", "w") {}
@sut.lockfile_path.should == temporary_directory + "Podfile.lock"
end
end
it "returns the statistics cache file" do
@sut.statistics_cache_file.to_s.should.end_with?('statistics.yml')
end
it "returns the search index file" do
@sut.search_index_file.to_s.should.end_with?('search_index.yaml')
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
describe "Dependency Injection" do describe "Dependency Injection" do
it "returns the downloader" do it "returns the downloader" do
downloader = @sut.downloader(Pathname.new(''), { :git => 'example.com' }) downloader = Config.downloader(Pathname.new(''), { :git => 'example.com' })
downloader.target_path.should == Pathname.new('') downloader.target_path.should == Pathname.new('')
downloader.url.should == 'example.com' downloader.url.should == 'example.com'
downloader.cache_root.should == @sut.cache_root downloader.cache_root.should == environment.cache_root
downloader.max_cache_size.should == 500 downloader.max_cache_size.should == 500
downloader.aggressive_cache.should.be.false downloader.aggressive_cache.should.be.false
end end
it "returns the specification statistics provider" do it "returns the specification statistics provider" do
stats_provider = @sut.spec_statistics_provider stats_provider = Config.spec_statistics_provider
stats_provider.cache_file.should == @sut.cache_root + 'statistics.yml' stats_provider.cache_file.should == environment.cache_root + 'statistics.yml'
end end
end end
#-------------------------------------------------------------------------#
describe "Private helpers" do
it "returns the path of the user settings file" do
@sut.send(:user_settings_file).should == Pathname.new("~/.cocoapods/config.yaml").expand_path
end
it "can be initialized with a hash" do
hash = { :verbose => true }
@sut.send(:initialize_with, hash)
@sut.should.be.verbose
end
#----------------------------------------#
describe "#podfile_path_in_dir" do
it "detects the CocoaPods.podfile.yaml file" do
expected = temporary_directory + "CocoaPods.podfile.yaml"
File.open(expected, "w") {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it "detects the CocoaPods.podfile file" do
expected = temporary_directory + "CocoaPods.podfile"
File.open(expected, "w") {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it "detects the Podfile file" do
expected = temporary_directory + "Podfile"
File.open(expected, "w") {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it "returns nils if the Podfile is not available" do
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path.should == nil
end
end
#-----------------------------------------------------------------------#
end
end end
end end
...@@ -42,9 +42,9 @@ module Pod ...@@ -42,9 +42,9 @@ module Pod
end end
it "fetches the specification from the remote stores it in the sandbox" do it "fetches the specification from the remote stores it in the sandbox" do
config.sandbox.specification('Reachability').should == nil environment.sandbox.specification('Reachability').should == nil
@external_source.fetch(config.sandbox) @external_source.fetch(environment.sandbox)
config.sandbox.specification('Reachability').name.should == 'Reachability' environment.sandbox.specification('Reachability').name.should == 'Reachability'
end end
end end
...@@ -54,9 +54,9 @@ module Pod ...@@ -54,9 +54,9 @@ module Pod
describe "Subclasses helpers" do describe "Subclasses helpers" do
it "pre-downloads the Pod and stores the relevant information in the sandbox" do it "pre-downloads the Pod and stores the relevant information in the sandbox" do
sandbox = config.sandbox sandbox = environment.sandbox
@external_source.send(:pre_download, sandbox) @external_source.send(:pre_download, sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = environment.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
sandbox.predownloaded_pods.should == ["Reachability"] sandbox.predownloaded_pods.should == ["Reachability"]
sandbox.checkout_sources.should == { sandbox.checkout_sources.should == {
...@@ -81,14 +81,14 @@ module Pod ...@@ -81,14 +81,14 @@ module Pod
end end
it "creates a copy of the podspec" do it "creates a copy of the podspec" do
@external_source.fetch(config.sandbox) @external_source.fetch(environment.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = environment.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
it "marks a LocalPod as downloaded" do it "marks a LocalPod as downloaded" do
@external_source.fetch(config.sandbox) @external_source.fetch(environment.sandbox)
config.sandbox.predownloaded_pods.should == ["Reachability"] environment.sandbox.predownloaded_pods.should == ["Reachability"]
end end
it "returns the description" do it "returns the description" do
...@@ -106,14 +106,14 @@ module Pod ...@@ -106,14 +106,14 @@ module Pod
end end
it "creates a copy of the podspec" do it "creates a copy of the podspec" do
@external_source.fetch(config.sandbox) @external_source.fetch(environment.sandbox)
path = config.sandbox.root + 'Local Podspecs/SvnSource.podspec' path = environment.sandbox.root + 'Local Podspecs/SvnSource.podspec'
path.should.exist? path.should.exist?
end end
it "marks a LocalPod as downloaded" do it "marks a LocalPod as downloaded" do
@external_source.fetch(config.sandbox) @external_source.fetch(environment.sandbox)
config.sandbox.predownloaded_pods.should == ["SvnSource"] environment.sandbox.predownloaded_pods.should == ["SvnSource"]
end end
it "returns the description" do it "returns the description" do
...@@ -131,14 +131,14 @@ module Pod ...@@ -131,14 +131,14 @@ module Pod
end end
it "creates a copy of the podspec" do it "creates a copy of the podspec" do
@external_source.fetch(config.sandbox) @external_source.fetch(environment.sandbox)
path = config.sandbox.root + 'Local Podspecs/MercurialSource.podspec' path = environment.sandbox.root + 'Local Podspecs/MercurialSource.podspec'
path.should.exist? path.should.exist?
end end
it "marks a LocalPod as downloaded" do it "marks a LocalPod as downloaded" do
@external_source.fetch(config.sandbox) @external_source.fetch(environment.sandbox)
config.sandbox.predownloaded_pods.should == ["MercurialSource"] environment.sandbox.predownloaded_pods.should == ["MercurialSource"]
end end
it "returns the description" do it "returns the description" do
...@@ -158,8 +158,8 @@ module Pod ...@@ -158,8 +158,8 @@ module Pod
end end
it "creates a copy of the podspec" do it "creates a copy of the podspec" do
@external_source.fetch(config.sandbox) @external_source.fetch(environment.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = environment.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
...@@ -207,15 +207,14 @@ module Pod ...@@ -207,15 +207,14 @@ module Pod
describe ExternalSources::PathSource do describe ExternalSources::PathSource do
before do before do
podspec_path = fixture('integration/Reachability/Reachability.podspec')
dependency = Dependency.new("Reachability", :path => fixture('integration/Reachability')) dependency = Dependency.new("Reachability", :path => fixture('integration/Reachability'))
podfile_path = fixture('integration/Podfile') podfile_path = fixture('integration/Podfile')
@external_source = ExternalSources.from_dependency(dependency, podfile_path) @external_source = ExternalSources.from_dependency(dependency, podfile_path)
end end
it "creates a copy of the podspec" do it "creates a copy of the podspec" do
@external_source.fetch(config.sandbox) @external_source.fetch(environment.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = environment.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
...@@ -223,8 +222,8 @@ module Pod ...@@ -223,8 +222,8 @@ module Pod
dependency = Dependency.new("Reachability", :local => fixture('integration/Reachability')) dependency = Dependency.new("Reachability", :local => fixture('integration/Reachability'))
podfile_path = fixture('integration/Podfile') podfile_path = fixture('integration/Podfile')
external_source = ExternalSources.from_dependency(dependency, podfile_path) external_source = ExternalSources.from_dependency(dependency, podfile_path)
external_source.fetch(config.sandbox) external_source.fetch(environment.sandbox)
path = config.sandbox.root + 'Local Podspecs/Reachability.podspec' path = environment.sandbox.root + 'Local Podspecs/Reachability.podspec'
path.should.exist? path.should.exist?
end end
...@@ -233,8 +232,8 @@ module Pod ...@@ -233,8 +232,8 @@ module Pod
end end
it "marks the Pod as local in the sandbox" do it "marks the Pod as local in the sandbox" do
@external_source.fetch(config.sandbox) @external_source.fetch(environment.sandbox)
config.sandbox.development_pods.should == { environment.sandbox.local_pods.should == {
"Reachability" => fixture('integration/Reachability').to_s "Reachability" => fixture('integration/Reachability').to_s
} }
end end
......
...@@ -26,9 +26,9 @@ describe Pod::Generator::Markdown do ...@@ -26,9 +26,9 @@ describe Pod::Generator::Markdown do
end end
it "writes a markdown file to disk" do it "writes a markdown file to disk" do
basepath = config.sandbox.root + "Pods-acknowledgements" basepath = environment.sandbox.root + "Pods-acknowledgements"
given_path = @generator.class.path_from_basepath(basepath) given_path = @generator.class.path_from_basepath(basepath)
expected_path = config.sandbox.root + "Pods-acknowledgements.markdown" expected_path = environment.sandbox.root + "Pods-acknowledgements.markdown"
mockFile = mock mockFile = mock
mockFile.expects(:write).with(equals(@generator.licenses)) mockFile.expects(:write).with(equals(@generator.licenses))
......
...@@ -9,10 +9,10 @@ module Pod ...@@ -9,10 +9,10 @@ module Pod
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@consumer = @spec.consumer(:ios) @consumer = @spec.consumer(:ios)
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target = AggregateTarget.new(target_definition, config.sandbox) @target = AggregateTarget.new(target_definition, environment.sandbox)
@target.client_root = config.sandbox.root.dirname @target.client_root = environment.sandbox.root.dirname
@target.stubs(:platform).returns(:ios) @target.stubs(:platform).returns(:ios)
@pod_target = PodTarget.new([@spec], target_definition, config.sandbox) @pod_target = PodTarget.new([@spec], target_definition, environment.sandbox)
@pod_target.stubs(:platform).returns(:ios) @pod_target.stubs(:platform).returns(:ios)
@pod_target.stubs(:spec_consumers).returns([@consumer]) @pod_target.stubs(:spec_consumers).returns([@consumer])
@target.pod_targets = [@pod_target] @target.pod_targets = [@pod_target]
...@@ -56,7 +56,7 @@ module Pod ...@@ -56,7 +56,7 @@ module Pod
end end
it 'adds the sandbox public headers search paths to the xcconfig, with quotes' do it 'adds the sandbox public headers search paths to the xcconfig, with quotes' do
expected = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\"" expected = "\"#{environment.sandbox.public_headers.search_paths.join('" "')}\""
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == expected @xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == expected
end end
......
...@@ -10,7 +10,7 @@ module Pod ...@@ -10,7 +10,7 @@ module Pod
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@consumer = @spec.consumer(:ios) @consumer = @spec.consumer(:ios)
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
@pod_target = PodTarget.new([@spec], target_definition, config.sandbox) @pod_target = PodTarget.new([@spec], target_definition, environment.sandbox)
@pod_target.stubs(:platform).returns(:ios) @pod_target.stubs(:platform).returns(:ios)
public_xcconfig = Xcodeproj::Config.new({"OTHER_LDFLAGS"=>"-framework SystemConfiguration"}) public_xcconfig = Xcodeproj::Config.new({"OTHER_LDFLAGS"=>"-framework SystemConfiguration"})
@generator = PrivatePodXCConfig.new(@pod_target, public_xcconfig) @generator = PrivatePodXCConfig.new(@pod_target, public_xcconfig)
...@@ -45,7 +45,7 @@ module Pod ...@@ -45,7 +45,7 @@ module Pod
it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do
private_headers = "\"#{@pod_target.build_headers.search_paths.join('" "')}\"" private_headers = "\"#{@pod_target.build_headers.search_paths.join('" "')}\""
public_headers = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\"" public_headers = "\"#{environment.sandbox.public_headers.search_paths.join('" "')}\""
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include private_headers @xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include private_headers
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include public_headers @xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include public_headers
end end
......
...@@ -8,7 +8,7 @@ module Pod ...@@ -8,7 +8,7 @@ module Pod
before do before do
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox) @pod_target = PodTarget.new([@spec], @target_definition, environment.sandbox)
@pod_target.stubs(:platform).returns(:ios) @pod_target.stubs(:platform).returns(:ios)
@generator = PublicPodXCConfig.new(@pod_target) @generator = PublicPodXCConfig.new(@pod_target)
...@@ -18,7 +18,7 @@ module Pod ...@@ -18,7 +18,7 @@ module Pod
@spec.weak_frameworks = ['iAd'] @spec.weak_frameworks = ['iAd']
@spec.libraries = ['xml2'] @spec.libraries = ['xml2']
file_accessors = [Sandbox::FileAccessor.new(fixture('banana-lib'), @spec.consumer(:ios))] file_accessors = [Sandbox::FileAccessor.new(fixture('banana-lib'), @spec.consumer(:ios))]
# vendored_framework_paths = [config.sandbox.root + 'BananaLib/BananaLib.framework'] # vendored_framework_paths = [environment.sandbox.root + 'BananaLib/BananaLib.framework']
# Sandbox::FileAccessor.any_instance.stubs(:vendored_frameworks).returns(vendored_framework_paths) # Sandbox::FileAccessor.any_instance.stubs(:vendored_frameworks).returns(vendored_framework_paths)
@pod_target.target_definition.stubs(:podfile).returns(@podfile) @pod_target.target_definition.stubs(:podfile).returns(@podfile)
...@@ -65,13 +65,13 @@ module Pod ...@@ -65,13 +65,13 @@ module Pod
end end
it "includes the build settings of the frameworks bundles of the spec" do it "includes the build settings of the frameworks bundles of the spec" do
config.sandbox.stubs(:root).returns(fixture('')) environment.sandbox.stubs(:root).returns(fixture(''))
xcconfig = @generator.generate xcconfig = @generator.generate
xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"') xcconfig.to_hash["FRAMEWORK_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"')
end end
it "includes the build settings of the libraries shipped with the spec" do it "includes the build settings of the libraries shipped with the spec" do
config.sandbox.stubs(:root).returns(fixture('')) environment.sandbox.stubs(:root).returns(fixture(''))
xcconfig = @generator.generate xcconfig = @generator.generate
xcconfig.to_hash["LIBRARY_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"') xcconfig.to_hash["LIBRARY_SEARCH_PATHS"].should.include?('"$(PODS_ROOT)/banana-lib"')
end end
......
...@@ -107,26 +107,26 @@ module Pod ...@@ -107,26 +107,26 @@ module Pod
describe "::add_framework_build_settings" do describe "::add_framework_build_settings" do
it "adds the build settings of a framework to the given xcconfig" do it "adds the build settings of a framework to the given xcconfig" do
framework_path = config.sandbox.root + 'Parse/Parse.framework' framework_path = environment.sandbox.root + 'Parse/Parse.framework'
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
@sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root) @sut.add_framework_build_settings(framework_path, xcconfig, environment.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == "-framework Parse" hash_config['OTHER_LDFLAGS'].should == "-framework Parse"
hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"$(PODS_ROOT)/Parse"' hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"$(PODS_ROOT)/Parse"'
end end
it "doesn't ovverides exiting linker flags" do it "doesn't ovverides exiting linker flags" do
framework_path = config.sandbox.root + 'Parse/Parse.framework' framework_path = environment.sandbox.root + 'Parse/Parse.framework'
xcconfig = Xcodeproj::Config.new( { 'OTHER_LDFLAGS' => '-framework CoreAnimation' } ) xcconfig = Xcodeproj::Config.new( { 'OTHER_LDFLAGS' => '-framework CoreAnimation' } )
@sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root) @sut.add_framework_build_settings(framework_path, xcconfig, environment.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == "-framework CoreAnimation -framework Parse" hash_config['OTHER_LDFLAGS'].should == "-framework CoreAnimation -framework Parse"
end end
it "doesn't ovverides exiting frameworks search paths" do it "doesn't ovverides exiting frameworks search paths" do
framework_path = config.sandbox.root + 'Parse/Parse.framework' framework_path = environment.sandbox.root + 'Parse/Parse.framework'
xcconfig = Xcodeproj::Config.new( { 'FRAMEWORK_SEARCH_PATHS' => '"path/to/frameworks"' } ) xcconfig = Xcodeproj::Config.new( { 'FRAMEWORK_SEARCH_PATHS' => '"path/to/frameworks"' } )
@sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root) @sut.add_framework_build_settings(framework_path, xcconfig, environment.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"path/to/frameworks" "$(PODS_ROOT)/Parse"' hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"path/to/frameworks" "$(PODS_ROOT)/Parse"'
end end
...@@ -136,9 +136,9 @@ module Pod ...@@ -136,9 +136,9 @@ module Pod
describe "::add_library_build_settings" do describe "::add_library_build_settings" do
it "adds the build settings of a framework to the given xcconfig" do it "adds the build settings of a framework to the given xcconfig" do
path = config.sandbox.root + 'MapBox/Proj4/libProj4.a' path = environment.sandbox.root + 'MapBox/Proj4/libProj4.a'
xcconfig = Xcodeproj::Config.new xcconfig = Xcodeproj::Config.new
@sut.add_library_build_settings(path, xcconfig, config.sandbox.root) @sut.add_library_build_settings(path, xcconfig, environment.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == "-lProj4" hash_config['OTHER_LDFLAGS'].should == "-lProj4"
hash_config['LIBRARY_SEARCH_PATHS'].should == '"$(PODS_ROOT)/MapBox/Proj4"' hash_config['LIBRARY_SEARCH_PATHS'].should == '"$(PODS_ROOT)/MapBox/Proj4"'
...@@ -173,3 +173,4 @@ module Pod ...@@ -173,3 +173,4 @@ module Pod
end end
end end
end end
...@@ -7,7 +7,7 @@ module Pod ...@@ -7,7 +7,7 @@ module Pod
before do before do
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@sandbox = config.sandbox @sandbox = environment.sandbox
lockfile_hash = { 'PODS' => ['BananaLib (1.0)'] } lockfile_hash = { 'PODS' => ['BananaLib (1.0)'] }
@manifest = Pod::Lockfile.new(lockfile_hash) @manifest = Pod::Lockfile.new(lockfile_hash)
@sandbox.stubs(:manifest).returns(@manifest) @sandbox.stubs(:manifest).returns(@manifest)
......
...@@ -20,7 +20,7 @@ def create_analyzer ...@@ -20,7 +20,7 @@ def create_analyzer
lockfile = Pod::Lockfile.new(hash) lockfile = Pod::Lockfile.new(hash)
SpecHelper.create_sample_app_copy_from_fixture('SampleProject') SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
analyzer = Pod::Installer::Analyzer.new(config.sandbox, @podfile, lockfile) Pod::Installer::Analyzer.new(environment.sandbox, @podfile, lockfile)
end end
#-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------#
...@@ -61,13 +61,13 @@ module Pod ...@@ -61,13 +61,13 @@ module Pod
#--------------------------------------# #--------------------------------------#
it "updates the repositories by default" do it "updates the repositories by default" do
config.skip_repo_update = false config.stubs(:skip_repo_update).returns(false)
SourcesManager.expects(:update).once SourcesManager.expects(:update).once
@analyzer.analyze @analyzer.analyze
end end
it "does not updates the repositories if config indicates to skip them" do it "does not updates the repositories if config indicates to skip them" do
config.skip_repo_update = true config.stubs(:skip_repo_update).returns(true)
SourcesManager.expects(:update).never SourcesManager.expects(:update).never
@analyzer.analyze @analyzer.analyze
end end
...@@ -82,7 +82,7 @@ module Pod ...@@ -82,7 +82,7 @@ module Pod
'Pods-SVPullToRefresh', 'Pods-SVPullToRefresh',
'Pods-libextobjc' 'Pods-libextobjc'
].sort ].sort
target.support_files_root.should == config.sandbox.root target.support_files_root.should == environment.sandbox.root
target.user_project_path.to_s.should.include 'SampleProject/SampleProject' target.user_project_path.to_s.should.include 'SampleProject/SampleProject'
target.client_root.to_s.should.include 'SampleProject' target.client_root.to_s.should.include 'SampleProject'
...@@ -94,10 +94,10 @@ module Pod ...@@ -94,10 +94,10 @@ module Pod
end end
it "generates the integration library appropriately if the installation will not integrate" do it "generates the integration library appropriately if the installation will not integrate" do
config.integrate_targets = false config.stubs(:integrate_targets).returns(false)
target = @analyzer.analyze.targets.first target = @analyzer.analyze.targets.first
target.client_root.should == config.installation_root target.client_root.should == environment.installation_root
target.user_target_uuids.should == [] target.user_target_uuids.should == []
target.user_build_configurations.should == {} target.user_build_configurations.should == {}
target.platform.to_s.should == 'iOS 6.0' target.platform.to_s.should == 'iOS 6.0'
...@@ -215,7 +215,7 @@ module Pod ...@@ -215,7 +215,7 @@ module Pod
it "if not specified in the target definition if looks if there is only one project" do it "if not specified in the target definition if looks if there is only one project" do
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
config.installation_root = config.installation_root + 'SampleProject' environment.installation_root = environment.installation_root + 'SampleProject'
path = @analyzer.send(:compute_user_project_path, target_definition) path = @analyzer.send(:compute_user_project_path, target_definition)
path.to_s.should.include 'SampleProject/SampleProject.xcodeproj' path.to_s.should.include 'SampleProject/SampleProject.xcodeproj'
......
...@@ -5,24 +5,24 @@ module Pod ...@@ -5,24 +5,24 @@ module Pod
before do before do
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec') @file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@pod_target = PodTarget.new([], nil, config.sandbox) @pod_target = PodTarget.new([], nil, environment.sandbox)
@pod_target.file_accessors = [@file_accessor] @pod_target.file_accessors = [@file_accessor]
@project = Project.new(config.sandbox.project_path) @project = Project.new(environment.sandbox.project_path)
@project.add_pod_group('BananaLib', fixture('banana-lib')) @project.add_pod_group('BananaLib', fixture('banana-lib'))
@installer = Installer::FileReferencesInstaller.new(config.sandbox, [@pod_target], @project) @installer = Installer::FileReferencesInstaller.new(environment.sandbox, [@pod_target], @project)
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "Installation" do describe "Installation" do
it "adds the files references of the source files the Pods project" do it "adds file references of the source files the Pods project" do
@file_accessor.path_list.read_file_system @file_accessor.path_list.read_file_system
@file_accessor.path_list.expects(:read_file_system) @file_accessor.path_list.expects(:read_file_system)
@installer.install! @installer.install!
end end
it "adds the files references of the source files the Pods project" do it "adds file references of the source files the Pods project" do
@installer.install! @installer.install!
file_ref = @installer.pods_project['Pods/BananaLib/Source Files/Banana.m'] file_ref = @installer.pods_project['Pods/BananaLib/Source Files/Banana.m']
file_ref.should.be.not.nil file_ref.should.be.not.nil
...@@ -37,7 +37,7 @@ module Pod ...@@ -37,7 +37,7 @@ module Pod
end end
it "adds the files references of the resources the Pods project" do it "adds file references of the resources the Pods project" do
@installer.install! @installer.install!
file_ref = @installer.pods_project['Pods/BananaLib/Resources/logo-sidebar.png'] file_ref = @installer.pods_project['Pods/BananaLib/Resources/logo-sidebar.png']
file_ref.should.be.not.nil file_ref.should.be.not.nil
...@@ -55,7 +55,7 @@ module Pod ...@@ -55,7 +55,7 @@ module Pod
it "links the public headers" do it "links the public headers" do
@installer.install! @installer.install!
headers_root = config.sandbox.public_headers.root headers_root = environment.sandbox.public_headers.root
public_header = headers_root + 'BananaLib/Banana.h' public_header = headers_root + 'BananaLib/Banana.h'
private_header = headers_root + 'BananaLib/BananaPrivate.h' private_header = headers_root + 'BananaLib/BananaPrivate.h'
public_header.should.exist public_header.should.exist
...@@ -70,20 +70,20 @@ module Pod ...@@ -70,20 +70,20 @@ module Pod
describe "#file_accessors" do describe "#file_accessors" do
it "returns the file accessors" do it "returns the file accessors" do
pod_target_1 = PodTarget.new([], nil, config.sandbox) pod_target_1 = PodTarget.new([], nil, environment.sandbox)
pod_target_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')] pod_target_1.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
pod_target_2 = PodTarget.new([], nil, config.sandbox) pod_target_2 = PodTarget.new([], nil, environment.sandbox)
pod_target_2.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')] pod_target_2.file_accessors = [fixture_file_accessor('banana-lib/BananaLib.podspec')]
installer = Installer::FileReferencesInstaller.new(config.sandbox, [pod_target_1, pod_target_2], @project) installer = Installer::FileReferencesInstaller.new(environment.sandbox, [pod_target_1, pod_target_2], @project)
roots = installer.send(:file_accessors).map { |fa| fa.path_list.root } roots = installer.send(:file_accessors).map { |fa| fa.path_list.root }
roots.should == [fixture('banana-lib'), fixture('banana-lib')] roots.should == [fixture('banana-lib'), fixture('banana-lib')]
end end
it "handles libraries empty libraries without file accessors" do it "handles libraries empty libraries without file accessors" do
pod_target_1 = PodTarget.new([], nil, config.sandbox) pod_target_1 = PodTarget.new([], nil, environment.sandbox)
pod_target_1.file_accessors = [] pod_target_1.file_accessors = []
installer = Installer::FileReferencesInstaller.new(config.sandbox, [pod_target_1], @project) installer = Installer::FileReferencesInstaller.new(environment.sandbox, [pod_target_1], @project)
roots = installer.send(:file_accessors).should == [] installer.send(:file_accessors).should == []
end end
end end
...@@ -134,4 +134,3 @@ module Pod ...@@ -134,4 +134,3 @@ module Pod
end end
end end
...@@ -9,9 +9,9 @@ module Pod ...@@ -9,9 +9,9 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox.project_path) @project = Project.new(environment.sandbox, nil)
config.sandbox.project = @project environment.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios)) file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios))
...@@ -21,20 +21,20 @@ module Pod ...@@ -21,20 +21,20 @@ module Pod
@project.add_file_reference(file, group) @project.add_file_reference(file, group)
end end
@target = AggregateTarget.new(@target_definition, config.sandbox) @target = AggregateTarget.new(@target_definition, environment.sandbox)
@target.stubs(:platform).returns(Platform.new(:ios, '6.0')) @target.stubs(:platform).returns(Platform.new(:ios, '6.0'))
@target.user_project_path = config.sandbox.root + '../user_project.xcodeproj' @target.user_project_path = environment.sandbox.root + '../user_project.xcodeproj'
@target.client_root = config.sandbox.root.dirname @target.client_root = environment.sandbox.root.dirname
@target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug } @target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox) @pod_target = PodTarget.new([@spec], @target_definition, environment.sandbox)
@pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0')) @pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0'))
@pod_target.user_build_configurations = @target.user_build_configurations @pod_target.user_build_configurations = @target.user_build_configurations
@pod_target.file_accessors = [file_accessor] @pod_target.file_accessors = [file_accessor]
@target.pod_targets = [@pod_target] @target.pod_targets = [@pod_target]
@installer = Installer::AggregateTargetInstaller.new(config.sandbox, @target) @installer = Installer::AggregateTargetInstaller.new(environment.sandbox, @target)
@spec.prefix_header_contents = '#import "BlocksKit.h"' @spec.prefix_header_contents = '#import "BlocksKit.h"'
end end
...@@ -114,14 +114,14 @@ module Pod ...@@ -114,14 +114,14 @@ module Pod
it "creates the xcconfig file" do it "creates the xcconfig file" do
@installer.install! @installer.install!
file = config.sandbox.root + @target.xcconfig_path file = environment.sandbox.root + @target.xcconfig_path
xcconfig = Xcodeproj::Config.new(file) xcconfig = Xcodeproj::Config.new(file)
xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods' xcconfig.to_hash['PODS_ROOT'].should == '${SRCROOT}/Pods'
end end
it "creates a header for the target which contains the information about the installed Pods" do it "creates a header for the target which contains the information about the installed Pods" do
@installer.install! @installer.install!
file = config.sandbox.root + 'Pods-environment.h' file = environment.sandbox.root + 'Pods-environment.h'
contents = file.read contents = file.read
contents.should.include?('#define COCOAPODS_POD_AVAILABLE_BananaLib') contents.should.include?('#define COCOAPODS_POD_AVAILABLE_BananaLib')
contents.should.include?('#define COCOAPODS_VERSION_MAJOR_BananaLib 1') contents.should.include?('#define COCOAPODS_VERSION_MAJOR_BananaLib 1')
...@@ -137,7 +137,7 @@ module Pod ...@@ -137,7 +137,7 @@ module Pod
it "creates a create copy resources script" do it "creates a create copy resources script" do
@installer.install! @installer.install!
script = config.sandbox.root + 'Pods-resources.sh' script = environment.sandbox.root + 'Pods-resources.sh'
script.read.should.include?('logo-sidebar.png') script.read.should.include?('logo-sidebar.png')
end end
...@@ -151,9 +151,9 @@ module Pod ...@@ -151,9 +151,9 @@ module Pod
it "creates the acknowledgements files " do it "creates the acknowledgements files " do
@installer.install! @installer.install!
markdown = config.sandbox.root + 'Pods-acknowledgements.markdown' markdown = environment.sandbox.root + 'Pods-acknowledgements.markdown'
markdown.read.should.include?('Permission is hereby granted') markdown.read.should.include?('Permission is hereby granted')
plist = config.sandbox.root + 'Pods-acknowledgements.plist' plist = environment.sandbox.root + 'Pods-acknowledgements.plist'
plist.read.should.include?('Permission is hereby granted') plist.read.should.include?('Permission is hereby granted')
end end
...@@ -163,9 +163,10 @@ module Pod ...@@ -163,9 +163,10 @@ module Pod
build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-dummy.m') } build_file = build_files.find { |bf| bf.file_ref.path.include?('Pods-dummy.m') }
build_file.should.be.not.nil build_file.should.be.not.nil
build_file.file_ref.path.should == 'Pods-dummy.m' build_file.file_ref.path.should == 'Pods-dummy.m'
dummy = config.sandbox.root + 'Pods-dummy.m' dummy = environment.sandbox.root + 'Pods-dummy.m'
dummy.read.should.include?('@interface PodsDummy_Pods') dummy.read.should.include?('@interface PodsDummy_Pods')
end end
end end
end end
end end
...@@ -9,9 +9,9 @@ module Pod ...@@ -9,9 +9,9 @@ module Pod
xcodeproj 'dummy' xcodeproj 'dummy'
end end
@target_definition = @podfile.target_definitions['Pods'] @target_definition = @podfile.target_definitions['Pods']
@project = Project.new(config.sandbox.project_path) @project = Project.new(environment.sandbox.project_path)
config.sandbox.project = @project environment.sandbox.project = @project
path_list = Sandbox::PathList.new(fixture('banana-lib')) path_list = Sandbox::PathList.new(fixture('banana-lib'))
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios)) file_accessor = Sandbox::FileAccessor.new(path_list, @spec.consumer(:ios))
...@@ -21,13 +21,14 @@ module Pod ...@@ -21,13 +21,14 @@ module Pod
@project.add_file_reference(file, group) @project.add_file_reference(file, group)
end end
@pod_target = PodTarget.new([@spec], @target_definition, config.sandbox) @pod_target = PodTarget.new([@spec], @target_definition, environment.sandbox)
@pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0')) @pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0'))
@pod_target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug } @pod_target.user_build_configurations = { 'Debug' => :debug, 'Release' => :release, 'AppStore' => :release, 'Test' => :debug }
@pod_target.file_accessors = [file_accessor] @pod_target.file_accessors = [file_accessor]
@installer = Installer::TargetInstaller.new(config.sandbox, @pod_target) @installer = Installer::TargetInstaller.new(environment.sandbox, @pod_target)
end end
end end
end end
...@@ -13,11 +13,11 @@ module Pod ...@@ -13,11 +13,11 @@ module Pod
before do before do
sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') sample_project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
@sample_project = Xcodeproj::Project.open(sample_project_path) @sample_project = Xcodeproj::Project.open(sample_project_path)
Xcodeproj::Project.new(config.sandbox.project_path).save Xcodeproj::Project.new(environment.sandbox.project_path).save
@target = @sample_project.targets.first @target = @sample_project.targets.first
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true target_definition.link_with_first_target = true
@lib = AggregateTarget.new(target_definition, config.sandbox) @lib = AggregateTarget.new(target_definition, environment.sandbox)
@lib.user_project_path = sample_project_path @lib.user_project_path = sample_project_path
@lib.client_root = sample_project_path.dirname @lib.client_root = sample_project_path.dirname
@lib.user_target_uuids = [@target.uuid] @lib.user_target_uuids = [@target.uuid]
......
require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../../../spec_helper', __FILE__)
module Pod module Pod
describe Installer::UserProjectIntegrator do describe Installer::UserProjectIntegrator do
describe "In general" do describe "In general" do
...@@ -16,14 +17,14 @@ module Pod ...@@ -16,14 +17,14 @@ module Pod
end end
end end
config.sandbox.project = Project.new(config.sandbox.project_path) environment.sandbox.project = Project.new(environment.sandbox.project_path)
Xcodeproj::Project.new(config.sandbox.project_path).save Xcodeproj::Project.new(environment.sandbox.project_path).save
@library = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox) @library = AggregateTarget.new(@podfile.target_definitions['Pods'], environment.sandbox)
@library.client_root = sample_project_path.dirname @library.client_root = sample_project_path.dirname
@library.user_project_path = sample_project_path @library.user_project_path = sample_project_path
@library.user_target_uuids = ['A346496C14F9BE9A0080D870'] @library.user_target_uuids = ['A346496C14F9BE9A0080D870']
empty_library = AggregateTarget.new(@podfile.target_definitions[:empty], config.sandbox) empty_library = AggregateTarget.new(@podfile.target_definitions[:empty], environment.sandbox)
@integrator = Installer::UserProjectIntegrator.new(@podfile, config.sandbox, temporary_directory, [@library, empty_library]) @integrator = Installer::UserProjectIntegrator.new(@podfile, environment.sandbox, temporary_directory, [@library, empty_library])
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -140,7 +141,7 @@ module Pod ...@@ -140,7 +141,7 @@ module Pod
it "raises if no workspace could be selected" do it "raises if no workspace could be selected" do
@integrator.expects(:user_project_paths).returns(%w[ project1 project2 ]) @integrator.expects(:user_project_paths).returns(%w[ project1 project2 ])
e = lambda { @integrator.send(:workspace_path) }.should.raise Informative lambda { @integrator.send(:workspace_path) }.should.raise Informative
end end
it "returns the paths of the user projects" do it "returns the paths of the user projects" do
...@@ -159,3 +160,4 @@ module Pod ...@@ -159,3 +160,4 @@ module Pod
end end
end end
end end
...@@ -14,7 +14,7 @@ end ...@@ -14,7 +14,7 @@ end
# @return [Podfile] # @return [Podfile]
# #
def generate_podfile(pods = ['JSONKit']) def generate_podfile(pods = ['JSONKit'])
podfile = Pod::Podfile.new do Pod::Podfile.new do
platform :ios platform :ios
xcodeproj SpecHelper.fixture('SampleProject/SampleProject'), 'Test' => :debug, 'App Store' => :release xcodeproj SpecHelper.fixture('SampleProject/SampleProject'), 'Test' => :debug, 'App Store' => :release
pods.each { |name| pod name } pods.each { |name| pod name }
...@@ -29,8 +29,8 @@ module Pod ...@@ -29,8 +29,8 @@ module Pod
before do before do
podfile = generate_podfile podfile = generate_podfile
lockfile = generate_lockfile lockfile = generate_lockfile
config.integrate_targets = false config.stubs(:integrate_targets).returns(false)
@installer = Installer.new(config.sandbox, podfile, lockfile) @installer = Installer.new(environment.sandbox, podfile, lockfile)
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
...@@ -76,13 +76,13 @@ module Pod ...@@ -76,13 +76,13 @@ module Pod
end end
it "integrates the user targets if the corresponding config is set" do it "integrates the user targets if the corresponding config is set" do
config.integrate_targets = true config.stubs(:integrate_targets).returns(true)
@installer.expects(:integrate_user_project) @installer.expects(:integrate_user_project)
@installer.install! @installer.install!
end end
it "doesn't integrates the user targets if the corresponding config is not set" do it "doesn't integrates the user targets if the corresponding config is not set" do
config.integrate_targets = false config.stubs(:integrate_targets).returns(false)
@installer.expects(:integrate_user_project).never @installer.expects(:integrate_user_project).never
@installer.install! @installer.install!
end end
...@@ -130,13 +130,13 @@ module Pod ...@@ -130,13 +130,13 @@ module Pod
@analysis_result = Installer::Analyzer::AnalysisResult.new @analysis_result = Installer::Analyzer::AnalysisResult.new
@analysis_result.specifications = [] @analysis_result.specifications = []
@analysis_result.sandbox_state = Installer::Analyzer::SpecsState.new() @analysis_result.sandbox_state = Installer::Analyzer::SpecsState.new()
@pod_targets = [PodTarget.new([], nil, config.sandbox)] @pod_targets = [PodTarget.new([], nil, environment.sandbox)]
@installer.stubs(:analysis_result).returns(@analysis_result) @installer.stubs(:analysis_result).returns(@analysis_result)
@installer.stubs(:pod_targets).returns(@pod_targets) @installer.stubs(:pod_targets).returns(@pod_targets)
end end
it "cleans the header stores" do it "cleans the header stores" do
config.sandbox.public_headers.expects(:implode!) environment.sandbox.public_headers.expects(:implode!)
@installer.pod_targets.each do |pods_target| @installer.pod_targets.each do |pods_target|
pods_target.build_headers.expects(:implode!) pods_target.build_headers.expects(:implode!)
end end
...@@ -145,7 +145,7 @@ module Pod ...@@ -145,7 +145,7 @@ module Pod
it "deletes the sources of the removed Pods" do it "deletes the sources of the removed Pods" do
@analysis_result.sandbox_state.add_name('Deleted-Pod', :deleted) @analysis_result.sandbox_state.add_name('Deleted-Pod', :deleted)
config.sandbox.expects(:clean_pod).with('Deleted-Pod') environment.sandbox.expects(:clean_pod).with('Deleted-Pod')
@installer.send(:clean_sandbox) @installer.send(:clean_sandbox)
end end
...@@ -175,7 +175,7 @@ module Pod ...@@ -175,7 +175,7 @@ module Pod
it "correctly configures the Pod source installer" do it "correctly configures the Pod source installer" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
pod_target = PodTarget.new([spec], nil, config.sandbox) pod_target = PodTarget.new([spec], nil, environment.sandbox)
pod_target.stubs(:platform).returns(:ios) pod_target.stubs(:platform).returns(:ios)
@installer.stubs(:pod_targets).returns([pod_target]) @installer.stubs(:pod_targets).returns([pod_target])
@installer.instance_variable_set(:@installed_specs, []) @installer.instance_variable_set(:@installed_specs, [])
...@@ -185,7 +185,7 @@ module Pod ...@@ -185,7 +185,7 @@ module Pod
it "maintains the list of the installed specs" do it "maintains the list of the installed specs" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
pod_target = PodTarget.new([spec], nil, config.sandbox) pod_target = PodTarget.new([spec], nil, environment.sandbox)
pod_target.stubs(:platform).returns(:ios) pod_target.stubs(:platform).returns(:ios)
@installer.stubs(:pod_targets).returns([pod_target, pod_target]) @installer.stubs(:pod_targets).returns([pod_target, pod_target])
@installer.instance_variable_set(:@installed_specs, []) @installer.instance_variable_set(:@installed_specs, [])
...@@ -199,7 +199,7 @@ module Pod ...@@ -199,7 +199,7 @@ module Pod
describe "#clean" do describe "#clean" do
it "it cleans only if the config instructs to do it" do it "it cleans only if the config instructs to do it" do
config.clean = false config.stubs(:clean).returns(false)
@installer.send(:clean_pod_sources) @installer.send(:clean_pod_sources)
Installer::PodSourceInstaller.any_instance.expects(:install!).never Installer::PodSourceInstaller.any_instance.expects(:install!).never
end end
...@@ -222,14 +222,14 @@ module Pod ...@@ -222,14 +222,14 @@ module Pod
end end
it "creates build configurations for all of the user's targets" do it "creates build configurations for all of the user's targets" do
config.integrate_targets = true config.stubs(:integrate_targets).returns(true)
@installer.send(:analyze) @installer.send(:analyze)
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
@installer.pods_project.build_configurations.map(&:name).sort.should == ['App Store', 'Debug', 'Release', 'Test'] @installer.pods_project.build_configurations.map(&:name).sort.should == ['App Store', 'Debug', 'Release', 'Test']
end end
it "sets STRIP_INSTALLED_PRODUCT to NO for all configurations for the whole project" do it "sets STRIP_INSTALLED_PRODUCT to NO for all configurations for the whole project" do
config.integrate_targets = true config.stubs(:integrate_targets).returns(true)
@installer.send(:analyze) @installer.send(:analyze)
@installer.send(:prepare_pods_project) @installer.send(:prepare_pods_project)
@installer.pods_project.build_settings('Debug')["STRIP_INSTALLED_PRODUCT"].should == "NO" @installer.pods_project.build_settings('Debug')["STRIP_INSTALLED_PRODUCT"].should == "NO"
...@@ -254,8 +254,8 @@ module Pod ...@@ -254,8 +254,8 @@ module Pod
end end
it "sets the deployment target for the whole project" do it "sets the deployment target for the whole project" do
pod_target_ios = PodTarget.new([], nil, config.sandbox) pod_target_ios = PodTarget.new([], nil, environment.sandbox)
pod_target_osx = PodTarget.new([], nil, config.sandbox) pod_target_osx = PodTarget.new([], nil, environment.sandbox)
pod_target_ios.stubs(:platform).returns(Platform.new(:ios, '6.0')) pod_target_ios.stubs(:platform).returns(Platform.new(:ios, '6.0'))
pod_target_osx.stubs(:platform).returns(Platform.new(:osx, '10.8')) pod_target_osx.stubs(:platform).returns(Platform.new(:osx, '10.8'))
@installer.stubs(:aggregate_targets).returns([pod_target_ios, pod_target_osx]) @installer.stubs(:aggregate_targets).returns([pod_target_ios, pod_target_osx])
...@@ -290,7 +290,7 @@ module Pod ...@@ -290,7 +290,7 @@ module Pod
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
target_definition.store_pod('BananaLib') target_definition.store_pod('BananaLib')
pod_target = PodTarget.new([spec], target_definition, config.sandbox) pod_target = PodTarget.new([spec], target_definition, environment.sandbox)
@installer.stubs(:aggregate_targets).returns([]) @installer.stubs(:aggregate_targets).returns([])
@installer.stubs(:pod_targets).returns([pod_target]) @installer.stubs(:pod_targets).returns([pod_target])
Installer::PodTargetInstaller.any_instance.expects(:install!) Installer::PodTargetInstaller.any_instance.expects(:install!)
...@@ -300,7 +300,7 @@ module Pod ...@@ -300,7 +300,7 @@ module Pod
it "skips empty pod targets" do it "skips empty pod targets" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new(:default, nil) target_definition = Podfile::TargetDefinition.new(:default, nil)
pod_target = PodTarget.new([spec], target_definition, config.sandbox) pod_target = PodTarget.new([spec], target_definition, environment.sandbox)
@installer.stubs(:aggregate_targets).returns([]) @installer.stubs(:aggregate_targets).returns([])
@installer.stubs(:pod_targets).returns([pod_target]) @installer.stubs(:pod_targets).returns([pod_target])
Installer::PodTargetInstaller.any_instance.expects(:install!).never Installer::PodTargetInstaller.any_instance.expects(:install!).never
...@@ -350,7 +350,6 @@ module Pod ...@@ -350,7 +350,6 @@ module Pod
end end
it "saves the project to the given path" do it "saves the project to the given path" do
path = temporary_directory + 'Pods/Pods.xcodeproj'
@installer.pods_project.expects(:save) @installer.pods_project.expects(:save)
@installer.send(:write_pod_project) @installer.send(:write_pod_project)
end end
...@@ -395,17 +394,16 @@ module Pod ...@@ -395,17 +394,16 @@ module Pod
it "links the pod targets with the aggregate integration library target" do it "links the pod targets with the aggregate integration library target" do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
target = AggregateTarget.new(target_definition, config.sandbox) target = AggregateTarget.new(target_definition, environment.sandbox)
lib_definition = Podfile::TargetDefinition.new('BananaLib', nil) lib_definition = Podfile::TargetDefinition.new('BananaLib', nil)
lib_definition.store_pod('BananaLib') lib_definition.store_pod('BananaLib')
pod_target = PodTarget.new([spec], lib_definition, config.sandbox) pod_target = PodTarget.new([spec], lib_definition, environment.sandbox)
target.pod_targets = [pod_target] target.pod_targets = [pod_target]
project = Xcodeproj::Project.new('path') project = Xcodeproj::Project.new('path')
pods_target = project.new_target(:static_library, target.name, :ios) pods_target = project.new_target(:static_library, target.name, :ios)
target.target = pods_target target.target = pods_target
native_target = project.new_target(:static_library, pod_target.name, :ios)
pod_target.target = pods_target pod_target.target = pods_target
@installer.stubs(:pods_project).returns(project) @installer.stubs(:pods_project).returns(project)
...@@ -417,7 +415,7 @@ module Pod ...@@ -417,7 +415,7 @@ module Pod
end end
it "integrates the client projects" do it "integrates the client projects" do
@installer.stubs(:aggregate_targets).returns([AggregateTarget.new(nil, config.sandbox)]) @installer.stubs(:aggregate_targets).returns([AggregateTarget.new(nil, environment.sandbox)])
Installer::UserProjectIntegrator.any_instance.expects(:integrate!) Installer::UserProjectIntegrator.any_instance.expects(:integrate!)
@installer.send(:integrate_user_project) @installer.send(:integrate_user_project)
end end
...@@ -461,12 +459,10 @@ module Pod ...@@ -461,12 +459,10 @@ module Pod
end end
it "calls the hooks in the specs for each target" do it "calls the hooks in the specs for each target" do
pod_target_ios = PodTarget.new([@spec], nil, config.sandbox) pod_target_ios = PodTarget.new([@spec], nil, environment.sandbox)
pod_target_osx = PodTarget.new([@spec], nil, config.sandbox) pod_target_osx = PodTarget.new([@spec], nil, environment.sandbox)
pod_target_ios.stubs(:name).returns('label') pod_target_ios.stubs(:name).returns('label')
pod_target_osx.stubs(:name).returns('label') pod_target_osx.stubs(:name).returns('label')
library_ios_rep = stub()
library_osx_rep = stub()
target_installer_data = stub() target_installer_data = stub()
@installer.stubs(:pod_targets).returns([pod_target_ios, pod_target_osx]) @installer.stubs(:pod_targets).returns([pod_target_ios, pod_target_osx])
......
...@@ -7,7 +7,7 @@ module Pod ...@@ -7,7 +7,7 @@ module Pod
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true @target_definition.link_with_first_target = true
@lib = AggregateTarget.new(@target_definition, config.sandbox) @lib = AggregateTarget.new(@target_definition, environment.sandbox)
end end
it "returns the target_definition that generated it" do it "returns the target_definition that generated it" do
...@@ -31,8 +31,8 @@ module Pod ...@@ -31,8 +31,8 @@ module Pod
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true @target_definition.link_with_first_target = true
@lib = AggregateTarget.new(@target_definition, config.sandbox) @lib = AggregateTarget.new(@target_definition, environment.sandbox)
@lib.client_root = config.sandbox.root.dirname @lib.client_root = environment.sandbox.root.dirname
end end
it "returns the absolute path of the xcconfig file" do it "returns the absolute path of the xcconfig file" do
......
...@@ -4,7 +4,7 @@ module Pod ...@@ -4,7 +4,7 @@ module Pod
describe Project do describe Project do
before do before do
@project = Project.new(config.sandbox.project_path) @project = Project.new(environment.sandbox.project_path)
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
...@@ -137,8 +137,8 @@ module Pod ...@@ -137,8 +137,8 @@ module Pod
describe "#reference_for_path" do describe "#reference_for_path" do
before do before do
@project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'), false) @project.add_pod_group('BananaLib', environment.sandbox.pod_dir('BananaLib'), false)
@file = config.sandbox.pod_dir('BananaLib') + "file.m" @file = environment.sandbox.pod_dir('BananaLib') + "file.m"
@group = @project.group_for_spec('BananaLib', :source_files) @group = @project.group_for_spec('BananaLib', :source_files)
end end
...@@ -167,8 +167,8 @@ module Pod ...@@ -167,8 +167,8 @@ module Pod
describe "#reference_for_path" do describe "#reference_for_path" do
before do before do
@project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'), false) @project.add_pod_group('BananaLib', environment.sandbox.pod_dir('BananaLib'), false)
@file = config.sandbox.pod_dir('BananaLib') + "file.m" @file = environment.sandbox.pod_dir('BananaLib') + "file.m"
@group = @project.group_for_spec('BananaLib', :source_files) @group = @project.group_for_spec('BananaLib', :source_files)
@project.add_file_reference(@file, @group) @project.add_file_reference(@file, @group)
end end
...@@ -179,7 +179,7 @@ module Pod ...@@ -179,7 +179,7 @@ module Pod
end end
it "returns nil if no reference for the given path is available" do it "returns nil if no reference for the given path is available" do
another_file = config.sandbox.pod_dir('BananaLib') + "another_file.m" another_file = environment.sandbox.pod_dir('BananaLib') + "another_file.m"
ref = @project.reference_for_path(another_file) ref = @project.reference_for_path(another_file)
ref.should.be.nil ref.should.be.nil
end end
...@@ -189,13 +189,12 @@ module Pod ...@@ -189,13 +189,12 @@ module Pod
@project.reference_for_path('relative/path/to/file.m') @project.reference_for_path('relative/path/to/file.m')
end.message.should.match /Paths must be absolute/ end.message.should.match /Paths must be absolute/
end end
end end
#----------------------------------------# #----------------------------------------#
it "adds the Podfile configured as a Ruby file" do it "adds the Podfile configured as a Ruby file" do
@project.add_podfile(config.sandbox.root + '../Podfile') @project.add_podfile(environment.sandbox.root + '../Podfile')
f = @project['Podfile'] f = @project['Podfile']
f.source_tree.should == 'SOURCE_ROOT' f.source_tree.should == 'SOURCE_ROOT'
f.xc_language_specification_identifier.should == 'xcode.lang.ruby' f.xc_language_specification_identifier.should == 'xcode.lang.ruby'
...@@ -211,7 +210,7 @@ module Pod ...@@ -211,7 +210,7 @@ module Pod
describe "#spec_group" do describe "#spec_group" do
before do before do
@project.add_pod_group('JSONKit', config.sandbox.pod_dir('JSONKit')) @project.add_pod_group('JSONKit', environment.sandbox.pod_dir('JSONKit'))
end end
it "returns the Pod group for root specifications" do it "returns the Pod group for root specifications" do
......
...@@ -9,11 +9,11 @@ module Pod ...@@ -9,11 +9,11 @@ module Pod
pod 'BlocksKit', '1.5.2' pod 'BlocksKit', '1.5.2'
end end
locked_deps = [Dependency.new('BlocksKit', '1.5.2')] locked_deps = [Dependency.new('BlocksKit', '1.5.2')]
@resolver = Resolver.new(config.sandbox, @podfile, locked_deps) @resolver = Resolver.new(environment.sandbox, @podfile, locked_deps)
end end
it "returns the sandbox" do it "returns the sandbox" do
@resolver.sandbox.should == config.sandbox @resolver.sandbox.should == environment.sandbox
end end
it "returns the podfile" do it "returns the podfile" do
...@@ -50,12 +50,12 @@ module Pod ...@@ -50,12 +50,12 @@ module Pod
it "it resolves specifications from external sources" do it "it resolves specifications from external sources" do
podspec = fixture('integration/Reachability/Reachability.podspec') podspec = fixture('integration/Reachability/Reachability.podspec')
spec = Specification.from_file(podspec) spec = Specification.from_file(podspec)
config.sandbox.expects(:specification).with('Reachability').returns(spec) environment.sandbox.expects(:specification).with('Reachability').returns(spec)
podfile = Podfile.new do podfile = Podfile.new do
platform :ios platform :ios
pod "Reachability", :podspec => podspec pod "Reachability", :podspec => podspec
end end
resolver = Resolver.new(config.sandbox, podfile) resolver = Resolver.new(environment.sandbox, podfile)
resolver.resolve resolver.resolve
specs = resolver.specs_by_target.values.flatten specs = resolver.specs_by_target.values.flatten
specs.map(&:to_s).should == ['Reachability (3.0.0)'] specs.map(&:to_s).should == ['Reachability (3.0.0)']
...@@ -70,7 +70,7 @@ module Pod ...@@ -70,7 +70,7 @@ module Pod
platform :ios, '6.0' platform :ios, '6.0'
pod 'BlocksKit', '1.5.2' pod 'BlocksKit', '1.5.2'
end end
@resolver = Resolver.new(config.sandbox, @podfile) @resolver = Resolver.new(environment.sandbox, @podfile)
end end
it "cross resolves dependencies" do it "cross resolves dependencies" do
...@@ -80,7 +80,7 @@ module Pod ...@@ -80,7 +80,7 @@ module Pod
pod 'AFQuickLookView', '= 0.1.0' # requires 'AFNetworking', '>= 0.9.0' pod 'AFQuickLookView', '= 0.1.0' # requires 'AFNetworking', '>= 0.9.0'
end end
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(environment.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:to_s).sort specs = resolver.resolve.values.flatten.map(&:to_s).sort
specs.should == ["AFNetworking (0.9.1)", "AFQuickLookView (0.1.0)"] specs.should == ["AFNetworking (0.9.1)", "AFQuickLookView (0.1.0)"]
end end
...@@ -110,7 +110,7 @@ module Pod ...@@ -110,7 +110,7 @@ module Pod
platform :ios platform :ios
pod 'RestKit', '0.10.3' pod 'RestKit', '0.10.3'
end end
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(environment.sandbox, @podfile)
resolver.resolve.values.flatten.map(&:name).sort.should == %w{ resolver.resolve.values.flatten.map(&:name).sort.should == %w{
FileMD5Hash FileMD5Hash
ISO8601DateFormatter ISO8601DateFormatter
...@@ -145,8 +145,8 @@ module Pod ...@@ -145,8 +145,8 @@ module Pod
fss.subspec 'SecondSubSpec' fss.subspec 'SecondSubSpec'
end end
end end
config.sandbox.expects(:specification).with('MainSpec').returns(spec) environment.sandbox.expects(:specification).with('MainSpec').returns(spec)
resolver = Resolver.new(config.sandbox, @podfile) resolver = Resolver.new(environment.sandbox, @podfile)
specs = resolver.resolve.values.flatten.map(&:name).sort specs = resolver.resolve.values.flatten.map(&:name).sort
specs.should == %w{ MainSpec/FirstSubSpec MainSpec/FirstSubSpec/SecondSubSpec } specs.should == %w{ MainSpec/FirstSubSpec MainSpec/FirstSubSpec/SecondSubSpec }
end end
...@@ -157,12 +157,12 @@ module Pod ...@@ -157,12 +157,12 @@ module Pod
pod 'FileMD5Hash' pod 'FileMD5Hash'
pod 'JSONKit', :head pod 'JSONKit', :head
end end
resolver = Resolver.new(config.sandbox, podfile) resolver = Resolver.new(environment.sandbox, podfile)
filemd5hash, jsonkit = resolver.resolve.values.first.sort_by(&:name) filemd5hash, jsonkit = resolver.resolve.values.first.sort_by(&:name)
filemd5hash.version.should.not.be.head filemd5hash.version.should.not.be.head
jsonkit.version.should.be.head jsonkit.version.should.be.head
config.sandbox.head_pod?('FileMD5Hash').should.be.false environment.sandbox.head_pod?('FileMD5Hash').should.be.false
config.sandbox.head_pod?('JSONKit').should.be.true environment.sandbox.head_pod?('JSONKit').should.be.true
end end
it "raises if it finds two conflicting dependencies" do it "raises if it finds two conflicting dependencies" do
...@@ -171,7 +171,7 @@ module Pod ...@@ -171,7 +171,7 @@ module Pod
pod 'JSONKit', "1.4" pod 'JSONKit', "1.4"
pod 'JSONKit', "1.5pre" pod 'JSONKit', "1.5pre"
end end
resolver = Resolver.new(config.sandbox, podfile) resolver = Resolver.new(environment.sandbox, podfile)
e = lambda {resolver.resolve}.should.raise Pod::Informative e = lambda {resolver.resolve}.should.raise Pod::Informative
e.message.should.match(/already activated version/) e.message.should.match(/already activated version/)
end end
...@@ -181,12 +181,12 @@ module Pod ...@@ -181,12 +181,12 @@ module Pod
platform :ios platform :ios
pod 'JSONKit', "<= 1.5pre" pod 'JSONKit', "<= 1.5pre"
end end
resolver = Resolver.new(config.sandbox, podfile) resolver = Resolver.new(environment.sandbox, podfile)
version = resolver.resolve.values.flatten.first.version version = resolver.resolve.values.flatten.first.version
version.to_s.should == '1.5pre' version.to_s.should == '1.5pre'
locked_deps = [Dependency.new('JSONKit', "= 1.4")] locked_deps = [Dependency.new('JSONKit', "= 1.4")]
resolver = Resolver.new(config.sandbox, podfile, locked_deps) resolver = Resolver.new(environment.sandbox, podfile, locked_deps)
version = resolver.resolve.values.flatten.first.version version = resolver.resolve.values.flatten.first.version
version.to_s.should == '1.4' version.to_s.should == '1.4'
end end
......
...@@ -79,7 +79,7 @@ module Pod ...@@ -79,7 +79,7 @@ module Pod
describe "Updating Sources" do describe "Updating Sources" do
extend SpecHelper::TemporaryRepos extend SpecHelper::TemporaryRepos
it "update source backed by a git repository" do it "updates source backed by a git repository" do
set_up_test_repo set_up_test_repo
upstream = SpecHelper.temporary_directory + 'upstream' upstream = SpecHelper.temporary_directory + 'upstream'
FileUtils.cp_r(test_repo_path, upstream) FileUtils.cp_r(test_repo_path, upstream)
...@@ -89,7 +89,7 @@ module Pod ...@@ -89,7 +89,7 @@ module Pod
`git fetch -q` `git fetch -q`
`git branch --set-upstream master origin/master` `git branch --set-upstream master origin/master`
end end
config.repos_dir = SpecHelper.tmp_repos_path config.stubs(:repos_dir).returns(SpecHelper.tmp_repos_path)
SourcesManager.update(test_repo_path.basename.to_s, true) SourcesManager.update(test_repo_path.basename.to_s, true)
UI.output.should.match /Already up-to-date/ UI.output.should.match /Already up-to-date/
......
...@@ -6,7 +6,7 @@ module Pod ...@@ -6,7 +6,7 @@ module Pod
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true @target_definition.link_with_first_target = true
@target = AggregateTarget.new(@target_definition, config.sandbox) @target = AggregateTarget.new(@target_definition, environment.sandbox)
end end
it "returns the target_definition that generated it" do it "returns the target_definition that generated it" do
...@@ -30,8 +30,8 @@ module Pod ...@@ -30,8 +30,8 @@ module Pod
before do before do
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@target_definition.link_with_first_target = true @target_definition.link_with_first_target = true
@target = AggregateTarget.new(@target_definition, config.sandbox) @target = AggregateTarget.new(@target_definition, environment.sandbox)
@target.client_root = config.sandbox.root.dirname @target.client_root = environment.sandbox.root.dirname
end end
it "returns the absolute path of the xcconfig file" do it "returns the absolute path of the xcconfig file" do
...@@ -73,8 +73,8 @@ module Pod ...@@ -73,8 +73,8 @@ module Pod
before do before do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
pod_target = PodTarget.new([spec], target_definition, config.sandbox) pod_target = PodTarget.new([spec], target_definition, environment.sandbox)
@target = AggregateTarget.new(target_definition, config.sandbox) @target = AggregateTarget.new(target_definition, environment.sandbox)
@target.stubs(:platform).returns(:ios) @target.stubs(:platform).returns(:ios)
@target.pod_targets = [pod_target] @target.pod_targets = [pod_target]
end end
......
...@@ -5,7 +5,7 @@ module Pod ...@@ -5,7 +5,7 @@ module Pod
before do before do
spec = fixture_spec('banana-lib/BananaLib.podspec') spec = fixture_spec('banana-lib/BananaLib.podspec')
@target_definition = Podfile::TargetDefinition.new('Pods', nil) @target_definition = Podfile::TargetDefinition.new('Pods', nil)
@pod_target = PodTarget.new([spec], @target_definition, config.sandbox) @pod_target = PodTarget.new([spec], @target_definition, environment.sandbox)
@pod_target.stubs(:platform).returns(:ios) @pod_target.stubs(:platform).returns(:ios)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment