Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
d1cf0b99
Commit
d1cf0b99
authored
Sep 28, 2013
by
Marin Usalj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
still refactoring. still lots of broken places
parent
7d7a92b6
Show whitespace changes
Inline
Side-by-side
Showing
40 changed files
with
676 additions
and
690 deletions
+676
-690
sandbox-pod
bin/sandbox-pod
+3
-3
command.rb
lib/cocoapods/command.rb
+3
-2
config.rb
lib/cocoapods/config.rb
+26
-230
config_manager.rb
lib/cocoapods/config/config_manager.rb
+23
-25
environment.rb
lib/cocoapods/config/environment.rb
+199
-0
executable.rb
lib/cocoapods/executable.rb
+3
-1
external_sources.rb
lib/cocoapods/external_sources.rb
+1
-1
installer.rb
lib/cocoapods/installer.rb
+8
-9
analyzer.rb
lib/cocoapods/installer/analyzer.rb
+6
-4
file_references_installer.rb
lib/cocoapods/installer/file_references_installer.rb
+1
-0
project.rb
lib/cocoapods/project.rb
+1
-0
sources_manager.rb
lib/cocoapods/sources_manager.rb
+5
-4
user_interface.rb
lib/cocoapods/user_interface.rb
+7
-9
validator.rb
lib/cocoapods/validator.rb
+20
-12
config_spec.rb
spec/functional/command/config_spec.rb
+5
-18
spec_helper.rb
spec/spec_helper.rb
+2
-1
pre_flight.rb
spec/spec_helper/pre_flight.rb
+5
-8
config_manager_spec.rb
spec/unit/config/config_manager_spec.rb
+31
-18
environment_spec.rb
spec/unit/config/environment_spec.rb
+171
-0
config_spec.rb
spec/unit/config_spec.rb
+4
-191
external_sources_spec.rb
spec/unit/external_sources_spec.rb
+25
-26
markdown_spec.rb
spec/unit/generator/acknowledgements/markdown_spec.rb
+2
-2
aggregate_xcconfig_spec.rb
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
+4
-4
private_pod_xcconfig_spec.rb
spec/unit/generator/xcconfig/private_pod_xcconfig_spec.rb
+2
-2
public_pod_xcconfig_spec.rb
spec/unit/generator/xcconfig/public_pod_xcconfig_spec.rb
+4
-4
xcconfig_helper_spec.rb
spec/unit/generator/xcconfig/xcconfig_helper_spec.rb
+9
-8
sandbox_analyzer_spec.rb
spec/unit/installer/analyzer/sandbox_analyzer_spec.rb
+1
-1
analyzer_spec.rb
spec/unit/installer/analyzer_spec.rb
+7
-7
file_references_installer_spec.rb
spec/unit/installer/file_references_installer_spec.rb
+13
-14
aggregate_target_installer_spec.rb
...aller/target_installer/aggregate_target_installer_spec.rb
+14
-13
target_installer_spec.rb
spec/unit/installer/target_installer_spec.rb
+5
-4
target_integrator_spec.rb
...staller/user_project_integrator/target_integrator_spec.rb
+2
-2
user_project_integrator_spec.rb
spec/unit/installer/user_project_integrator_spec.rb
+8
-6
installer_spec.rb
spec/unit/installer_spec.rb
+22
-26
library_spec.rb
spec/unit/library_spec.rb
+3
-3
project_spec.rb
spec/unit/project_spec.rb
+8
-9
resolver_spec.rb
spec/unit/resolver_spec.rb
+15
-15
sources_manager_spec.rb
spec/unit/sources_manager_spec.rb
+2
-2
aggregate_target_spec.rb
spec/unit/target/aggregate_target_spec.rb
+5
-5
pod_target_spec.rb
spec/unit/target/pod_target_spec.rb
+1
-1
No files found.
bin/sandbox-pod
View file @
d1cf0b99
...
...
@@ -81,7 +81,7 @@ PROFILE_ERB_TEMPLATE = <<-EOS
#"^<%= ruby_prefix %>"
#"^<%= pod_prefix %>"
#"^<%= xcode_app_path %>"
#"^<%= Pod::Config
.instance
.repos_dir %>"
#"^<%= Pod::Config
::ConfigEnvironment
.repos_dir %>"
<% prefixes.each do |prefix| %>
#"^<%= prefix %>/*"
<% end %>
...
...
@@ -94,8 +94,8 @@ PROFILE_ERB_TEMPLATE = <<-EOS
"/dev/null"
)
(regex
#"^<%= Pod::Config.instance.project_root %>"
#"^<%= Pod::Config.instance.repos_dir %>"
#"^<%= Pod::Config
::ConfigEnvironment
.instance.project_root %>"
#"^<%= Pod::Config
::ConfigEnvironment
.instance.repos_dir %>"
#"^/Users/[^.]+/Library/Caches/CocoaPods/*"
#"^/dev/tty"
#"^/private/var"
...
...
lib/cocoapods/command.rb
View file @
d1cf0b99
...
...
@@ -23,6 +23,8 @@ module Pod
require
'cocoapods/command/spec'
require
'cocoapods/command/init'
include
Pod
::
Config
::
Manager
self
.
abstract_command
=
true
self
.
default_subcommand
=
'install'
self
.
command
=
'pod'
...
...
@@ -56,7 +58,7 @@ module Pod
def
self
.
report_error
(
exception
)
if
exception
.
is_a?
(
Interrupt
)
puts
"[!] Cancelled"
.
red
Pod
::
Config
.
instance
.
verbose?
?
raise
:
exit
(
1
)
config
.
verbose?
?
raise
:
exit
(
1
)
else
if
ENV
[
'COCOA_PODS_ENV'
]
!=
'development'
puts
UI
::
ErrorReport
.
report
(
exception
)
...
...
@@ -88,7 +90,6 @@ module Pod
#-------------------------------------------------------------------------#
include
Pod
::
Config
::
Mixin
private
...
...
lib/cocoapods/config.rb
View file @
d1cf0b99
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
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.
# This module is not intented to be included - you probably
# want to include Config::Manager and/or Config::Enironment
#
def
sandbox_root
@sandbox_root
||=
installation_root
+
'Pods'
end
module
Config
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
autoload
:ConfigManager
,
'cocoapods/config/config_manager'
autoload
:ConfigEnvironment
,
'cocoapods/config/environment'
# 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]
# Provides support for accessing the configuration manager
# instance in other scopes.
#
def
default_podfile_path
@default_podfile_path
||=
templates_dir
+
"Podfile.default"
module
Manager
def
config
ConfigManager
.
instance
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.
# Provides support for accessing the environment instance in other
# scopes.
#
def
statistics_cache_file
cache_root
+
'statistics.yml'
module
Environment
def
environment
ConfigEnvironment
.
instance
end
# @return [Pathname] The file to use to cache the search data.
#
def
search_index_file
cache_root
+
'search_index.yaml'
end
public
extend
Environment
extend
Manager
#-------------------------------------------------------------------------#
# @!group Dependency Injection
...
...
@@ -167,100 +42,21 @@ module Pod
# @return [Downloader] The downloader to use for the retrieving remote
# source.
#
def
downloader
(
target_path
,
options
)
def
self
.
downloader
(
target_path
,
options
)
downloader
=
Downloader
.
for_target
(
target_path
,
options
)
downloader
.
cache_root
=
cache_root
downloader
.
max_cache_size
=
max_cache_size
downloader
.
aggressive_cache
=
aggressive_cache?
downloader
.
cache_root
=
environment
.
cache_root
downloader
.
max_cache_size
=
config
.
max_cache_size
downloader
.
aggressive_cache
=
config
.
aggressive_cache?
downloader
end
# @return [Specification::Set::Statistics] The statistic provider to use
# for specifications.
#
def
spec_statistics_provider
Specification
::
Set
::
Statistics
.
new
(
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
def
self
.
spec_statistics_provider
Specification
::
Set
::
Statistics
.
new
(
environment
.
statistics_cache_file
)
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
# Provides support for accessing the configuration instance in other
# scopes.
#
module
Mixin
def
config
Config
.
instance
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
lib/cocoapods/config/config_manager.rb
View file @
d1cf0b99
module
Pod
class
Config
module
Config
require
'yaml'
...
...
@@ -9,6 +9,7 @@ module Pod
#
class
ConfigManager
# The default settings for the configuration.
#
# Users can specify custom settings in `~/.cocoapods/config.yaml`.
...
...
@@ -19,17 +20,16 @@ module Pod
# new_version_message: false
#
DEFAULTS
=
{
:verbose
=>
false
,
:silent
=>
false
,
:skip_repo_update
=>
false
,
'verbose'
=>
false
,
'silent'
=>
false
,
'skip_repo_update'
=>
false
,
:clean
=>
true
,
:integrate_targets
=>
true
,
:new_version_message
=>
true
,
'clean'
=>
true
,
'integrate_targets'
=>
true
,
'new_version_message'
=>
true
,
:cache_root
=>
Pathname
.
new
(
File
.
join
(
ENV
[
'HOME'
],
'Library/Caches/CocoaPods'
)),
:max_cache_size
=>
500
,
:aggressive_cache
=>
false
,
'max_cache_size'
=>
500
,
'aggressive_cache'
=>
false
,
}
DEFAULTS
.
each
do
|
key
,
value
|
...
...
@@ -50,9 +50,8 @@ module Pod
@instance
||=
new
end
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?
raise
NoKeyError
,
"Unrecognized keypath for configuration `
#{
keypath
}
`. "
\
"
\n
Supported ones are:
\n
-
#{
DEFAULTS
.
keys
.
join
(
"
\n
- "
)
}
"
...
...
@@ -65,7 +64,6 @@ module Pod
if
value
==
'true'
value
=
true
end
hash
[
keypath
]
=
value
store_configuration
(
hash
)
end
...
...
@@ -74,6 +72,14 @@ module Pod
end
# @group Helpers
#
#
def
verbose?
get_setting
(
'verbose'
)
&&
!
silent?
end
private
def
global_config
...
...
@@ -91,8 +97,8 @@ module Pod
end
def
store_configuration
(
hash
)
@global_config
=
hash
yaml
=
YAML
.
dump
(
hash
)
global_config_filepath
File
.
open
(
global_config_filepath
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
end
...
...
@@ -100,23 +106,14 @@ module Pod
# @return [Pathname] The path of the file which contains the user settings.
#
def
global_config_filepath
home_dir
+
"config.yaml"
Config
::
ConfigEnvironment
.
instance
.
home_dir
+
"config.yaml"
end
def
local_config_filepath
end
# @return [Pathname] the directory where repos, templates and configuration
# 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
)
def
value_from_env
(
keypath
)
value
=
ENV
[
"CP_
#{
keypath
.
upcase
}
"
]
if
value
==
'TRUE'
true
...
...
@@ -130,3 +127,4 @@ module Pod
end
end
lib/cocoapods/config/environment.rb
0 → 100644
View file @
d1cf0b99
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
lib/cocoapods/executable.rb
View file @
d1cf0b99
...
...
@@ -13,6 +13,8 @@ module Pod
#
module
Executable
extend
Pod
::
Config
::
Manager
# Creates the methods for the executable with the given name.
#
# @param [Symbol] name
...
...
@@ -59,7 +61,7 @@ module Pod
full_command
=
"
#{
bin
}
#{
command
}
"
if
Config
.
instance
.
verbose?
if
config
.
verbose?
UI
.
message
(
"$
#{
full_command
}
"
)
stdout
,
stderr
=
Indenter
.
new
(
STDOUT
),
Indenter
.
new
(
STDERR
)
else
...
...
lib/cocoapods/external_sources.rb
View file @
d1cf0b99
...
...
@@ -136,7 +136,7 @@ module Pod
UI
.
titled_section
(
"Pre-downloading: `
#{
name
}
`
#{
description
}
"
,
{
:verbose_prefix
=>
"-> "
})
do
target
=
sandbox
.
root
+
name
target
.
rmtree
if
target
.
exist?
downloader
=
Config
.
instance
.
downloader
(
target
,
params
)
downloader
=
Config
::
downloader
(
target
,
params
)
downloader
.
download
store_podspec
(
sandbox
,
target
+
"
#{
name
}
.podspec"
)
sandbox
.
store_pre_downloaded_pod
(
name
)
...
...
lib/cocoapods/installer.rb
View file @
d1cf0b99
...
...
@@ -36,10 +36,9 @@ module Pod
autoload
:PodTargetInstaller
,
'cocoapods/installer/target_installer/pod_target_installer'
autoload
:UserProjectIntegrator
,
'cocoapods/installer/user_project_integrator'
# include Config::Mixin
def
config
Config
::
ConfigManager
.
instance
end
include
Config
::
Manager
include
Config
::
Environment
# @return [Sandbox] The sandbox where the Pods should be installed.
#
...
...
@@ -301,8 +300,8 @@ module Pod
@pods_project
.
add_pod_group
(
pod_name
,
path
,
local
)
end
if
config
.
podfile_path
@pods_project
.
add_podfile
(
config
.
podfile_path
)
if
environment
.
podfile_path
@pods_project
.
add_podfile
(
environment
.
podfile_path
)
end
sandbox
.
project
=
@pods_project
...
...
@@ -417,8 +416,8 @@ module Pod
# checkout_options = sandbox.checkout_options
@lockfile
=
Lockfile
.
generate
(
podfile
,
analysis_result
.
specifications
)
UI
.
message
"- Writing Lockfile in
#{
UI
.
path
config
.
lockfile_path
}
"
do
@lockfile
.
write_to_disk
(
config
.
lockfile_path
)
UI
.
message
"- Writing Lockfile in
#{
UI
.
path
environment
.
lockfile_path
}
"
do
@lockfile
.
write_to_disk
(
environment
.
lockfile_path
)
end
UI
.
message
"- Writing Manifest in
#{
UI
.
path
sandbox
.
manifest_path
}
"
do
...
...
@@ -440,7 +439,7 @@ module Pod
#
def
integrate_user_project
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
.
integrate!
end
...
...
lib/cocoapods/installer/analyzer.rb
View file @
d1cf0b99
...
...
@@ -6,7 +6,8 @@ module Pod
#
class
Analyzer
include
Config
::
Mixin
include
Config
::
Manager
include
Config
::
Environment
autoload
:SandboxAnalyzer
,
'cocoapods/installer/analyzer/sandbox_analyzer'
...
...
@@ -179,7 +180,7 @@ module Pod
target
.
user_build_configurations
=
compute_user_build_configurations
(
target_definition
,
native_targets
)
target
.
archs
=
@archs_by_target_def
[
target_definition
]
else
target
.
client_root
=
config
.
installation_root
target
.
client_root
=
environment
.
installation_root
target
.
user_target_uuids
=
[]
target
.
user_build_configurations
=
{}
end
...
...
@@ -339,7 +340,7 @@ module Pod
#
def
compute_user_project_path
(
target_definition
)
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
=
Pathname
.
new
(
path
)
unless
path
.
exist?
...
...
@@ -348,7 +349,7 @@ module Pod
end
else
xcodeprojs
=
Pathname
.
glob
(
config
.
installation_root
+
'*.xcodeproj'
)
xcodeprojs
=
Pathname
.
glob
(
environment
.
installation_root
+
'*.xcodeproj'
)
if
xcodeprojs
.
size
==
1
path
=
xcodeprojs
.
first
else
...
...
@@ -479,6 +480,7 @@ module Pod
project_path
=
compute_user_project_path
(
target_definition
)
user_project
=
Xcodeproj
::
Project
.
open
(
project_path
)
targets
=
compute_user_project_targets
(
target_definition
,
user_project
)
# TODO: this is unused
platform
=
compute_platform_for_target_definition
(
target_definition
,
targets
)
archs
=
compute_archs_for_target_definition
(
target_definition
,
targets
)
@archs_by_target_def
[
target_definition
]
=
archs
...
...
lib/cocoapods/installer/file_references_installer.rb
View file @
d1cf0b99
...
...
@@ -206,3 +206,4 @@ module Pod
end
end
end
lib/cocoapods/project.rb
View file @
d1cf0b99
...
...
@@ -213,3 +213,4 @@ module Pod
end
end
lib/cocoapods/sources_manager.rb
View file @
d1cf0b99
...
...
@@ -6,13 +6,14 @@ module Pod
class
<<
self
include
Config
::
Mixin
include
Config
::
Manager
include
Config
::
Environment
# @return [Source::Aggregate] the aggregate of all the sources known to
# this installation of CocoaPods.
#
def
aggregate
Source
::
Aggregate
.
new
(
config
.
repos_dir
)
Source
::
Aggregate
.
new
(
environment
.
repos_dir
)
end
# @return [Array<Source>] the list of all the sources known to this
...
...
@@ -120,7 +121,7 @@ module Pod
# @return [Pathname] The path where the search index should be stored.
#
def
search_index_path
Config
.
instance
.
search_index_file
environment
.
search_index_file
end
public
...
...
@@ -256,7 +257,7 @@ module Pod
# @return [Pathname] The path of the master repo.
#
def
master_repo_dir
config
.
repos_dir
+
'master'
environment
.
repos_dir
+
'master'
end
# @return [Bool] Checks if the master repo is usable.
...
...
lib/cocoapods/user_interface.rb
View file @
d1cf0b99
...
...
@@ -17,6 +17,9 @@ module Pod
class
<<
self
include
Config
::
Manager
include
Config
::
Environment
attr_accessor
:indentation_level
attr_accessor
:title_level
attr_accessor
:warnings
...
...
@@ -147,7 +150,7 @@ module Pod
#
def
path
(
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
}
`"
else
''
...
...
@@ -279,15 +282,10 @@ module Pod
end
end
def
config
Config
::
ConfigManager
.
instance
end
# @return [bool] whatever ConfigurationManager returns
#
def
verbose?
Config
::
ConfigManager
.
instance
.
verbose?
&&
!
silent?
end
def
silent?
Config
::
ConfigManager
.
instance
.
silent?
config
.
verbose?
end
end
...
...
lib/cocoapods/validator.rb
View file @
d1cf0b99
...
...
@@ -2,16 +2,17 @@ module Pod
# Validates a Specification.
#
# Extends
the Linter from the Core to add additional which require the
# LocalPod and
the
Installer.
# Extends
Linter from Core to add some additional functionality which requires
# LocalPod and Installer.
#
# In detail it checks that
the file patterns defined by the user match
# actually
do
match at least a file and that the Pod builds, by installing
# In detail it checks that
file patterns defined by the user
# actually match at least a file and that the Pod builds, by installing
# it without integration and building the project with xcodebuild.
#
class
Validator
include
Config
::
Mixin
include
Config
::
Manager
include
Config
::
Environment
# @return [Specification::Linter] the linter instance from CocoaPods
# Core.
...
...
@@ -183,13 +184,20 @@ module Pod
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
validation_dir
.
rmtree
if
validation_dir
.
exist?
validation_dir
.
mkpath
@original_config
=
Config
.
instance
.
clone
config
.
installation_root
=
validation_dir
config
.
sandbox_root
=
validation_dir
+
'Pods'
config
.
silent
=
!
config
.
verbose
@original_config
=
config
.
clone
@original_environment
=
environment
.
clone
environment
.
installation_root
=
validation_dir
environment
.
sandbox_root
=
validation_dir
+
'Pods'
config
.
silent
=
!
config
.
verbose?
config
.
integrate_targets
=
false
config
.
skip_repo_update
=
true
end
...
...
@@ -204,7 +212,7 @@ module Pod
#
def
install_pod
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
.
install!
...
...
@@ -213,7 +221,7 @@ module Pod
end
.
flatten
@file_accessor
=
file_accessors
.
find
{
|
accessor
|
accessor
.
spec
.
root
.
name
==
spec
.
root
.
name
}
config
.
silent
#
config.silent
end
# Performs platform specific analysis. It requires to download the source
...
...
@@ -229,7 +237,7 @@ module Pod
UI
.
warn
"Skipping compilation with `xcodebuild' because it can't be found.
\n
"
.
yellow
else
UI
.
message
"
\n
Building with xcodebuild.
\n
"
.
yellow
do
output
=
Dir
.
chdir
(
config
.
sandbox_root
)
{
xcodebuild
}
output
=
Dir
.
chdir
(
environment
.
sandbox_root
)
{
xcodebuild
}
UI
.
puts
output
parsed_output
=
parse_xcodebuild_output
(
output
)
parsed_output
.
each
do
|
message
|
...
...
spec/functional/command/config_spec.rb
View file @
d1cf0b99
...
...
@@ -11,14 +11,14 @@ module Pod
pod_path
=
'~/code/OSS/ObjectiveSugar'
project_name
=
'SampleProject'
before
do
# Dir.stubs(:pwd).returns('~/code/OSS/SampleProject')
@config_file_path
=
temporary_directory
+
'config.yaml'
@config_file_path
=
temporary_directory
+
"mock_config.yaml"
Pod
::
Config
.
instance
.
stubs
(
:user_settings_file
).
returns
(
@config_file_path
)
before
do
FileUtils
.
rm_rf
(
@config_file_path
)
@subject
=
Config
::
ConfigManager
.
new
# TODO: stub the file accessor
end
it
"writes local repos for each project"
do
run_command
(
'config'
,
"--local"
,
pod_name
,
pod_path
)
yaml
=
YAML
.
load
(
File
.
open
(
@config_file_path
))
...
...
@@ -72,16 +72,3 @@ module Pod
end
end
# ===================
# Config file format
# ===================
#
# ---
# LOCAL_OVERRIDES:
# SampleApp:
# ARAnalytics: ~/code/ARAnalytics
#
# GLOBAL_OVERRIDES:
# ObjectiveRecord: ~/code/OSS/ObjectiveRecord
# ObjectiveSugar: ~/code/OSS/ObjectiveSugar
#
spec/spec_helper.rb
View file @
d1cf0b99
...
...
@@ -79,7 +79,8 @@ Bacon.summary_at_exit
module
Bacon
class
Context
include
Pod
::
Config
::
Mixin
include
Pod
::
Config
::
Manager
include
Pod
::
Config
::
Environment
include
SpecHelper
::
Fixture
include
SpecHelper
::
Command
...
...
spec/spec_helper/pre_flight.rb
View file @
d1cf0b99
...
...
@@ -5,16 +5,13 @@ module Bacon
old_run_requirement
=
instance_method
(
:run_requirement
)
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'
)
c
.
installation_root
=
SpecHelper
.
temporary_directory
end
config
.
stubs
(
:silent
).
returns
(
true
)
config
.
stubs
(
'skip_repo_update'
).
returns
(
true
)
::
Pod
::
UI
.
output
=
''
# The following prevents a nasty behaviour where the increments are not
...
...
spec/unit/config/config_manager_spec.rb
View file @
d1cf0b99
...
...
@@ -10,38 +10,42 @@ module Pod
@config_file_path
=
temporary_directory
+
'config.yaml'
before
do
@subject
=
Config
::
ConfigManager
.
instance
@subject
.
stubs
(
:home_dir
).
returns
(
temporary_directory
)
FileUtils
.
rm_rf
(
@config_file_path
)
@subject
=
Config
::
ConfigManager
.
new
end
it
"has a singleton"
do
Config
::
ConfigManager
.
instance
.
should
===
Config
::
ConfigManager
.
instance
end
it
"creates a global config file if one didn't exist"
do
FileUtils
.
rm_rf
(
@config_file_path
)
@subject
.
set_global
(
'verbose'
,
'true'
)
@subject
.
set_global
(
'verbose'
,
true
)
@config_file_path
.
should
.
exist
end
it
"stores a global setting"
do
@subject
.
set_global
(
'verbose'
,
'true'
)
@subject
.
set_global
(
'verbose'
,
true
)
yaml
=
YAML
.
load_file
(
@config_file_path
)
yaml
[
'verbose'
].
should
==
true
end
it
"preserves the existing settings of the configuration file"
do
@subject
.
set_global
(
'silent'
,
'true'
)
@subject
.
set_global
(
'verbose'
,
'true'
)
@subject
.
set_global
(
'silent'
,
true
)
@subject
.
set_global
(
'verbose'
,
true
)
yaml
=
YAML
.
load_file
(
@config_file_path
)
yaml
[
'silent'
].
should
==
true
end
x
it
"allows to store a development pod"
do
it
"allows to store a development pod"
do
@subject
.
set_global
(
'development.ObjectiveSugar'
,
'~/code/OS'
)
yaml
=
YAML
.
load_file
(
@config_file_path
)
yaml
[
'development.ObjectiveSugar'
].
should
==
'~/code/OS'
end
it
"returns a globally decided setting"
do
@subject
.
set_global
(
'
user_name'
,
'Super Marin'
)
@subject
.
get_setting
(
'user_name'
).
should
==
'Super Marin'
@subject
.
set_global
(
'
silent'
,
true
)
@subject
.
should
.
be
.
silent
end
it
"verbose by default is false"
do
...
...
@@ -52,8 +56,15 @@ module Pod
@subject
.
should
.
not
.
be
.
silent
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
@subject
.
should
.
not
.
skip_repo_update
@subject
.
should
.
not
.
skip_repo_update
?
end
it
"clean by default is true"
do
...
...
@@ -68,10 +79,6 @@ module Pod
@subject
.
should
.
new_version_message
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
@subject
.
max_cache_size
.
should
==
500
end
...
...
@@ -87,17 +94,23 @@ module Pod
end
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
ENV
.
delete
(
'CP_AGGRESSIVE_CACHE'
)
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
xit
"writes local repos for each project"
do
@subject
.
set_local
(
'verbose'
,
'true'
)
yaml
[
'verbose'
].
should
==
true
end
end
end
end
spec/unit/config/environment_spec.rb
0 → 100644
View file @
d1cf0b99
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
spec/unit/config_spec.rb
View file @
d1cf0b99
...
...
@@ -3,211 +3,24 @@ require File.expand_path('../../spec_helper', __FILE__)
module
Pod
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
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
.
url
.
should
==
'example.com'
downloader
.
cache_root
.
should
==
@su
t
.
cache_root
downloader
.
cache_root
.
should
==
environmen
t
.
cache_root
downloader
.
max_cache_size
.
should
==
500
downloader
.
aggressive_cache
.
should
.
be
.
false
end
it
"returns the specification statistics provider"
do
stats_provider
=
@sut
.
spec_statistics_provider
stats_provider
.
cache_file
.
should
==
@su
t
.
cache_root
+
'statistics.yml'
stats_provider
=
Config
.
spec_statistics_provider
stats_provider
.
cache_file
.
should
==
environmen
t
.
cache_root
+
'statistics.yml'
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
spec/unit/external_sources_spec.rb
View file @
d1cf0b99
...
...
@@ -42,9 +42,9 @@ module Pod
end
it
"fetches the specification from the remote stores it in the sandbox"
do
config
.
sandbox
.
specification
(
'Reachability'
).
should
==
nil
@external_source
.
fetch
(
config
.
sandbox
)
config
.
sandbox
.
specification
(
'Reachability'
).
name
.
should
==
'Reachability'
environment
.
sandbox
.
specification
(
'Reachability'
).
should
==
nil
@external_source
.
fetch
(
environment
.
sandbox
)
environment
.
sandbox
.
specification
(
'Reachability'
).
name
.
should
==
'Reachability'
end
end
...
...
@@ -54,9 +54,9 @@ module Pod
describe
"Subclasses helpers"
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
)
path
=
config
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
=
environment
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
.
should
.
exist?
sandbox
.
predownloaded_pods
.
should
==
[
"Reachability"
]
sandbox
.
checkout_sources
.
should
==
{
...
...
@@ -81,14 +81,14 @@ module Pod
end
it
"creates a copy of the podspec"
do
@external_source
.
fetch
(
config
.
sandbox
)
path
=
config
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
@external_source
.
fetch
(
environment
.
sandbox
)
path
=
environment
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
.
should
.
exist?
end
it
"marks a LocalPod as downloaded"
do
@external_source
.
fetch
(
config
.
sandbox
)
config
.
sandbox
.
predownloaded_pods
.
should
==
[
"Reachability"
]
@external_source
.
fetch
(
environment
.
sandbox
)
environment
.
sandbox
.
predownloaded_pods
.
should
==
[
"Reachability"
]
end
it
"returns the description"
do
...
...
@@ -106,14 +106,14 @@ module Pod
end
it
"creates a copy of the podspec"
do
@external_source
.
fetch
(
config
.
sandbox
)
path
=
config
.
sandbox
.
root
+
'Local Podspecs/SvnSource.podspec'
@external_source
.
fetch
(
environment
.
sandbox
)
path
=
environment
.
sandbox
.
root
+
'Local Podspecs/SvnSource.podspec'
path
.
should
.
exist?
end
it
"marks a LocalPod as downloaded"
do
@external_source
.
fetch
(
config
.
sandbox
)
config
.
sandbox
.
predownloaded_pods
.
should
==
[
"SvnSource"
]
@external_source
.
fetch
(
environment
.
sandbox
)
environment
.
sandbox
.
predownloaded_pods
.
should
==
[
"SvnSource"
]
end
it
"returns the description"
do
...
...
@@ -131,14 +131,14 @@ module Pod
end
it
"creates a copy of the podspec"
do
@external_source
.
fetch
(
config
.
sandbox
)
path
=
config
.
sandbox
.
root
+
'Local Podspecs/MercurialSource.podspec'
@external_source
.
fetch
(
environment
.
sandbox
)
path
=
environment
.
sandbox
.
root
+
'Local Podspecs/MercurialSource.podspec'
path
.
should
.
exist?
end
it
"marks a LocalPod as downloaded"
do
@external_source
.
fetch
(
config
.
sandbox
)
config
.
sandbox
.
predownloaded_pods
.
should
==
[
"MercurialSource"
]
@external_source
.
fetch
(
environment
.
sandbox
)
environment
.
sandbox
.
predownloaded_pods
.
should
==
[
"MercurialSource"
]
end
it
"returns the description"
do
...
...
@@ -158,8 +158,8 @@ module Pod
end
it
"creates a copy of the podspec"
do
@external_source
.
fetch
(
config
.
sandbox
)
path
=
config
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
@external_source
.
fetch
(
environment
.
sandbox
)
path
=
environment
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
.
should
.
exist?
end
...
...
@@ -207,15 +207,14 @@ module Pod
describe
ExternalSources
::
PathSource
do
before
do
podspec_path
=
fixture
(
'integration/Reachability/Reachability.podspec'
)
dependency
=
Dependency
.
new
(
"Reachability"
,
:path
=>
fixture
(
'integration/Reachability'
))
podfile_path
=
fixture
(
'integration/Podfile'
)
@external_source
=
ExternalSources
.
from_dependency
(
dependency
,
podfile_path
)
end
it
"creates a copy of the podspec"
do
@external_source
.
fetch
(
config
.
sandbox
)
path
=
config
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
@external_source
.
fetch
(
environment
.
sandbox
)
path
=
environment
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
.
should
.
exist?
end
...
...
@@ -223,8 +222,8 @@ module Pod
dependency
=
Dependency
.
new
(
"Reachability"
,
:local
=>
fixture
(
'integration/Reachability'
))
podfile_path
=
fixture
(
'integration/Podfile'
)
external_source
=
ExternalSources
.
from_dependency
(
dependency
,
podfile_path
)
external_source
.
fetch
(
config
.
sandbox
)
path
=
config
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
external_source
.
fetch
(
environment
.
sandbox
)
path
=
environment
.
sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
.
should
.
exist?
end
...
...
@@ -233,8 +232,8 @@ module Pod
end
it
"marks the Pod as local in the sandbox"
do
@external_source
.
fetch
(
config
.
sandbox
)
config
.
sandbox
.
development
_pods
.
should
==
{
@external_source
.
fetch
(
environment
.
sandbox
)
environment
.
sandbox
.
local
_pods
.
should
==
{
"Reachability"
=>
fixture
(
'integration/Reachability'
).
to_s
}
end
...
...
spec/unit/generator/acknowledgements/markdown_spec.rb
View file @
d1cf0b99
...
...
@@ -26,9 +26,9 @@ describe Pod::Generator::Markdown do
end
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
)
expected_path
=
config
.
sandbox
.
root
+
"Pods-acknowledgements.markdown"
expected_path
=
environment
.
sandbox
.
root
+
"Pods-acknowledgements.markdown"
mockFile
=
mock
mockFile
.
expects
(
:write
).
with
(
equals
(
@generator
.
licenses
))
...
...
spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
View file @
d1cf0b99
...
...
@@ -9,10 +9,10 @@ module Pod
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@consumer
=
@spec
.
consumer
(
:ios
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
@target
=
AggregateTarget
.
new
(
target_definition
,
config
.
sandbox
)
@target
.
client_root
=
config
.
sandbox
.
root
.
dirname
@target
=
AggregateTarget
.
new
(
target_definition
,
environment
.
sandbox
)
@target
.
client_root
=
environment
.
sandbox
.
root
.
dirname
@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
(
:spec_consumers
).
returns
([
@consumer
])
@target
.
pod_targets
=
[
@pod_target
]
...
...
@@ -56,7 +56,7 @@ module Pod
end
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
end
...
...
spec/unit/generator/xcconfig/private_pod_xcconfig_spec.rb
View file @
d1cf0b99
...
...
@@ -10,7 +10,7 @@ module Pod
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@consumer
=
@spec
.
consumer
(
:ios
)
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
)
public_xcconfig
=
Xcodeproj
::
Config
.
new
({
"OTHER_LDFLAGS"
=>
"-framework SystemConfiguration"
})
@generator
=
PrivatePodXCConfig
.
new
(
@pod_target
,
public_xcconfig
)
...
...
@@ -45,7 +45,7 @@ module Pod
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
(
'" "'
)
}
\"
"
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
public_headers
end
...
...
spec/unit/generator/xcconfig/public_pod_xcconfig_spec.rb
View file @
d1cf0b99
...
...
@@ -8,7 +8,7 @@ module Pod
before
do
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@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
)
@generator
=
PublicPodXCConfig
.
new
(
@pod_target
)
...
...
@@ -18,7 +18,7 @@ module Pod
@spec
.
weak_frameworks
=
[
'iAd'
]
@spec
.
libraries
=
[
'xml2'
]
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)
@pod_target
.
target_definition
.
stubs
(
:podfile
).
returns
(
@podfile
)
...
...
@@ -65,13 +65,13 @@ module Pod
end
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
.
to_hash
[
"FRAMEWORK_SEARCH_PATHS"
].
should
.
include?
(
'"$(PODS_ROOT)/banana-lib"'
)
end
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
.
to_hash
[
"LIBRARY_SEARCH_PATHS"
].
should
.
include?
(
'"$(PODS_ROOT)/banana-lib"'
)
end
...
...
spec/unit/generator/xcconfig/xcconfig_helper_spec.rb
View file @
d1cf0b99
...
...
@@ -107,26 +107,26 @@ module Pod
describe
"::add_framework_build_settings"
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
@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
[
'OTHER_LDFLAGS'
].
should
==
"-framework Parse"
hash_config
[
'FRAMEWORK_SEARCH_PATHS'
].
should
==
'"$(PODS_ROOT)/Parse"'
end
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'
}
)
@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
[
'OTHER_LDFLAGS'
].
should
==
"-framework CoreAnimation -framework Parse"
end
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"'
}
)
@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
[
'FRAMEWORK_SEARCH_PATHS'
].
should
==
'"path/to/frameworks" "$(PODS_ROOT)/Parse"'
end
...
...
@@ -136,9 +136,9 @@ module Pod
describe
"::add_library_build_settings"
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
@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
[
'OTHER_LDFLAGS'
].
should
==
"-lProj4"
hash_config
[
'LIBRARY_SEARCH_PATHS'
].
should
==
'"$(PODS_ROOT)/MapBox/Proj4"'
...
...
@@ -173,3 +173,4 @@ module Pod
end
end
end
spec/unit/installer/analyzer/sandbox_analyzer_spec.rb
View file @
d1cf0b99
...
...
@@ -7,7 +7,7 @@ module Pod
before
do
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@sandbox
=
config
.
sandbox
@sandbox
=
environment
.
sandbox
lockfile_hash
=
{
'PODS'
=>
[
'BananaLib (1.0)'
]
}
@manifest
=
Pod
::
Lockfile
.
new
(
lockfile_hash
)
@sandbox
.
stubs
(
:manifest
).
returns
(
@manifest
)
...
...
spec/unit/installer/analyzer_spec.rb
View file @
d1cf0b99
...
...
@@ -20,7 +20,7 @@ def create_analyzer
lockfile
=
Pod
::
Lockfile
.
new
(
hash
)
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
#-----------------------------------------------------------------------------#
...
...
@@ -61,13 +61,13 @@ module Pod
#--------------------------------------#
it
"updates the repositories by default"
do
config
.
s
kip_repo_update
=
false
config
.
s
tubs
(
:skip_repo_update
).
returns
(
false
)
SourcesManager
.
expects
(
:update
).
once
@analyzer
.
analyze
end
it
"does not updates the repositories if config indicates to skip them"
do
config
.
s
kip_repo_update
=
true
config
.
s
tubs
(
:skip_repo_update
).
returns
(
true
)
SourcesManager
.
expects
(
:update
).
never
@analyzer
.
analyze
end
...
...
@@ -82,7 +82,7 @@ module Pod
'Pods-SVPullToRefresh'
,
'Pods-libextobjc'
].
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
.
client_root
.
to_s
.
should
.
include
'SampleProject'
...
...
@@ -94,10 +94,10 @@ module Pod
end
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
.
client_root
.
should
==
config
.
installation_root
target
.
client_root
.
should
==
environment
.
installation_root
target
.
user_target_uuids
.
should
==
[]
target
.
user_build_configurations
.
should
==
{}
target
.
platform
.
to_s
.
should
==
'iOS 6.0'
...
...
@@ -215,7 +215,7 @@ module Pod
it
"if not specified in the target definition if looks if there is only one project"
do
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
.
to_s
.
should
.
include
'SampleProject/SampleProject.xcodeproj'
...
...
spec/unit/installer/file_references_installer_spec.rb
View file @
d1cf0b99
...
...
@@ -5,24 +5,24 @@ module Pod
before
do
@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
]
@project
=
Project
.
new
(
config
.
sandbox
.
project_path
)
@project
=
Project
.
new
(
environment
.
sandbox
.
project_path
)
@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
#-------------------------------------------------------------------------#
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
.
expects
(
:read_file_system
)
@installer
.
install!
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!
file_ref
=
@installer
.
pods_project
[
'Pods/BananaLib/Source Files/Banana.m'
]
file_ref
.
should
.
be
.
not
.
nil
...
...
@@ -37,7 +37,7 @@ module Pod
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!
file_ref
=
@installer
.
pods_project
[
'Pods/BananaLib/Resources/logo-sidebar.png'
]
file_ref
.
should
.
be
.
not
.
nil
...
...
@@ -55,7 +55,7 @@ module Pod
it
"links the public headers"
do
@installer
.
install!
headers_root
=
config
.
sandbox
.
public_headers
.
root
headers_root
=
environment
.
sandbox
.
public_headers
.
root
public_header
=
headers_root
+
'BananaLib/Banana.h'
private_header
=
headers_root
+
'BananaLib/BananaPrivate.h'
public_header
.
should
.
exist
...
...
@@ -70,20 +70,20 @@ module Pod
describe
"#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_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'
)]
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
.
should
==
[
fixture
(
'banana-lib'
),
fixture
(
'banana-lib'
)]
end
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
=
[]
installer
=
Installer
::
FileReferencesInstaller
.
new
(
config
.
sandbox
,
[
pod_target_1
],
@project
)
roots
=
installer
.
send
(
:file_accessors
).
should
==
[]
installer
=
Installer
::
FileReferencesInstaller
.
new
(
environment
.
sandbox
,
[
pod_target_1
],
@project
)
installer
.
send
(
:file_accessors
).
should
==
[]
end
end
...
...
@@ -134,4 +134,3 @@ module Pod
end
end
spec/unit/installer/target_installer/aggregate_target_installer_spec.rb
View file @
d1cf0b99
...
...
@@ -9,9 +9,9 @@ module Pod
xcodeproj
'dummy'
end
@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'
))
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
file_accessor
=
Sandbox
::
FileAccessor
.
new
(
path_list
,
@spec
.
consumer
(
:ios
))
...
...
@@ -21,20 +21,20 @@ module Pod
@project
.
add_file_reference
(
file
,
group
)
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
.
user_project_path
=
config
.
sandbox
.
root
+
'../user_project.xcodeproj'
@target
.
client_root
=
config
.
sandbox
.
root
.
dirname
@target
.
user_project_path
=
environment
.
sandbox
.
root
+
'../user_project.xcodeproj'
@target
.
client_root
=
environment
.
sandbox
.
root
.
dirname
@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
.
user_build_configurations
=
@target
.
user_build_configurations
@pod_target
.
file_accessors
=
[
file_accessor
]
@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"'
end
...
...
@@ -114,14 +114,14 @@ module Pod
it
"creates the xcconfig file"
do
@installer
.
install!
file
=
config
.
sandbox
.
root
+
@target
.
xcconfig_path
file
=
environment
.
sandbox
.
root
+
@target
.
xcconfig_path
xcconfig
=
Xcodeproj
::
Config
.
new
(
file
)
xcconfig
.
to_hash
[
'PODS_ROOT'
].
should
==
'${SRCROOT}/Pods'
end
it
"creates a header for the target which contains the information about the installed Pods"
do
@installer
.
install!
file
=
config
.
sandbox
.
root
+
'Pods-environment.h'
file
=
environment
.
sandbox
.
root
+
'Pods-environment.h'
contents
=
file
.
read
contents
.
should
.
include?
(
'#define COCOAPODS_POD_AVAILABLE_BananaLib'
)
contents
.
should
.
include?
(
'#define COCOAPODS_VERSION_MAJOR_BananaLib 1'
)
...
...
@@ -137,7 +137,7 @@ module Pod
it
"creates a create copy resources script"
do
@installer
.
install!
script
=
config
.
sandbox
.
root
+
'Pods-resources.sh'
script
=
environment
.
sandbox
.
root
+
'Pods-resources.sh'
script
.
read
.
should
.
include?
(
'logo-sidebar.png'
)
end
...
...
@@ -151,9 +151,9 @@ module Pod
it
"creates the acknowledgements files "
do
@installer
.
install!
markdown
=
config
.
sandbox
.
root
+
'Pods-acknowledgements.markdown'
markdown
=
environment
.
sandbox
.
root
+
'Pods-acknowledgements.markdown'
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'
)
end
...
...
@@ -163,9 +163,10 @@ module Pod
build_file
=
build_files
.
find
{
|
bf
|
bf
.
file_ref
.
path
.
include?
(
'Pods-dummy.m'
)
}
build_file
.
should
.
be
.
not
.
nil
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'
)
end
end
end
end
spec/unit/installer/target_installer_spec.rb
View file @
d1cf0b99
...
...
@@ -9,9 +9,9 @@ module Pod
xcodeproj
'dummy'
end
@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'
))
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
file_accessor
=
Sandbox
::
FileAccessor
.
new
(
path_list
,
@spec
.
consumer
(
:ios
))
...
...
@@ -21,13 +21,14 @@ module Pod
@project
.
add_file_reference
(
file
,
group
)
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
.
user_build_configurations
=
{
'Debug'
=>
:debug
,
'Release'
=>
:release
,
'AppStore'
=>
:release
,
'Test'
=>
:debug
}
@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
spec/unit/installer/user_project_integrator/target_integrator_spec.rb
View file @
d1cf0b99
...
...
@@ -13,11 +13,11 @@ module Pod
before
do
sample_project_path
=
SpecHelper
.
create_sample_app_copy_from_fixture
(
'SampleProject'
)
@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_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
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
.
client_root
=
sample_project_path
.
dirname
@lib
.
user_target_uuids
=
[
@target
.
uuid
]
...
...
spec/unit/installer/user_project_integrator_spec.rb
View file @
d1cf0b99
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Installer
::
UserProjectIntegrator
do
describe
"In general"
do
...
...
@@ -16,14 +17,14 @@ module Pod
end
end
config
.
sandbox
.
project
=
Project
.
new
(
config
.
sandbox
.
project_path
)
Xcodeproj
::
Project
.
new
(
config
.
sandbox
.
project_path
).
save
@library
=
AggregateTarget
.
new
(
@podfile
.
target_definitions
[
'Pods'
],
config
.
sandbox
)
environment
.
sandbox
.
project
=
Project
.
new
(
environment
.
sandbox
.
project_path
)
Xcodeproj
::
Project
.
new
(
environment
.
sandbox
.
project_path
).
save
@library
=
AggregateTarget
.
new
(
@podfile
.
target_definitions
[
'Pods'
],
environment
.
sandbox
)
@library
.
client_root
=
sample_project_path
.
dirname
@library
.
user_project_path
=
sample_project_path
@library
.
user_target_uuids
=
[
'A346496C14F9BE9A0080D870'
]
empty_library
=
AggregateTarget
.
new
(
@podfile
.
target_definitions
[
:empty
],
config
.
sandbox
)
@integrator
=
Installer
::
UserProjectIntegrator
.
new
(
@podfile
,
config
.
sandbox
,
temporary_directory
,
[
@library
,
empty_library
])
empty_library
=
AggregateTarget
.
new
(
@podfile
.
target_definitions
[
:empty
],
environment
.
sandbox
)
@integrator
=
Installer
::
UserProjectIntegrator
.
new
(
@podfile
,
environment
.
sandbox
,
temporary_directory
,
[
@library
,
empty_library
])
end
#-----------------------------------------------------------------------#
...
...
@@ -140,7 +141,7 @@ module Pod
it
"raises if no workspace could be selected"
do
@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
it
"returns the paths of the user projects"
do
...
...
@@ -159,3 +160,4 @@ module Pod
end
end
end
spec/unit/installer_spec.rb
View file @
d1cf0b99
...
...
@@ -14,7 +14,7 @@ end
# @return [Podfile]
#
def
generate_podfile
(
pods
=
[
'JSONKit'
])
podfile
=
Pod
::
Podfile
.
new
do
Pod
::
Podfile
.
new
do
platform
:ios
xcodeproj
SpecHelper
.
fixture
(
'SampleProject/SampleProject'
),
'Test'
=>
:debug
,
'App Store'
=>
:release
pods
.
each
{
|
name
|
pod
name
}
...
...
@@ -29,8 +29,8 @@ module Pod
before
do
podfile
=
generate_podfile
lockfile
=
generate_lockfile
config
.
integrate_targets
=
false
@installer
=
Installer
.
new
(
config
.
sandbox
,
podfile
,
lockfile
)
config
.
stubs
(
:integrate_targets
).
returns
(
false
)
@installer
=
Installer
.
new
(
environment
.
sandbox
,
podfile
,
lockfile
)
end
#-------------------------------------------------------------------------#
...
...
@@ -76,13 +76,13 @@ module Pod
end
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
.
install!
end
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
.
install!
end
...
...
@@ -130,13 +130,13 @@ module Pod
@analysis_result
=
Installer
::
Analyzer
::
AnalysisResult
.
new
@analysis_result
.
specifications
=
[]
@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
(
:pod_targets
).
returns
(
@pod_targets
)
end
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
|
pods_target
.
build_headers
.
expects
(
:implode!
)
end
...
...
@@ -145,7 +145,7 @@ module Pod
it
"deletes the sources of the removed Pods"
do
@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
)
end
...
...
@@ -175,7 +175,7 @@ module Pod
it
"correctly configures the Pod source installer"
do
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
)
@installer
.
stubs
(
:pod_targets
).
returns
([
pod_target
])
@installer
.
instance_variable_set
(
:@installed_specs
,
[])
...
...
@@ -185,7 +185,7 @@ module Pod
it
"maintains the list of the installed specs"
do
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
)
@installer
.
stubs
(
:pod_targets
).
returns
([
pod_target
,
pod_target
])
@installer
.
instance_variable_set
(
:@installed_specs
,
[])
...
...
@@ -199,7 +199,7 @@ module Pod
describe
"#clean"
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
::
PodSourceInstaller
.
any_instance
.
expects
(
:install!
).
never
end
...
...
@@ -222,14 +222,14 @@ module Pod
end
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
(
:prepare_pods_project
)
@installer
.
pods_project
.
build_configurations
.
map
(
&
:name
).
sort
.
should
==
[
'App Store'
,
'Debug'
,
'Release'
,
'Test'
]
end
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
(
:prepare_pods_project
)
@installer
.
pods_project
.
build_settings
(
'Debug'
)[
"STRIP_INSTALLED_PRODUCT"
].
should
==
"NO"
...
...
@@ -254,8 +254,8 @@ module Pod
end
it
"sets the deployment target for the whole project"
do
pod_target_ios
=
PodTarget
.
new
([],
nil
,
config
.
sandbox
)
pod_target_osx
=
PodTarget
.
new
([],
nil
,
config
.
sandbox
)
pod_target_ios
=
PodTarget
.
new
([],
nil
,
environment
.
sandbox
)
pod_target_osx
=
PodTarget
.
new
([],
nil
,
environment
.
sandbox
)
pod_target_ios
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'6.0'
))
pod_target_osx
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:osx
,
'10.8'
))
@installer
.
stubs
(
:aggregate_targets
).
returns
([
pod_target_ios
,
pod_target_osx
])
...
...
@@ -290,7 +290,7 @@ module Pod
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
:default
,
nil
)
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
(
:pod_targets
).
returns
([
pod_target
])
Installer
::
PodTargetInstaller
.
any_instance
.
expects
(
:install!
)
...
...
@@ -300,7 +300,7 @@ module Pod
it
"skips empty pod targets"
do
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
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
(
:pod_targets
).
returns
([
pod_target
])
Installer
::
PodTargetInstaller
.
any_instance
.
expects
(
:install!
).
never
...
...
@@ -350,7 +350,6 @@ module Pod
end
it
"saves the project to the given path"
do
path
=
temporary_directory
+
'Pods/Pods.xcodeproj'
@installer
.
pods_project
.
expects
(
:save
)
@installer
.
send
(
:write_pod_project
)
end
...
...
@@ -395,17 +394,16 @@ module Pod
it
"links the pod targets with the aggregate integration library target"
do
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
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
.
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
]
project
=
Xcodeproj
::
Project
.
new
(
'path'
)
pods_target
=
project
.
new_target
(
:static_library
,
target
.
name
,
:ios
)
target
.
target
=
pods_target
native_target
=
project
.
new_target
(
:static_library
,
pod_target
.
name
,
:ios
)
pod_target
.
target
=
pods_target
@installer
.
stubs
(
:pods_project
).
returns
(
project
)
...
...
@@ -417,7 +415,7 @@ module Pod
end
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
.
send
(
:integrate_user_project
)
end
...
...
@@ -461,12 +459,10 @@ module Pod
end
it
"calls the hooks in the specs for each target"
do
pod_target_ios
=
PodTarget
.
new
([
@spec
],
nil
,
config
.
sandbox
)
pod_target_osx
=
PodTarget
.
new
([
@spec
],
nil
,
config
.
sandbox
)
pod_target_ios
=
PodTarget
.
new
([
@spec
],
nil
,
environment
.
sandbox
)
pod_target_osx
=
PodTarget
.
new
([
@spec
],
nil
,
environment
.
sandbox
)
pod_target_ios
.
stubs
(
:name
).
returns
(
'label'
)
pod_target_osx
.
stubs
(
:name
).
returns
(
'label'
)
library_ios_rep
=
stub
()
library_osx_rep
=
stub
()
target_installer_data
=
stub
()
@installer
.
stubs
(
:pod_targets
).
returns
([
pod_target_ios
,
pod_target_osx
])
...
...
spec/unit/library_spec.rb
View file @
d1cf0b99
...
...
@@ -7,7 +7,7 @@ module Pod
before
do
@target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
@target_definition
.
link_with_first_target
=
true
@lib
=
AggregateTarget
.
new
(
@target_definition
,
config
.
sandbox
)
@lib
=
AggregateTarget
.
new
(
@target_definition
,
environment
.
sandbox
)
end
it
"returns the target_definition that generated it"
do
...
...
@@ -31,8 +31,8 @@ module Pod
before
do
@target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
@target_definition
.
link_with_first_target
=
true
@lib
=
AggregateTarget
.
new
(
@target_definition
,
config
.
sandbox
)
@lib
.
client_root
=
config
.
sandbox
.
root
.
dirname
@lib
=
AggregateTarget
.
new
(
@target_definition
,
environment
.
sandbox
)
@lib
.
client_root
=
environment
.
sandbox
.
root
.
dirname
end
it
"returns the absolute path of the xcconfig file"
do
...
...
spec/unit/project_spec.rb
View file @
d1cf0b99
...
...
@@ -4,7 +4,7 @@ module Pod
describe
Project
do
before
do
@project
=
Project
.
new
(
config
.
sandbox
.
project_path
)
@project
=
Project
.
new
(
environment
.
sandbox
.
project_path
)
end
#-------------------------------------------------------------------------#
...
...
@@ -137,8 +137,8 @@ module Pod
describe
"#reference_for_path"
do
before
do
@project
.
add_pod_group
(
'BananaLib'
,
config
.
sandbox
.
pod_dir
(
'BananaLib'
),
false
)
@file
=
config
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
"file.m"
@project
.
add_pod_group
(
'BananaLib'
,
environment
.
sandbox
.
pod_dir
(
'BananaLib'
),
false
)
@file
=
environment
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
"file.m"
@group
=
@project
.
group_for_spec
(
'BananaLib'
,
:source_files
)
end
...
...
@@ -167,8 +167,8 @@ module Pod
describe
"#reference_for_path"
do
before
do
@project
.
add_pod_group
(
'BananaLib'
,
config
.
sandbox
.
pod_dir
(
'BananaLib'
),
false
)
@file
=
config
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
"file.m"
@project
.
add_pod_group
(
'BananaLib'
,
environment
.
sandbox
.
pod_dir
(
'BananaLib'
),
false
)
@file
=
environment
.
sandbox
.
pod_dir
(
'BananaLib'
)
+
"file.m"
@group
=
@project
.
group_for_spec
(
'BananaLib'
,
:source_files
)
@project
.
add_file_reference
(
@file
,
@group
)
end
...
...
@@ -179,7 +179,7 @@ module Pod
end
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
.
should
.
be
.
nil
end
...
...
@@ -189,13 +189,12 @@ module Pod
@project
.
reference_for_path
(
'relative/path/to/file.m'
)
end
.
message
.
should
.
match
/Paths must be absolute/
end
end
#----------------------------------------#
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
.
source_tree
.
should
==
'SOURCE_ROOT'
f
.
xc_language_specification_identifier
.
should
==
'xcode.lang.ruby'
...
...
@@ -211,7 +210,7 @@ module Pod
describe
"#spec_group"
do
before
do
@project
.
add_pod_group
(
'JSONKit'
,
config
.
sandbox
.
pod_dir
(
'JSONKit'
))
@project
.
add_pod_group
(
'JSONKit'
,
environment
.
sandbox
.
pod_dir
(
'JSONKit'
))
end
it
"returns the Pod group for root specifications"
do
...
...
spec/unit/resolver_spec.rb
View file @
d1cf0b99
...
...
@@ -9,11 +9,11 @@ module Pod
pod
'BlocksKit'
,
'1.5.2'
end
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
it
"returns the sandbox"
do
@resolver
.
sandbox
.
should
==
config
.
sandbox
@resolver
.
sandbox
.
should
==
environment
.
sandbox
end
it
"returns the podfile"
do
...
...
@@ -50,12 +50,12 @@ module Pod
it
"it resolves specifications from external sources"
do
podspec
=
fixture
(
'integration/Reachability/Reachability.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
platform
:ios
pod
"Reachability"
,
:podspec
=>
podspec
end
resolver
=
Resolver
.
new
(
config
.
sandbox
,
podfile
)
resolver
=
Resolver
.
new
(
environment
.
sandbox
,
podfile
)
resolver
.
resolve
specs
=
resolver
.
specs_by_target
.
values
.
flatten
specs
.
map
(
&
:to_s
).
should
==
[
'Reachability (3.0.0)'
]
...
...
@@ -70,7 +70,7 @@ module Pod
platform
:ios
,
'6.0'
pod
'BlocksKit'
,
'1.5.2'
end
@resolver
=
Resolver
.
new
(
config
.
sandbox
,
@podfile
)
@resolver
=
Resolver
.
new
(
environment
.
sandbox
,
@podfile
)
end
it
"cross resolves dependencies"
do
...
...
@@ -80,7 +80,7 @@ module Pod
pod
'AFQuickLookView'
,
'= 0.1.0'
# requires 'AFNetworking', '>= 0.9.0'
end
resolver
=
Resolver
.
new
(
config
.
sandbox
,
@podfile
)
resolver
=
Resolver
.
new
(
environment
.
sandbox
,
@podfile
)
specs
=
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:to_s
).
sort
specs
.
should
==
[
"AFNetworking (0.9.1)"
,
"AFQuickLookView (0.1.0)"
]
end
...
...
@@ -110,7 +110,7 @@ module Pod
platform
:ios
pod
'RestKit'
,
'0.10.3'
end
resolver
=
Resolver
.
new
(
config
.
sandbox
,
@podfile
)
resolver
=
Resolver
.
new
(
environment
.
sandbox
,
@podfile
)
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
.
should
==
%w{
FileMD5Hash
ISO8601DateFormatter
...
...
@@ -145,8 +145,8 @@ module Pod
fss
.
subspec
'SecondSubSpec'
end
end
config
.
sandbox
.
expects
(
:specification
).
with
(
'MainSpec'
).
returns
(
spec
)
resolver
=
Resolver
.
new
(
config
.
sandbox
,
@podfile
)
environment
.
sandbox
.
expects
(
:specification
).
with
(
'MainSpec'
).
returns
(
spec
)
resolver
=
Resolver
.
new
(
environment
.
sandbox
,
@podfile
)
specs
=
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
specs
.
should
==
%w{ MainSpec/FirstSubSpec MainSpec/FirstSubSpec/SecondSubSpec }
end
...
...
@@ -157,12 +157,12 @@ module Pod
pod
'FileMD5Hash'
pod
'JSONKit'
,
:head
end
resolver
=
Resolver
.
new
(
config
.
sandbox
,
podfile
)
resolver
=
Resolver
.
new
(
environment
.
sandbox
,
podfile
)
filemd5hash
,
jsonkit
=
resolver
.
resolve
.
values
.
first
.
sort_by
(
&
:name
)
filemd5hash
.
version
.
should
.
not
.
be
.
head
jsonkit
.
version
.
should
.
be
.
head
config
.
sandbox
.
head_pod?
(
'FileMD5Hash'
).
should
.
be
.
false
config
.
sandbox
.
head_pod?
(
'JSONKit'
).
should
.
be
.
true
environment
.
sandbox
.
head_pod?
(
'FileMD5Hash'
).
should
.
be
.
false
environment
.
sandbox
.
head_pod?
(
'JSONKit'
).
should
.
be
.
true
end
it
"raises if it finds two conflicting dependencies"
do
...
...
@@ -171,7 +171,7 @@ module Pod
pod
'JSONKit'
,
"1.4"
pod
'JSONKit'
,
"1.5pre"
end
resolver
=
Resolver
.
new
(
config
.
sandbox
,
podfile
)
resolver
=
Resolver
.
new
(
environment
.
sandbox
,
podfile
)
e
=
lambda
{
resolver
.
resolve
}.
should
.
raise
Pod
::
Informative
e
.
message
.
should
.
match
(
/already activated version/
)
end
...
...
@@ -181,12 +181,12 @@ module Pod
platform
:ios
pod
'JSONKit'
,
"<= 1.5pre"
end
resolver
=
Resolver
.
new
(
config
.
sandbox
,
podfile
)
resolver
=
Resolver
.
new
(
environment
.
sandbox
,
podfile
)
version
=
resolver
.
resolve
.
values
.
flatten
.
first
.
version
version
.
to_s
.
should
==
'1.5pre'
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
.
to_s
.
should
==
'1.4'
end
...
...
spec/unit/sources_manager_spec.rb
View file @
d1cf0b99
...
...
@@ -79,7 +79,7 @@ module Pod
describe
"Updating Sources"
do
extend
SpecHelper
::
TemporaryRepos
it
"update source backed by a git repository"
do
it
"update
s
source backed by a git repository"
do
set_up_test_repo
upstream
=
SpecHelper
.
temporary_directory
+
'upstream'
FileUtils
.
cp_r
(
test_repo_path
,
upstream
)
...
...
@@ -89,7 +89,7 @@ module Pod
`git fetch -q`
`git branch --set-upstream master origin/master`
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
)
UI
.
output
.
should
.
match
/Already up-to-date/
...
...
spec/unit/target/aggregate_target_spec.rb
View file @
d1cf0b99
...
...
@@ -6,7 +6,7 @@ module Pod
before
do
@target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
@target_definition
.
link_with_first_target
=
true
@target
=
AggregateTarget
.
new
(
@target_definition
,
config
.
sandbox
)
@target
=
AggregateTarget
.
new
(
@target_definition
,
environment
.
sandbox
)
end
it
"returns the target_definition that generated it"
do
...
...
@@ -30,8 +30,8 @@ module Pod
before
do
@target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
@target_definition
.
link_with_first_target
=
true
@target
=
AggregateTarget
.
new
(
@target_definition
,
config
.
sandbox
)
@target
.
client_root
=
config
.
sandbox
.
root
.
dirname
@target
=
AggregateTarget
.
new
(
@target_definition
,
environment
.
sandbox
)
@target
.
client_root
=
environment
.
sandbox
.
root
.
dirname
end
it
"returns the absolute path of the xcconfig file"
do
...
...
@@ -73,8 +73,8 @@ module Pod
before
do
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
pod_target
=
PodTarget
.
new
([
spec
],
target_definition
,
config
.
sandbox
)
@target
=
AggregateTarget
.
new
(
target_definition
,
config
.
sandbox
)
pod_target
=
PodTarget
.
new
([
spec
],
target_definition
,
environment
.
sandbox
)
@target
=
AggregateTarget
.
new
(
target_definition
,
environment
.
sandbox
)
@target
.
stubs
(
:platform
).
returns
(
:ios
)
@target
.
pod_targets
=
[
pod_target
]
end
...
...
spec/unit/target/pod_target_spec.rb
View file @
d1cf0b99
...
...
@@ -5,7 +5,7 @@ module Pod
before
do
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@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
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment