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
5e592de7
Commit
5e592de7
authored
Sep 18, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UI] Drop UserInterface::Mixin.
parent
9616bc24
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
53 additions
and
93 deletions
+53
-93
cocoapods.rb
lib/cocoapods.rb
+1
-1
git.rb
lib/cocoapods/downloader/git.rb
+5
-6
http.rb
lib/cocoapods/downloader/http.rb
+1
-1
mercurial.rb
lib/cocoapods/downloader/mercurial.rb
+1
-1
subversion.rb
lib/cocoapods/downloader/subversion.rb
+2
-2
executable.rb
lib/cocoapods/executable.rb
+3
-7
installer.rb
lib/cocoapods/installer.rb
+14
-15
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+4
-5
resolver.rb
lib/cocoapods/resolver.rb
+4
-5
user_interface.rb
lib/cocoapods/user_interface.rb
+18
-50
No files found.
lib/cocoapods.rb
View file @
5e592de7
...
...
@@ -41,7 +41,7 @@ module Pod
autoload
:Source
,
'cocoapods/source'
autoload
:Spec
,
'cocoapods/specification'
autoload
:Specification
,
'cocoapods/specification'
autoload
:U
serInterface
,
'cocoapods/user_interface'
autoload
:U
I
,
'cocoapods/user_interface'
autoload
:Version
,
'cocoapods/version'
autoload
:Pathname
,
'pathname'
...
...
lib/cocoapods/downloader/git.rb
View file @
5e592de7
...
...
@@ -7,7 +7,6 @@ module Pod
class
Downloader
class
Git
<
Downloader
include
Config
::
Mixin
include
UserInterface
::
Mixin
executable
:git
...
...
@@ -15,7 +14,7 @@ module Pod
def
download
create_cache
unless
cache_exist?
ui_
title
(
' > Cloning git repo'
,
''
,
3
)
do
UI
.
title
(
' > Cloning git repo'
,
''
,
3
)
do
if
options
[
:tag
]
download_tag
elsif
options
[
:branch
]
...
...
@@ -31,7 +30,7 @@ module Pod
end
def
create_cache
ui_
title
" > Creating cache git repo (
#{
cache_path
}
)"
UI
.
title
" > Creating cache git repo (
#{
cache_path
}
)"
cache_path
.
rmtree
if
cache_path
.
exist?
cache_path
.
mkpath
git!
%Q|clone --mirror "
#{
url
}
" "
#{
cache_path
}
"|
...
...
@@ -43,7 +42,7 @@ module Pod
repos
=
Pathname
.
new
(
caches_dir
).
children
.
select
{
|
c
|
c
.
directory?
}.
sort_by
(
&
:ctime
)
while
caches_size
>=
MAX_CACHE_SIZE
&&
!
repos
.
empty?
dir
=
repos
.
shift
ui_
message
"
#{
'->'
.
yellow
}
Removing git cache for `
#{
origin_url
(
dir
)
}
'"
UI
.
message
"
#{
'->'
.
yellow
}
Removing git cache for `
#{
origin_url
(
dir
)
}
'"
dir
.
rmtree
end
end
...
...
@@ -75,7 +74,7 @@ module Pod
end
def
update_cache
ui_
title
" > Updating cache git repo (
#{
cache_path
}
)"
UI
.
title
" > Updating cache git repo (
#{
cache_path
}
)"
Dir
.
chdir
(
cache_path
)
do
if
git
(
"config core.bare"
).
chomp
==
"true"
git!
"remote update"
...
...
@@ -148,7 +147,7 @@ module Pod
git!
"remote add upstream '
#{
@url
}
'"
# we need to add the original url, not the cache url
git!
"fetch -q upstream"
# refresh the branches
git!
"checkout --track -b activated-pod-commit upstream/
#{
options
[
:branch
]
}
"
# create a new tracking branch
ui_
message
(
"Just downloaded and checked out branch:
#{
options
[
:branch
]
}
from upstream
#{
clone_url
}
"
)
UI
.
message
(
"Just downloaded and checked out branch:
#{
options
[
:branch
]
}
from upstream
#{
clone_url
}
"
)
end
end
...
...
lib/cocoapods/downloader/http.rb
View file @
5e592de7
...
...
@@ -16,7 +16,7 @@ module Pod
def
download
@filename
=
filename_with_type
type
@download_path
=
target_path
+
@filename
ui_
title
(
' > Downloading from HTTP'
,
''
,
3
)
do
UI
.
title
(
' > Downloading from HTTP'
,
''
,
3
)
do
download_file
@download_path
extract_with_type
@download_path
,
type
end
...
...
lib/cocoapods/downloader/mercurial.rb
View file @
5e592de7
...
...
@@ -4,7 +4,7 @@ module Pod
executable
:hg
def
download
ui_
title
(
' > Cloning mercurial repo'
,
''
,
3
)
do
UI
.
title
(
' > Cloning mercurial repo'
,
''
,
3
)
do
if
options
[
:revision
]
download_revision
else
...
...
lib/cocoapods/downloader/subversion.rb
View file @
5e592de7
...
...
@@ -8,13 +8,13 @@ module Pod
end
def
download
ui_
title
(
' > Exporting subversion repo'
,
''
,
3
)
do
UI
.
title
(
' > Exporting subversion repo'
,
''
,
3
)
do
svn!
%|export "#{reference_url}" "#{target_path}"|
end
end
def
download_head
ui_
title
(
' > Exporting subversion repo'
,
''
,
3
)
do
UI
.
title
(
' > Exporting subversion repo'
,
''
,
3
)
do
svn!
%|export "#{trunk_url}" "#{target_path}"|
end
end
...
...
lib/cocoapods/executable.rb
View file @
5e592de7
...
...
@@ -2,9 +2,7 @@ require 'open4'
module
Pod
module
Executable
class
Indenter
<
::
Array
include
UserInterface
::
Mixin
include
Config
::
Mixin
attr_accessor
:indent
...
...
@@ -12,7 +10,7 @@ module Pod
def
initialize
(
io
=
nil
)
@io
=
io
@indent
=
' '
*
U
serInterface
.
instance
.
indentation_level
@indent
=
' '
*
U
I
.
indentation_level
end
def
<<
(
value
)
...
...
@@ -23,7 +21,6 @@ module Pod
end
def
executable
(
name
)
include
UserInterface
::
Mixin
bin
=
`which
#{
name
}
`
.
strip
base_method
=
"base_"
<<
name
.
to_s
define_method
(
base_method
)
do
|
command
,
should_raise
|
...
...
@@ -32,7 +29,7 @@ module Pod
end
full_command
=
"
#{
bin
}
#{
command
}
"
if
Config
.
instance
.
verbose?
ui_
message
(
"$
#{
full_command
}
"
)
UI
.
message
(
"$
#{
full_command
}
"
)
stdout
,
stderr
=
Indenter
.
new
(
STDOUT
),
Indenter
.
new
(
STDERR
)
else
stdout
,
stderr
=
Indenter
.
new
,
Indenter
.
new
...
...
@@ -44,7 +41,7 @@ module Pod
if
should_raise
raise
Informative
,
"
#{
name
}
#{
command
}
\n\n
#{
output
}
"
else
ui_
message
(
"[!] Failed:
#{
full_command
}
"
.
red
)
UI
.
message
(
"[!] Failed:
#{
full_command
}
"
.
red
)
end
end
output
...
...
@@ -58,7 +55,6 @@ module Pod
send
(
base_method
,
command
,
true
)
end
private
name
end
end
...
...
lib/cocoapods/installer.rb
View file @
5e592de7
...
...
@@ -6,7 +6,6 @@ module Pod
autoload
:UserProjectIntegrator
,
'cocoapods/installer/user_project_integrator'
include
Config
::
Mixin
include
UserInterface
::
Mixin
attr_reader
:resolver
,
:sandbox
,
:lockfile
...
...
@@ -51,7 +50,7 @@ module Pod
pods
.
sort_by
{
|
pod
|
pod
.
top_specification
.
name
.
downcase
}.
each
do
|
pod
|
should_install
=
@resolver
.
should_install?
(
pod
.
top_specification
.
name
)
||
!
pod
.
exists?
if
should_install
ui_
title
(
"Installing
#{
pod
}
"
.
green
,
"-> "
.
green
)
do
UI
.
title
(
"Installing
#{
pod
}
"
.
green
,
"-> "
.
green
)
do
unless
pod
.
downloaded?
pod
.
implode
download_pod
(
pod
)
...
...
@@ -64,7 +63,7 @@ module Pod
pod
.
clean!
if
config
.
clean?
end
else
ui_
title
(
"Using
#{
pod
}
"
,
"-> "
.
green
)
UI
.
title
(
"Using
#{
pod
}
"
,
"-> "
.
green
)
end
end
end
...
...
@@ -88,10 +87,10 @@ module Pod
def
generate_docs
(
pod
)
doc_generator
=
Generator
::
Documentation
.
new
(
pod
)
if
(
config
.
generate_docs?
&&
!
doc_generator
.
already_installed?
)
ui_
title
" > Installing documentation"
UI
.
title
" > Installing documentation"
doc_generator
.
generate
(
config
.
doc_install?
)
else
ui_
title
" > Using existing documentation"
UI
.
title
" > Using existing documentation"
end
end
...
...
@@ -99,7 +98,7 @@ module Pod
#
def
remove_deleted_dependencies!
resolver
.
removed_pods
.
each
do
|
pod_name
|
ui_
title
(
"Removing
#{
pod_name
}
"
,
"-> "
.
red
)
do
UI
.
title
(
"Removing
#{
pod_name
}
"
,
"-> "
.
red
)
do
path
=
sandbox
.
root
+
pod_name
path
.
rmtree
if
path
.
exist?
end
...
...
@@ -108,37 +107,37 @@ module Pod
def
install!
@sandbox
.
prepare_for_install
ui_title
"Resolving dependencies of
#{
ui_
path
@podfile
.
defined_in_file
}
"
do
UI
.
title
"Resolving dependencies of
#{
UI
.
path
@podfile
.
defined_in_file
}
"
do
specs_by_target
end
ui_
title
"Removing deleted dependencies"
do
UI
.
title
"Removing deleted dependencies"
do
remove_deleted_dependencies!
end
unless
resolver
.
removed_pods
.
empty?
ui_
title
"Downloading dependencies"
do
UI
.
title
"Downloading dependencies"
do
install_dependencies!
end
ui_
title
(
"Generating support files"
,
''
,
2
)
do
ui_
message
"- Running pre install hooks"
do
UI
.
title
(
"Generating support files"
,
''
,
2
)
do
UI
.
message
"- Running pre install hooks"
do
run_pre_install_hooks
end
ui_
message
(
"- Installing targets"
,
''
,
2
)
do
UI
.
message
(
"- Installing targets"
,
''
,
2
)
do
generate_target_support_files
end
ui_
message
"- Running post install hooks"
do
UI
.
message
"- Running post install hooks"
do
# Post install hooks run _before_ saving of project, so that they can alter it before saving.
run_post_install_hooks
end
ui_message
"- Writing Xcode project file to
#{
ui_
path
@sandbox
.
project_path
}
"
do
UI
.
message
"- Writing Xcode project file to
#{
UI
.
path
@sandbox
.
project_path
}
"
do
project
.
save_as
(
@sandbox
.
project_path
)
end
ui_message
"- Writing lockfile in
#{
ui_
path
config
.
project_lockfile
}
"
do
UI
.
message
"- Writing lockfile in
#{
UI
.
path
config
.
project_lockfile
}
"
do
@lockfile
=
Lockfile
.
generate
(
@podfile
,
specs_by_target
.
values
.
flatten
)
@lockfile
.
write_to_disk
(
config
.
project_lockfile
)
end
...
...
lib/cocoapods/installer/target_installer.rb
View file @
5e592de7
...
...
@@ -2,7 +2,6 @@ module Pod
class
Installer
class
TargetInstaller
include
Config
::
Mixin
include
UserInterface
::
Mixin
attr_reader
:podfile
,
:project
,
:target_definition
,
:target
attr_accessor
:requires_arc
...
...
@@ -99,21 +98,21 @@ module Pod
def
create_files
(
pods
,
sandbox
)
bridge_support_metadata_path
=
sandbox
.
root
+
@target_definition
.
bridge_support_name
ui_message
"- Generating BridgeSupport metadata file at
#{
ui_
path
bridge_support_metadata_path
}
"
do
UI
.
message
"- Generating BridgeSupport metadata file at
#{
UI
.
path
bridge_support_metadata_path
}
"
do
bridge_support_generator_for
(
pods
,
sandbox
).
save_as
(
bridge_support_metadata_path
)
copy_resources_script_for
(
pods
).
resources
<<
@target_definition
.
bridge_support_name
end
if
@podfile
.
generate_bridge_support?
ui_message
"- Generating xcconfig file at
#{
ui_
path
(
sandbox
.
root
+
@target_definition
.
xcconfig_name
)
}
"
do
UI
.
message
"- Generating xcconfig file at
#{
UI
.
path
(
sandbox
.
root
+
@target_definition
.
xcconfig_name
)
}
"
do
xcconfig
.
save_as
(
sandbox
.
root
+
@target_definition
.
xcconfig_name
)
@target_definition
.
xcconfig
=
xcconfig
end
ui_message
"- Generating prefix header at
#{
ui_
path
(
sandbox
.
root
+
@target_definition
.
prefix_header_name
)
}
"
do
UI
.
message
"- Generating prefix header at
#{
UI
.
path
(
sandbox
.
root
+
@target_definition
.
prefix_header_name
)
}
"
do
save_prefix_header_as
(
sandbox
.
root
+
@target_definition
.
prefix_header_name
,
pods
)
end
ui_message
"- Generating copy resources script at
#{
ui_
path
(
sandbox
.
root
+
@target_definition
.
copy_resources_script_name
)
}
"
do
UI
.
message
"- Generating copy resources script at
#{
UI
.
path
(
sandbox
.
root
+
@target_definition
.
copy_resources_script_name
)
}
"
do
copy_resources_script_for
(
pods
).
save_as
(
sandbox
.
root
+
@target_definition
.
copy_resources_script_name
)
end
end
...
...
lib/cocoapods/resolver.rb
View file @
5e592de7
...
...
@@ -3,7 +3,6 @@ require 'colored'
module
Pod
class
Resolver
include
Config
::
Mixin
include
UserInterface
::
Mixin
# @return [Bool] Whether the resolver should find the pods to install or
# the pods to update.
...
...
@@ -70,11 +69,11 @@ module Pod
if
@lockfile
@pods_by_state
=
@lockfile
.
detect_changes_with_podfile
(
podfile
)
ui_
title
(
"Finding added, modified or removed dependencies:"
,
''
,
2
)
do
UI
.
title
(
"Finding added, modified or removed dependencies:"
,
''
,
2
)
do
marks
=
{
:added
=>
"A"
.
green
,
:changed
=>
"M"
.
yellow
,
:removed
=>
"R"
.
red
,
:unchanged
=>
"-"
}
@pods_by_state
.
each
do
|
symbol
,
pod_names
|
pod_names
.
each
do
|
pod_name
|
ui_
message
(
"
#{
marks
[
symbol
]
}
#{
pod_name
}
"
,
''
,
2
)
UI
.
message
(
"
#{
marks
[
symbol
]
}
#{
pod_name
}
"
,
''
,
2
)
end
end
end
if
config
.
verbose?
...
...
@@ -82,7 +81,7 @@ module Pod
end
@podfile
.
target_definitions
.
values
.
each
do
|
target_definition
|
ui_
title
(
"Resolving dependencies for target `
#{
target_definition
.
name
}
' (
#{
target_definition
.
platform
}
):"
,
''
,
2
)
do
UI
.
title
(
"Resolving dependencies for target `
#{
target_definition
.
name
}
' (
#{
target_definition
.
platform
}
):"
,
''
,
2
)
do
@loaded_specs
=
[]
find_dependency_specs
(
@podfile
,
target_definition
.
dependencies
,
target_definition
)
@specs_by_target
[
target_definition
]
=
@cached_specs
.
values_at
(
*
@loaded_specs
).
sort_by
(
&
:name
)
...
...
@@ -183,7 +182,7 @@ module Pod
if
!
update_mode
&&
@pods_to_lock
.
include?
(
dependency
.
name
)
dependency
=
lockfile
.
dependency_for_installed_pod_named
(
dependency
.
name
)
end
ui_
message
(
"-
#{
dependency
}
"
,
''
,
2
)
do
UI
.
message
(
"-
#{
dependency
}
"
,
''
,
2
)
do
set
=
find_cached_set
(
dependency
,
target_definition
.
platform
)
set
.
required_by
(
dependency
,
dependent_specification
.
to_s
)
...
...
lib/cocoapods/user_interface.rb
View file @
5e592de7
module
Pod
class
UserInterface
include
Config
::
Mixin
def
self
.
instance
@instance
||=
new
end
def
initialize
@indentation_level
=
0
@title_level
=
0
@title_colors
=
%w|yellow green|
end
class
<<
self
include
Config
::
Mixin
attr_accessor
:indentation_level
,
:title_level
def
title
(
title
,
verbose_prefix
=
''
)
def
title
(
title
,
verbose_prefix
=
''
,
relative_indentation
=
0
)
if
config
.
verbose?
title
=
"
\n
#{
title
}
"
if
@title_level
<
2
title
=
verbose_prefix
+
title
if
config
.
verbose?
title
=
"
\n
#{
title
}
"
if
@title_level
<
2
if
(
color
=
@title_colors
[
@title_level
])
title
=
title
.
send
(
color
)
end
...
...
@@ -25,11 +20,21 @@ module Pod
elsif
title_level
<
2
puts
title
end
self
.
indentation_level
+=
relative_indentation
self
.
title_level
+=
1
yield
if
block_given?
self
.
indentation_level
-=
relative_indentation
self
.
title_level
-=
1
end
def
message
(
message
,
verbose_prefix
=
''
)
def
message
(
message
,
verbose_prefix
=
''
,
relative_indentation
=
0
)
message
=
verbose_prefix
+
message
if
config
.
verbose?
puts_indented
message
if
config
.
verbose?
self
.
indentation_level
+=
relative_indentation
yield
if
block_given?
self
.
indentation_level
-=
relative_indentation
end
def
puts
(
message
)
...
...
@@ -41,7 +46,7 @@ module Pod
puts
(
indented
)
end
def
ui_
path
(
pathname
)
def
path
(
pathname
)
if
pathname
"`./
#{
pathname
.
relative_path_from
(
config
.
project_podfile
.
dirname
||
Pathname
.
pwd
)
}
'"
else
...
...
@@ -54,44 +59,7 @@ module Pod
width
=
`stty size`
.
split
(
' '
)[
1
].
to_i
-
indent
.
length
txt
.
strip
.
gsub
(
/(.{1,
#{
width
}
})( +|$)\n?|(.{
#{
width
}
})/
,
indent
+
"
\\
1
\\
3
\n
"
)
end
module
Mixin
def
ui_title
(
title
,
verbose_prefix
=
''
,
relative_indentation
=
0
)
UserInterface
.
instance
.
title
(
title
)
UserInterface
.
instance
.
indentation_level
+=
relative_indentation
UserInterface
.
instance
.
title_level
+=
1
yield
if
block_given?
UserInterface
.
instance
.
indentation_level
-=
relative_indentation
UserInterface
.
instance
.
title_level
-=
1
end
def
ui_message
(
message
,
verbose_prefix
=
''
,
relative_indentation
=
0
)
UserInterface
.
instance
.
message
(
message
)
UserInterface
.
instance
.
indentation_level
+=
relative_indentation
yield
if
block_given?
UserInterface
.
instance
.
indentation_level
-=
relative_indentation
end
def
ui_verbose
(
message
)
UserInterface
.
instance
.
puts
(
message
)
end
def
ui_path
(
pathname
)
UserInterface
.
instance
.
ui_path
(
pathname
)
end
# def ui_spec(spec)
# end
# def ui_progress_start(count)
# end
# def ui_progress_increase(message = nil, ammount = 1)
# end
# def ui_progress_complete()
# end
end
end
UI
=
UserInterface
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