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
6943b6d5
Commit
6943b6d5
authored
Sep 19, 2013
by
Fabio Pelosin + Marin Usalj
Committed by
Marin Usalj
Oct 11, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
will introduce convenience methods instead of accessing hash
parent
8928250b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
247 deletions
+21
-247
config.rb
lib/cocoapods/config.rb
+0
-174
config_manager.rb
lib/cocoapods/config/config_manager.rb
+11
-13
pre_flight.rb
spec/spec_helper/pre_flight.rb
+5
-3
config_manager_spec.rb
spec/unit/config/config_manager_spec.rb
+5
-29
config_spec.rb
spec/unit/config_spec.rb
+0
-28
No files found.
lib/cocoapods/config.rb
View file @
6943b6d5
...
@@ -6,139 +6,6 @@ module Pod
...
@@ -6,139 +6,6 @@ module Pod
autoload
:ConfigManager
,
'cocoapods/config/config_manager'
autoload
:ConfigManager
,
'cocoapods/config/config_manager'
# The default settings for the configuration.
#
# Users can specify custom settings in `~/.cocoapods/config.yaml`.
# An example of the contents of this file might look like:
#
# ---
# skip_repo_update: true
# new_version_message: false
#
DEFAULTS
=
{
:verbose
=>
false
,
:silent
=>
false
,
:skip_repo_update
=>
false
,
: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
,
}
public
#-------------------------------------------------------------------------#
# @!group UI
# @return [Bool] Whether CocoaPods should provide detailed output about the
# performed actions.
#
attr_accessor
:verbose
alias_method
:verbose?
,
:verbose
# @return [Bool] Whether CocoaPods should produce not output.
#
attr_accessor
:silent
alias_method
:silent?
,
:silent
# @return [Bool] Whether a message should be printed when a new version of
# CocoaPods is available.
#
attr_accessor
:new_version_message
alias_method
:new_version_message?
,
:new_version_message
#-------------------------------------------------------------------------#
# @!group Installation
# @return [Bool] Whether the installer should clean after the installation.
#
attr_accessor
:clean
alias_method
:clean?
,
:clean
# @return [Bool] Whether CocoaPods should integrate a user target and build
# the workspace or just create the Pods project.
#
attr_accessor
:integrate_targets
alias_method
:integrate_targets?
,
:integrate_targets
# @return [Bool] Whether the installer should skip the repos update.
#
attr_accessor
:skip_repo_update
alias_method
:skip_repo_update?
,
:skip_repo_update
public
#-------------------------------------------------------------------------#
# @!group Cache
# @return [Fixnum] The maximum size for the cache expressed in Mb.
#
attr_accessor
:max_cache_size
# @return [Pathname] The directory where CocoaPods should cache remote data
# and other expensive to compute information.
#
attr_accessor
:cache_root
def
cache_root
@cache_root
.
mkpath
unless
@cache_root
.
exist?
@cache_root
end
# Allows to set whether the downloader should use more aggressive caching
# options.
#
# @note The aggressive cache has lead to issues if a tag is updated to
# point to another commit.
#
attr_writer
:aggressive_cache
# @return [Bool] Whether the downloader should use more aggressive caching
# options.
#
def
aggressive_cache?
@aggressive_cache
||
(
ENV
[
'CP_AGGRESSIVE_CACHE'
]
==
'TRUE'
)
end
# def aggressive_cache?
# @aggressive_cache? || (parent.aggressive_cache? if parent)
# end
# pod config verbose true --global
# pod config verbose true
# pod config unset verbose
# pod config get verbose
#
# pod config # defaults to show
#
# ~/.cocoapods/config.yaml
# ~/code/OSS/AwesomeApp/Pods/config.yaml
#
# load the configuration file (path is returned by the manager)
# convert to hash
# user_config? BOOL
# keypath STRING
# value STRING
# manager = Config::ConfigManager.new
# manager.set_local(keypath, value)
# manager.unset_local(keypath)
# manager.set_global(keypath, value)
# manager.unset_global(keypath)
public
public
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
@@ -357,47 +224,6 @@ module Pod
...
@@ -357,47 +224,6 @@ module Pod
#
#
#
#
LOCAL_OVERRIDES
=
'PER_PROJECT_REPO_OVERRIDES'
GLOBAL_OVERRIDES
=
'GLOBAL_REPO_OVERRIDES'
def
store_global
(
pod_name
,
pod_path
)
config_hash
[
GLOBAL_OVERRIDES
]
||=
{}
config_hash
[
GLOBAL_OVERRIDES
][
pod_name
]
=
pod_path
end
def
store_local
(
pod_name
,
pod_path
)
config_hash
[
LOCAL_OVERRIDES
]
||=
{}
config_hash
[
LOCAL_OVERRIDES
][
project_name
]
||=
{}
config_hash
[
LOCAL_OVERRIDES
][
project_name
][
pod_name
]
=
pod_path
end
def
delete_local
(
pod_name
)
config_hash
[
LOCAL_OVERRIDES
]
||=
{}
config_hash
[
LOCAL_OVERRIDES
][
project_name
].
delete
(
pod_name
)
end
def
delete_global
(
pod_name
)
config_hash
[
GLOBAL_OVERRIDES
]
||=
{}
config_hash
[
GLOBAL_OVERRIDES
].
delete
(
pod_name
)
end
def
config_hash
@config_hash
||=
load_config
end
def
load_config
FileUtils
.
touch
(
user_settings_file
)
unless
File
.
exists?
user_settings_file
YAML
.
load
(
File
.
open
(
user_settings_file
))
||
{}
end
def
project_name
`basename
#{
Dir
.
pwd
}
`
.
chomp
end
def
write_config_to_file
File
.
open
(
user_settings_file
,
'w'
)
{
|
f
|
f
.
write
(
config_hash
.
delete_blank
.
to_yaml
)
}
end
public
public
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
...
lib/cocoapods/config/config_manager.rb
View file @
6943b6d5
...
@@ -34,12 +34,9 @@ module Pod
...
@@ -34,12 +34,9 @@ module Pod
class
NoKeyError
<
ArgumentError
;
end
class
NoKeyError
<
ArgumentError
;
end
def
initialize
()
end
def
get_setting
(
keypath
)
def
get_setting
(
keypath
)
value
=
global_config
[
keypath
]
||
DEFAULTS
[
keypath
.
to_sym
]
value
=
global_config
[
keypath
]
||
get_environment
(
keypath
)
||
DEFAULTS
[
keypath
.
to_sym
]
if
value
.
nil?
if
value
.
nil?
raise
NoKeyError
,
"Unrecognized keypath for configuration `
#{
keypath
}
`. "
\
raise
NoKeyError
,
"Unrecognized keypath for configuration `
#{
keypath
}
`. "
\
"
\n
Supported ones are:
\n
-
#{
DEFAULTS
.
keys
.
join
(
"
\n
- "
)
}
"
"
\n
Supported ones are:
\n
-
#{
DEFAULTS
.
keys
.
join
(
"
\n
- "
)
}
"
...
@@ -61,12 +58,6 @@ module Pod
...
@@ -61,12 +58,6 @@ module Pod
end
end
# def set_local(keypath, value)
# end
# def unset_local(keypath)
# end
private
private
def
global_config
def
global_config
...
@@ -75,7 +66,7 @@ module Pod
...
@@ -75,7 +66,7 @@ module Pod
# @return [Hash]
# @return [Hash]
#
#
def
load_configuration
()
def
load_configuration
if
global_config_filepath
.
exist?
if
global_config_filepath
.
exist?
YAML
.
load_file
(
global_config_filepath
)
YAML
.
load_file
(
global_config_filepath
)
else
else
...
@@ -89,8 +80,6 @@ module Pod
...
@@ -89,8 +80,6 @@ module Pod
File
.
open
(
global_config_filepath
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
File
.
open
(
global_config_filepath
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
end
end
def
set_keypath
(
keypath
,
value
,
hash
)
end
# @return [Pathname] The path of the file which contains the user settings.
# @return [Pathname] The path of the file which contains the user settings.
#
#
...
@@ -111,6 +100,15 @@ module Pod
...
@@ -111,6 +100,15 @@ module Pod
@home_dir
||=
Pathname
.
new
(
"~/.cocoapods"
).
expand_path
@home_dir
||=
Pathname
.
new
(
"~/.cocoapods"
).
expand_path
end
end
def
get_environment
(
keypath
)
value
=
ENV
[
"CP_
#{
keypath
.
upcase
}
"
]
if
value
==
'TRUE'
true
else
false
end
end
end
end
end
end
...
...
spec/spec_helper/pre_flight.rb
View file @
6943b6d5
...
@@ -7,11 +7,13 @@ module Bacon
...
@@ -7,11 +7,13 @@ module Bacon
define_method
(
:run_requirement
)
do
|
description
,
spec
|
define_method
(
:run_requirement
)
do
|
description
,
spec
|
::
Pod
::
Config
.
instance
=
nil
::
Pod
::
Config
.
instance
=
nil
::
Pod
::
Config
.
instance
.
tap
do
|
c
|
::
Pod
::
Config
.
instance
.
tap
do
|
c
|
c
.
verbose
=
false
# c.verbose = false
c
.
silent
=
true
# c.silent = true
# c.skip_repo_update = true
c
.
repos_dir
=
fixture
(
'spec-repos'
)
c
.
repos_dir
=
fixture
(
'spec-repos'
)
c
.
installation_root
=
SpecHelper
.
temporary_directory
c
.
installation_root
=
SpecHelper
.
temporary_directory
c
.
skip_repo_update
=
true
end
end
::
Pod
::
UI
.
output
=
''
::
Pod
::
UI
.
output
=
''
...
...
spec/unit/config/config_manager_spec.rb
View file @
6943b6d5
...
@@ -5,14 +5,6 @@ module Pod
...
@@ -5,14 +5,6 @@ module Pod
describe
Config
::
ConfigManager
do
describe
Config
::
ConfigManager
do
# manager = Config::ConfigManager.new
# manager.set_local(keypath, value)
# manager.unset_local(keypath)
# manager.set_global(keypath, value)
# manager.unset_global(keypath)
describe
"global"
do
describe
"global"
do
@config_file_path
=
temporary_directory
+
'config.yaml'
@config_file_path
=
temporary_directory
+
'config.yaml'
...
@@ -94,6 +86,11 @@ module Pod
...
@@ -94,6 +86,11 @@ module Pod
end
end
end
end
it
"can accept aggressive cache from ENV"
do
ENV
.
stubs
(
:[]
).
returns
(
'TRUE'
)
@sut
.
get_setting
(
'aggressive_cache'
).
should
==
true
end
xit
"it converts string boolean values"
xit
"it converts string boolean values"
xit
"it support keypath"
xit
"it support keypath"
# key.keypath = 'my value'
# key.keypath = 'my value'
...
@@ -104,27 +101,6 @@ module Pod
...
@@ -104,27 +101,6 @@ module Pod
yaml
[
'verbose'
].
should
==
true
yaml
[
'verbose'
].
should
==
true
end
end
xit
"works with ENV"
do
end
xit
"writes global repos without specifying project"
do
run_command
(
'config'
,
"--global"
,
pod_name
,
pod_path
)
yaml
=
YAML
.
load
(
File
.
open
(
@config_file_path
))
yaml
[
GLOBAL_OVERRIDES
][
pod_name
].
should
.
equal
pod_path
end
xit
"deletes global configuration"
do
run_command
(
'config'
,
"--global"
,
pod_name
,
pod_path
)
run_command
(
'config'
,
"--global"
,
"--delete"
,
pod_name
)
yaml
=
YAML
.
load
(
File
.
open
(
@config_file_path
))
yaml
.
should
.
not
.
has_key?
GLOBAL_OVERRIDES
end
end
end
end
end
spec/unit/config_spec.rb
View file @
6943b6d5
...
@@ -140,34 +140,6 @@ module Pod
...
@@ -140,34 +140,6 @@ module Pod
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
describe
"Default settings"
do
it
"prints out normal information"
do
@sut
.
should
.
not
.
be
.
silent
end
it
"does not print verbose information"
do
@sut
.
should
.
not
.
be
.
verbose
end
it
"cleans SCM dirs in dependency checkouts"
do
@sut
.
should
.
clean
end
it
"has a default cache size of 500"
do
@sut
.
max_cache_size
.
should
==
500
end
it
"returns the cache root"
do
@sut
.
cache_root
.
should
==
Pathname
.
new
(
File
.
join
(
ENV
[
'HOME'
],
'Library/Caches/CocoaPods'
))
end
it
"doesn't use aggressive cache"
do
@sut
.
should
.
not
.
aggressive_cache?
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
describe
"Dependency Injection"
do
describe
"Dependency Injection"
do
...
...
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