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
7d7a92b6
Commit
7d7a92b6
authored
Sep 22, 2013
by
Marin Usalj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing tests.. still some places broken
parent
c7d4cb42
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
37 deletions
+57
-37
config_manager.rb
lib/cocoapods/config/config_manager.rb
+9
-0
installer.rb
lib/cocoapods/installer.rb
+4
-1
user_interface.rb
lib/cocoapods/user_interface.rb
+22
-11
config_manager_spec.rb
spec/unit/config/config_manager_spec.rb
+22
-25
No files found.
lib/cocoapods/config/config_manager.rb
View file @
7d7a92b6
...
...
@@ -42,6 +42,15 @@ module Pod
class
NoKeyError
<
ArgumentError
;
end
# @!group Singleton
# @return [Config] the current config instance creating one if needed.
#
def
self
.
instance
@instance
||=
new
end
def
get_setting
(
keypath
)
value
=
global_config
[
keypath
]
||
get_environment
(
keypath
)
||
DEFAULTS
[
keypath
.
to_sym
]
if
value
.
nil?
...
...
lib/cocoapods/installer.rb
View file @
7d7a92b6
...
...
@@ -36,7 +36,10 @@ module Pod
autoload
:PodTargetInstaller
,
'cocoapods/installer/target_installer/pod_target_installer'
autoload
:UserProjectIntegrator
,
'cocoapods/installer/user_project_integrator'
include
Config
::
Mixin
# include Config::Mixin
def
config
Config
::
ConfigManager
.
instance
end
# @return [Sandbox] The sandbox where the Pods should be installed.
#
...
...
lib/cocoapods/user_interface.rb
View file @
7d7a92b6
...
...
@@ -17,8 +17,6 @@ module Pod
class
<<
self
include
Config
::
Mixin
attr_accessor
:indentation_level
attr_accessor
:title_level
attr_accessor
:warnings
...
...
@@ -40,8 +38,9 @@ module Pod
# @todo Refactor to title (for always visible titles like search)
# and sections (titles that represent collapsible sections).
#
def
section
(
title
,
verbose_prefix
=
''
,
relative_indentation
=
0
)
if
config
.
verbose?
if
verbose?
title
(
title
,
verbose_prefix
,
relative_indentation
)
elsif
title_level
<
1
puts
title
...
...
@@ -62,7 +61,7 @@ module Pod
def
titled_section
(
title
,
options
=
{})
relative_indentation
=
options
[
:relative_indentation
]
||
0
verbose_prefix
=
options
[
:verbose_prefix
]
||
''
if
config
.
verbose?
if
verbose?
title
(
title
,
verbose_prefix
,
relative_indentation
)
else
puts
title
...
...
@@ -81,7 +80,7 @@ module Pod
if
(
@treat_titles_as_messages
)
message
(
title
,
verbose_prefix
)
else
title
=
verbose_prefix
+
title
if
config
.
verbose?
title
=
verbose_prefix
+
title
if
verbose?
title
=
"
\n
#{
title
}
"
if
@title_level
<
2
if
(
color
=
@title_colors
[
@title_level
])
title
=
title
.
send
(
color
)
...
...
@@ -106,8 +105,8 @@ module Pod
# @todo Clean interface.
#
def
message
(
message
,
verbose_prefix
=
''
,
relative_indentation
=
2
)
message
=
verbose_prefix
+
message
if
config
.
verbose?
puts_indented
message
if
config
.
verbose?
message
=
verbose_prefix
+
message
if
verbose?
puts_indented
message
if
verbose?
self
.
indentation_level
+=
relative_indentation
yield
if
block_given?
...
...
@@ -121,7 +120,7 @@ module Pod
# Any title printed in the optional block is treated as a message.
#
def
info
(
message
)
indentation
=
config
.
verbose?
?
self
.
indentation_level
:
0
indentation
=
verbose?
?
self
.
indentation_level
:
0
indented
=
wrap_string
(
message
,
" "
*
indentation
)
puts
(
indented
)
...
...
@@ -214,7 +213,7 @@ module Pod
def
print_warnings
STDOUT
.
flush
warnings
.
each
do
|
warning
|
next
if
warning
[
:verbose_only
]
&&
!
config
.
verbose?
next
if
warning
[
:verbose_only
]
&&
!
verbose?
STDERR
.
puts
(
"
\n
[!]
#{
warning
[
:message
]
}
"
.
yellow
)
warning
[
:actions
].
each
do
|
action
|
indented
=
wrap_string
(
action
,
" - "
)
...
...
@@ -231,13 +230,13 @@ module Pod
# prints a message followed by a new line unless config is silent.
#
def
puts
(
message
=
''
)
STDOUT
.
puts
(
message
)
unless
config
.
silent?
STDOUT
.
puts
(
message
)
unless
silent?
end
# prints a message followed by a new line unless config is silent.
#
def
print
(
message
)
STDOUT
.
print
(
message
)
unless
config
.
silent?
STDOUT
.
print
(
message
)
unless
silent?
end
# Stores important warning to the user optionally followed by actions
...
...
@@ -279,6 +278,18 @@ module Pod
txt
.
strip
.
gsub
(
/(.{1,
#{
width
}
})( +|$)\n?|(.{
#{
width
}
})/
,
indent
+
"
\\
1
\\
3
\n
"
)
end
end
def
config
Config
::
ConfigManager
.
instance
end
def
verbose?
Config
::
ConfigManager
.
instance
.
verbose?
&&
!
silent?
end
def
silent?
Config
::
ConfigManager
.
instance
.
silent?
end
end
end
UI
=
UserInterface
...
...
spec/unit/config/config_manager_spec.rb
View file @
7d7a92b6
...
...
@@ -10,94 +10,91 @@ module Pod
@config_file_path
=
temporary_directory
+
'config.yaml'
before
do
@su
t
=
Config
::
ConfigManager
.
new
@sut
.
stubs
(
:home_dir
).
returns
(
temporary_directory
)
@su
bject
=
Config
::
ConfigManager
.
instance
@su
bjec
t
.
stubs
(
:home_dir
).
returns
(
temporary_directory
)
end
it
"creates a global config file if one didn't exist"
do
FileUtils
.
rm_rf
(
@config_file_path
)
@sut
.
set_global
(
'verbose'
,
'true'
)
@su
bjec
t
.
set_global
(
'verbose'
,
'true'
)
@config_file_path
.
should
.
exist
end
it
"stores a global setting"
do
@sut
.
set_global
(
'verbose'
,
'true'
)
@su
bjec
t
.
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
@su
t
.
set_global
(
'user_name'
,
'Super Marin
'
)
@sut
.
set_global
(
'verbose'
,
'true'
)
@su
bject
.
set_global
(
'silent'
,
'true
'
)
@su
bjec
t
.
set_global
(
'verbose'
,
'true'
)
yaml
=
YAML
.
load_file
(
@config_file_path
)
yaml
[
'
user_name'
].
should
==
'Super Marin'
yaml
[
'
silent'
].
should
==
true
end
xit
"allows to store a development pod"
do
@sut
.
set_global
(
'development.ObjectiveSugar'
,
'~/code/OS'
)
@su
bjec
t
.
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
@sut
.
set_global
(
'user_name'
,
'Super Marin'
)
@sut
.
get_setting
(
'user_name'
).
should
==
'Super Marin'
@su
bjec
t
.
set_global
(
'user_name'
,
'Super Marin'
)
@su
bjec
t
.
get_setting
(
'user_name'
).
should
==
'Super Marin'
end
it
"verbose by default is false"
do
@sut
.
should
.
not
.
be
.
verbose
@su
bjec
t
.
should
.
not
.
be
.
verbose
end
it
"silent by default is false"
do
@sut
.
should
.
not
.
be
.
silent
@su
bjec
t
.
should
.
not
.
be
.
silent
end
it
"skips repo update by default is false"
do
@sut
.
should
.
not
.
skip_repo_update
@su
bjec
t
.
should
.
not
.
skip_repo_update
end
it
"clean by default is true"
do
@sut
.
should
.
be
.
clean
@su
bjec
t
.
should
.
be
.
clean
end
it
"integrate_targets by default is true"
do
@sut
.
should
.
integrate_targets
@su
bjec
t
.
should
.
integrate_targets
end
it
"new_version_message by default is true"
do
@sut
.
should
.
new_version_message
@su
bjec
t
.
should
.
new_version_message
end
it
"cache_root returns the cache root by default"
do
@sut
.
cache_root
.
to_s
.
should
.
include
(
'Library/Caches/CocoaPods'
)
@su
bjec
t
.
cache_root
.
to_s
.
should
.
include
(
'Library/Caches/CocoaPods'
)
end
it
"max_cache_size is 500 MB by default"
do
@sut
.
max_cache_size
.
should
==
500
@su
bjec
t
.
max_cache_size
.
should
==
500
end
it
"aggressive_cache is false by default"
do
@sut
.
should
.
not
.
aggressive_cache
@su
bjec
t
.
should
.
not
.
aggressive_cache
end
it
"raises if there is an attempt to access an unrecognized attribute"
do
should
.
raise
Config
::
ConfigManager
::
NoKeyError
do
@sut
.
get_setting
(
'idafjaeilfjoasijfopasdj'
)
@su
bjec
t
.
get_setting
(
'idafjaeilfjoasijfopasdj'
)
end
end
it
"can accept aggressive cache from ENV"
do
ENV
.
stubs
(
:[]
).
returns
(
'TRUE'
)
@sut
.
get_setting
(
'aggressive_cache'
).
should
==
true
@su
bjec
t
.
get_setting
(
'aggressive_cache'
).
should
==
true
end
xit
"it converts string boolean values"
xit
"it support keypath"
# key.keypath = 'my value'
end
xit
"writes local repos for each project"
do
@sut
.
set_local
(
'verbose'
,
'true'
)
@su
bjec
t
.
set_local
(
'verbose'
,
'true'
)
yaml
[
'verbose'
].
should
==
true
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