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
76cb703e
Commit
76cb703e
authored
Sep 19, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UI] Adoption in Pod::Command classes.
parent
9aeeb74f
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
335 additions
and
285 deletions
+335
-285
cocoapods.rb
lib/cocoapods.rb
+0
-1
command.rb
lib/cocoapods/command.rb
+2
-2
list.rb
lib/cocoapods/command/list.rb
+16
-11
presenter.rb
lib/cocoapods/command/presenter.rb
+0
-61
cocoa_pod.rb
lib/cocoapods/command/presenter/cocoa_pod.rb
+0
-118
push.rb
lib/cocoapods/command/push.rb
+7
-8
repo.rb
lib/cocoapods/command/repo.rb
+9
-9
search.rb
lib/cocoapods/command/search.rb
+6
-4
setup.rb
lib/cocoapods/command/setup.rb
+2
-2
spec.rb
lib/cocoapods/command/spec.rb
+8
-8
git.rb
lib/cocoapods/downloader/git.rb
+3
-3
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
installer.rb
lib/cocoapods/installer.rb
+9
-9
resolver.rb
lib/cocoapods/resolver.rb
+2
-2
user_interface.rb
lib/cocoapods/user_interface.rb
+100
-11
ui_pod.rb
lib/cocoapods/user_interface/ui_pod.rb
+116
-0
list_spec.rb
spec/functional/command/list_spec.rb
+2
-2
push_spec.rb
spec/functional/command/push_spec.rb
+2
-2
repo_spec.rb
spec/functional/command/repo_spec.rb
+1
-1
setup_spec.rb
spec/functional/command/setup_spec.rb
+4
-5
spec_spec.rb
spec/functional/command/spec_spec.rb
+3
-3
user_interface_spec.rb
spec/functional/user_interface_spec.rb
+10
-10
spec_helper.rb
spec/spec_helper.rb
+1
-0
command.rb
spec/spec_helper/command.rb
+15
-9
user_interface.rb
spec/spec_helper/user_interface.rb
+13
-0
No files found.
lib/cocoapods.rb
View file @
76cb703e
...
...
@@ -7,7 +7,6 @@ require 'rubygems'
#
# E.g. https://github.com/CocoaPods/CocoaPods/issues/398
unless
Gem
::
Version
::
Requirement
.
new
(
'>= 1.4.0'
).
satisfied_by?
(
Gem
::
Version
.
new
(
Gem
::
VERSION
))
require
'colored'
STDERR
.
puts
"Your RubyGems version (
#{
Gem
::
VERSION
}
) is too old, please update with: `gem update --system`"
.
red
exit
1
end
...
...
lib/cocoapods/command.rb
View file @
76cb703e
...
...
@@ -7,7 +7,6 @@ module Pod
autoload
:List
,
'cocoapods/command/list'
autoload
:Linter
,
'cocoapods/command/linter'
autoload
:Outdated
,
'cocoapods/command/outdated'
autoload
:Presenter
,
'cocoapods/command/presenter'
autoload
:Push
,
'cocoapods/command/push'
autoload
:Repo
,
'cocoapods/command/repo'
autoload
:Search
,
'cocoapods/command/search'
...
...
@@ -74,6 +73,7 @@ module Pod
Setup
.
new
(
ARGV
.
new
).
run_if_needed
end
sub_command
.
run
UI
.
puts
rescue
Interrupt
puts
"[!] Cancelled"
.
red
...
...
@@ -145,7 +145,7 @@ module Pod
def
update_spec_repos_if_necessary!
if
@update_repo
UI
.
title
'Updating Spec Repositories'
do
UI
.
section
'Updating Spec Repositories'
do
Repo
.
new
(
ARGV
.
new
([
"update"
])).
run
end
end
...
...
lib/cocoapods/command/list.rb
View file @
76cb703e
...
...
@@ -14,23 +14,26 @@ module Pod
end
def
self
.
options
[[
"--update"
,
"Run `pod repo update` before listing"
]].
concat
(
Presenter
.
options
).
concat
(
super
)
[[
"--update"
,
"Run `pod repo update` before listing"
,
"--stats"
,
"Show additional stats (like GitHub watchers and forks)"
]].
concat
(
super
)
end
extend
Executable
executable
:git
def
initialize
(
argv
)
@update
=
argv
.
option
(
'--update'
)
@
new
=
argv
.
option
(
'new
'
)
@
presenter
=
Presenter
.
new
(
argv
)
@update
=
argv
.
option
(
'--update'
)
@
stats
=
argv
.
option
(
'--stats
'
)
@
new
=
argv
.
option
(
'new'
)
super
unless
argv
.
empty?
end
def
list_all
sets
=
Source
.
all_sets
sets
.
each
{
|
s
|
puts
@presenter
.
describe
(
s
)
}
puts
"
\n
#{
sets
.
count
}
pods were found"
sets
.
each
{
|
set
|
UI
.
pod
(
set
,
:name
)
}
UI
.
puts
"
\n
#{
sets
.
count
}
pods were found"
end
def
list_new
...
...
@@ -53,16 +56,18 @@ module Pod
days
.
reverse
.
each
do
|
d
|
sets
=
groups
[
d
]
next
unless
sets
puts
"
\n
Pods added in the last
#{
d
==
1
?
'day'
:
"
#{
d
}
days"
}
"
.
yellow
sets
.
sort_by
{
|
s
|
creation_dates
[
s
.
name
]}.
each
{
|
s
|
puts
@presenter
.
describe
(
s
)}
UI
.
section
(
"
\n
Pods added in the last
#{
d
==
1
?
'day'
:
"
#{
d
}
days"
}
"
.
yellow
)
do
sorted
=
sets
.
sort_by
{
|
s
|
creation_dates
[
s
.
name
]}
sorted
.
each
{
|
set
|
UI
.
pod
(
set
,
(
@stats
?
:
stats
:
:name
))
}
end
end
end
def
run
puts
"
\n
Updating Spec Repositories
\n
"
.
yellow
if
@update
&&
config
.
verbose?
Repo
.
new
(
ARGV
.
new
([
"update"
])).
run
if
@update
UI
.
section
(
"
\n
Updating Spec Repositories
\n
"
.
yellow
)
do
Repo
.
new
(
ARGV
.
new
([
"update"
])).
run
end
if
@update
&&
config
.
verbose?
@new
?
list_new
:
list_all
puts
end
end
end
...
...
lib/cocoapods/command/presenter.rb
deleted
100644 → 0
View file @
9aeeb74f
module
Pod
class
Command
class
Presenter
def
self
.
options
[[
"--stats"
,
"Show additional stats (like GitHub watchers and forks)"
]]
end
autoload
:CocoaPod
,
'cocoapods/command/presenter/cocoa_pod'
def
initialize
(
argv
)
@stats
=
argv
.
option
(
'--stats'
)
end
def
render
(
array
)
result
=
"
\n
"
seats
.
each
{
|
s
|
puts
describe
(
s
)}
result
end
def
describe
(
set
)
pod
=
CocoaPod
.
new
(
set
)
result
=
"
\n
-->
#{
pod
.
name
}
(
#{
pod
.
versions
}
)
\n
"
.
green
result
<<
wrap_string
(
pod
.
summary
)
result
<<
detail
(
'Homepage'
,
pod
.
homepage
)
result
<<
detail
(
'Source'
,
pod
.
source_url
)
if
@stats
result
<<
detail
(
'Pushed'
,
pod
.
github_last_activity
)
result
<<
detail
(
'Authors'
,
pod
.
authors
)
if
pod
.
authors
=~
/,/
result
<<
detail
(
'Author'
,
pod
.
authors
)
if
pod
.
authors
!~
/,/
result
<<
detail
(
'License'
,
pod
.
license
)
result
<<
detail
(
'Platform'
,
pod
.
platform
)
result
<<
detail
(
'Watchers'
,
pod
.
github_watchers
)
result
<<
detail
(
'Forks'
,
pod
.
github_forks
)
end
result
<<
detail
(
'Sub specs'
,
pod
.
subspecs
)
result
end
private
# adapted from http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
def
wrap_string
(
txt
,
col
=
80
,
indentation
=
4
)
indent
=
' '
*
indentation
txt
.
strip
.
gsub
(
/(.{1,
#{
col
}
})( +|$)\n?|(.{
#{
col
}
})/
,
indent
+
"
\\
1
\\
3
\n
"
)
end
def
detail
(
title
,
value
)
return
''
if
!
value
''
.
tap
do
|
t
|
t
<<
" -
#{
title
}
:"
.
ljust
(
16
)
if
value
.
class
==
Array
separator
=
"
\n
- "
t
<<
separator
<<
value
.
join
(
separator
)
else
t
<<
value
.
to_s
<<
"
\n
"
end
end
end
end
end
end
lib/cocoapods/command/presenter/cocoa_pod.rb
deleted
100644 → 0
View file @
9aeeb74f
require
'active_support/core_ext/array/conversions'
module
Pod
class
Command
class
Presenter
class
CocoaPod
attr_accessor
:set
def
initialize
(
set
)
@set
=
set
end
# set information
def
name
@set
.
name
end
def
version
@set
.
versions
.
last
end
def
versions
@set
.
versions
.
reverse
.
join
(
", "
)
end
# specification information
def
spec
@set
.
specification
end
def
authors
spec
.
authors
.
keys
.
to_sentence
end
def
homepage
spec
.
homepage
end
def
description
spec
.
description
end
def
summary
spec
.
summary
end
def
source_url
spec
.
source
.
reject
{
|
k
,
_
|
k
==
:commit
||
k
==
:tag
}.
values
.
first
end
def
platform
spec
.
available_platforms
.
sort
{
|
a
,
b
|
a
.
to_s
.
downcase
<=>
b
.
to_s
.
downcase
}.
join
(
' - '
)
end
def
license
spec
.
license
[
:type
]
if
spec
.
license
end
# will return array of all subspecs (recursevly) or nil
def
subspecs
(
spec
.
recursive_subspecs
.
any?
&&
spec
.
recursive_subspecs
)
||
nil
end
# Statistics information
def
creation_date
Pod
::
Specification
::
Statistics
.
instance
.
creation_date
(
@set
)
end
def
github_watchers
Pod
::
Specification
::
Statistics
.
instance
.
github_watchers
(
@set
)
end
def
github_forks
Pod
::
Specification
::
Statistics
.
instance
.
github_forks
(
@set
)
end
def
github_last_activity
distance_from_now_in_words
(
Pod
::
Specification
::
Statistics
.
instance
.
github_pushed_at
(
@set
))
end
def
==
(
other
)
self
.
class
===
other
&&
@set
==
other
.
set
end
def
eql?
(
other
)
self
.
class
===
other
&&
name
.
eql?
(
other
.
name
)
end
def
hash
name
.
hash
end
private
def
distance_from_now_in_words
(
from_time
)
return
nil
unless
from_time
from_time
=
Time
.
parse
(
from_time
)
to_time
=
Time
.
now
distance_in_days
=
(((
to_time
-
from_time
).
abs
)
/
60
/
60
/
24
).
round
case
distance_in_days
when
0
..
7
"less than a week ago"
when
8
..
29
"
#{
distance_in_days
}
days ago"
when
30
..
45
"1 month ago"
when
46
..
365
"
#{
(
distance_in_days
.
to_f
/
30
).
round
}
months ago"
else
"more than a year ago"
end
end
end
end
end
end
lib/cocoapods/command/push.rb
View file @
76cb703e
...
...
@@ -36,20 +36,19 @@ module Pod
update_repo
add_specs_to_repo
push_repo
unless
@local_only
puts
end
private
def
update_repo
puts
"Updating the `
#{
@repo
}
' repo
\n
"
.
yellow
unless
config
.
silent
UI
.
puts
"Updating the `
#{
@repo
}
' repo
\n
"
.
yellow
unless
config
.
silent
# show the output of git even if not verbose
Dir
.
chdir
(
repo_dir
)
{
puts
`git pull 2>&1`
}
Dir
.
chdir
(
repo_dir
)
{
UI
.
puts
`git pull 2>&1`
}
end
def
push_repo
puts
"
\n
Pushing the `
#{
@repo
}
' repo
\n
"
.
yellow
unless
config
.
silent
Dir
.
chdir
(
repo_dir
)
{
puts
`git push 2>&1`
}
UI
.
puts
"
\n
Pushing the `
#{
@repo
}
' repo
\n
"
.
yellow
unless
config
.
silent
Dir
.
chdir
(
repo_dir
)
{
UI
.
puts
`git push 2>&1`
}
end
def
repo_dir
...
...
@@ -71,7 +70,7 @@ module Pod
end
def
validate_podspec_files
puts
"
\n
Validating specs"
.
yellow
unless
config
.
silent
UI
.
puts
"
\n
Validating specs"
.
yellow
unless
config
.
silent
lint_argv
=
[
"lint"
]
lint_argv
<<
"--only-errors"
if
@allow_warnings
lint_argv
<<
"--silent"
if
config
.
silent
...
...
@@ -82,7 +81,7 @@ module Pod
end
def
add_specs_to_repo
puts
"
\n
Adding the specs to the
#{
@repo
}
repo
\n
"
.
yellow
unless
config
.
silent
UI
.
puts
"
\n
Adding the specs to the
#{
@repo
}
repo
\n
"
.
yellow
unless
config
.
silent
podspec_files
.
each
do
|
spec_file
|
spec
=
Pod
::
Specification
.
from_file
(
spec_file
)
output_path
=
File
.
join
(
repo_dir
,
spec
.
name
,
spec
.
version
.
to_s
)
...
...
@@ -93,7 +92,7 @@ module Pod
else
message
=
"[Add]
#{
spec
}
"
end
puts
" -
#{
message
}
"
unless
config
.
silent
UI
.
puts
" -
#{
message
}
"
unless
config
.
silent
FileUtils
.
mkdir_p
(
output_path
)
FileUtils
.
cp
(
Pathname
.
new
(
spec
.
name
+
'.podspec'
),
output_path
)
...
...
lib/cocoapods/command/repo.rb
View file @
76cb703e
...
...
@@ -56,7 +56,7 @@ module Pod
end
def
add
UI
.
title
(
"Cloning spec repo `
#{
@name
}
' from `
#{
@url
}
'
#{
" (branch `
#{
@branch
}
')"
if
@branch
}
"
)
do
UI
.
section
(
"Cloning spec repo `
#{
@name
}
' from `
#{
@url
}
'
#{
" (branch `
#{
@branch
}
')"
if
@branch
}
"
)
do
config
.
repos_dir
.
mkpath
Dir
.
chdir
(
config
.
repos_dir
)
{
git!
(
"clone '
#{
@url
}
'
#{
@name
}
"
)
}
Dir
.
chdir
(
dir
)
{
git!
(
"checkout
#{
@branch
}
"
)
}
if
@branch
...
...
@@ -67,7 +67,7 @@ module Pod
def
update
dirs
=
@name
?
[
dir
]
:
config
.
repos_dir
.
children
.
select
{
|
c
|
c
.
directory?
}
dirs
.
each
do
|
dir
|
UI
.
title
"Updating spec repo `
#{
dir
.
basename
}
'"
do
UI
.
section
"Updating spec repo `
#{
dir
.
basename
}
'"
do
Dir
.
chdir
(
dir
)
do
`git rev-parse >/dev/null 2>&1`
if
$?
.
exitstatus
.
zero?
...
...
@@ -89,7 +89,7 @@ module Pod
end
dirs
.
each
do
|
dir
|
check_versions
(
dir
)
puts
"
\n
Linting spec repo `
#{
dir
.
realpath
.
basename
}
'
\n
"
.
yellow
UI
.
puts
"
\n
Linting spec repo `
#{
dir
.
realpath
.
basename
}
'
\n
"
.
yellow
podspecs
=
dir
.
glob
(
'**/*.podspec'
)
invalid_count
=
0
...
...
@@ -111,19 +111,19 @@ module Pod
end
if
should_display
puts
" -> "
.
send
(
color
)
<<
linter
.
spec_name
UI
.
puts
" -> "
.
send
(
color
)
<<
linter
.
spec_name
print_messages
(
'ERROR'
,
linter
.
errors
)
unless
@only_errors
print_messages
(
'WARN'
,
linter
.
warnings
)
print_messages
(
'NOTE'
,
linter
.
notes
)
end
puts
unless
config
.
silent?
UI
.
puts
unless
config
.
silent?
end
end
puts
"Analyzed
#{
podspecs
.
count
}
podspecs files.
\n\n
"
unless
config
.
silent?
UI
.
puts
"Analyzed
#{
podspecs
.
count
}
podspecs files.
\n\n
"
unless
config
.
silent?
if
invalid_count
==
0
puts
"All the specs passed validation."
.
green
<<
"
\n\n
"
unless
config
.
silent?
UI
.
puts
"All the specs passed validation."
.
green
<<
"
\n\n
"
unless
config
.
silent?
else
raise
Informative
,
"
#{
invalid_count
}
podspecs failed validation."
end
...
...
@@ -132,7 +132,7 @@ module Pod
def
print_messages
(
type
,
messages
)
return
if
config
.
silent?
messages
.
each
{
|
msg
|
puts
" -
#{
type
.
ljust
(
5
)
}
|
#{
msg
}
"
}
messages
.
each
{
|
msg
|
UI
.
puts
" -
#{
type
.
ljust
(
5
)
}
|
#{
msg
}
"
}
end
def
check_versions
(
dir
)
...
...
@@ -144,7 +144,7 @@ module Pod
"
\n
[!] The `
#{
dir
.
basename
.
to_s
}
' repo requires CocoaPods
#{
version_msg
}
\n
"
.
red
+
"Update Cocoapods, or checkout the appropriate tag in the repo.
\n\n
"
end
puts
"
\n
Cocoapods
#{
versions
[
'last'
]
}
is available.
\n
"
.
green
if
has_update
(
versions
)
&&
config
.
new_version_message?
UI
.
puts
"
\n
Cocoapods
#{
versions
[
'last'
]
}
is available.
\n
"
.
green
if
has_update
(
versions
)
&&
config
.
new_version_message?
end
def
self
.
compatible?
(
name
)
...
...
lib/cocoapods/command/search.rb
View file @
76cb703e
...
...
@@ -12,20 +12,22 @@ module Pod
end
def
self
.
options
[[
"--full"
,
"Search by name, summary, and description"
]].
concat
(
Presenter
.
options
).
concat
(
super
)
[[
"--full"
,
"Search by name, summary, and description"
,
"--stats"
,
"Show additional stats (like GitHub watchers and forks)"
]].
concat
(
super
)
end
def
initialize
(
argv
)
@full_text_search
=
argv
.
option
(
'--full'
)
@
presenter
=
Presenter
.
new
(
argv
)
@
stats
=
argv
.
option
(
'--stats'
)
@query
=
argv
.
shift_argument
super
unless
argv
.
empty?
&&
@query
end
def
run
sets
=
Source
.
search_by_name
(
@query
.
strip
,
@full_text_search
)
sets
.
each
{
|
s
|
puts
@presenter
.
describe
(
s
)}
puts
sets
.
each
{
|
set
|
UI
.
pod
(
set
,
(
@stats
?
:
stats
:
:normal
))
}
end
end
end
...
...
lib/cocoapods/command/setup.rb
View file @
76cb703e
...
...
@@ -89,7 +89,7 @@ module Pod
end
def
run
UI
.
title
"Setting up CocoaPods master repo"
do
UI
.
section
"Setting up CocoaPods master repo"
do
if
dir
.
exist?
set_master_repo_url
set_master_repo_branch
...
...
@@ -104,7 +104,7 @@ module Pod
`chmod +x '
#{
hook
}
'`
end
end
UI
.
title
"Setup completed (
#{
push?
?
"push"
:
"read-only"
}
access)"
UI
.
puts
"Setup completed (
#{
push?
?
"push"
:
"read-only"
}
access)"
.
green
end
end
end
...
...
lib/cocoapods/command/spec.rb
View file @
76cb703e
...
...
@@ -59,17 +59,17 @@ module Pod
repo_id
=
repo_id_match
[
1
]
data
=
github_data_for_template
(
repo_id
)
data
[
:name
]
=
@name_or_url
if
@url
puts
semantic_versioning_notice
(
repo_id
,
data
[
:name
])
if
data
[
:version
]
==
'0.0.1'
UI
.
puts
semantic_versioning_notice
(
repo_id
,
data
[
:name
])
if
data
[
:version
]
==
'0.0.1'
else
data
=
default_data_for_template
(
@name_or_url
)
end
spec
=
spec_template
(
data
)
(
Pathname
.
pwd
+
"
#{
data
[
:name
]
}
.podspec"
).
open
(
'w'
)
{
|
f
|
f
<<
spec
}
puts
"
\n
Specification created at
#{
data
[
:name
]
}
.podspec"
.
green
UI
.
puts
"
\n
Specification created at
#{
data
[
:name
]
}
.podspec"
.
green
end
def
lint
puts
UI
.
puts
invalid_count
=
0
podspecs_to_lint
.
each
do
|
podspec
|
linter
=
Linter
.
new
(
podspec
)
...
...
@@ -93,19 +93,19 @@ module Pod
end
# This overwrites the previously printed text
puts
" -> "
.
send
(
color
)
<<
linter
.
spec_name
unless
config
.
silent?
UI
.
puts
" -> "
.
send
(
color
)
<<
linter
.
spec_name
unless
config
.
silent?
print_messages
(
'ERROR'
,
linter
.
errors
)
print_messages
(
'WARN'
,
linter
.
warnings
)
print_messages
(
'NOTE'
,
linter
.
notes
)
puts
unless
config
.
silent?
UI
.
puts
unless
config
.
silent?
end
puts
"Analyzed
#{
podspecs_to_lint
.
count
}
podspecs files.
\n\n
"
unless
config
.
silent?
UI
.
puts
"Analyzed
#{
podspecs_to_lint
.
count
}
podspecs files.
\n\n
"
unless
config
.
silent?
count
=
podspecs_to_lint
.
count
if
invalid_count
==
0
lint_passed_message
=
count
==
1
?
"
#{
podspecs_to_lint
.
first
.
basename
}
passed validation."
:
"All the specs passed validation."
puts
lint_passed_message
.
green
<<
"
\n\n
"
unless
config
.
silent?
UI
.
puts
lint_passed_message
.
green
<<
"
\n\n
"
unless
config
.
silent?
else
raise
Informative
,
count
==
1
?
"The spec did not pass validation."
:
"
#{
invalid_count
}
out of
#{
count
}
specs failed validation."
end
...
...
@@ -116,7 +116,7 @@ module Pod
def
print_messages
(
type
,
messages
)
return
if
config
.
silent?
messages
.
each
{
|
msg
|
puts
" -
#{
type
.
ljust
(
5
)
}
|
#{
msg
}
"
}
messages
.
each
{
|
msg
|
UI
.
puts
" -
#{
type
.
ljust
(
5
)
}
|
#{
msg
}
"
}
end
def
podspecs_to_lint
...
...
lib/cocoapods/downloader/git.rb
View file @
76cb703e
...
...
@@ -14,7 +14,7 @@ module Pod
def
download
create_cache
unless
cache_exist?
UI
.
title
(
' > Cloning git repo'
,
''
,
3
)
do
UI
.
section
(
' > Cloning git repo'
,
''
,
3
)
do
if
options
[
:tag
]
download_tag
elsif
options
[
:branch
]
...
...
@@ -30,7 +30,7 @@ module Pod
end
def
create_cache
UI
.
title
" > Creating cache git repo (
#{
cache_path
}
)"
UI
.
section
" > Creating cache git repo (
#{
cache_path
}
)"
cache_path
.
rmtree
if
cache_path
.
exist?
cache_path
.
mkpath
git!
%Q|clone --mirror "
#{
url
}
" "
#{
cache_path
}
"|
...
...
@@ -74,7 +74,7 @@ module Pod
end
def
update_cache
UI
.
title
" > Updating cache git repo (
#{
cache_path
}
)"
UI
.
section
" > Updating cache git repo (
#{
cache_path
}
)"
Dir
.
chdir
(
cache_path
)
do
if
git
(
"config core.bare"
).
chomp
==
"true"
git!
"remote update"
...
...
lib/cocoapods/downloader/http.rb
View file @
76cb703e
...
...
@@ -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
.
section
(
' > Downloading from HTTP'
,
''
,
3
)
do
download_file
@download_path
extract_with_type
@download_path
,
type
end
...
...
lib/cocoapods/downloader/mercurial.rb
View file @
76cb703e
...
...
@@ -4,7 +4,7 @@ module Pod
executable
:hg
def
download
UI
.
title
(
' > Cloning mercurial repo'
,
''
,
3
)
do
UI
.
section
(
' > Cloning mercurial repo'
,
''
,
3
)
do
if
options
[
:revision
]
download_revision
else
...
...
lib/cocoapods/downloader/subversion.rb
View file @
76cb703e
...
...
@@ -8,13 +8,13 @@ module Pod
end
def
download
UI
.
title
(
' > Exporting subversion repo'
,
''
,
3
)
do
UI
.
section
(
' > Exporting subversion repo'
,
''
,
3
)
do
svn!
%|export "#{reference_url}" "#{target_path}"|
end
end
def
download_head
UI
.
title
(
' > Exporting subversion repo'
,
''
,
3
)
do
UI
.
section
(
' > Exporting subversion repo'
,
''
,
3
)
do
svn!
%|export "#{trunk_url}" "#{target_path}"|
end
end
...
...
lib/cocoapods/installer.rb
View file @
76cb703e
...
...
@@ -50,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
.
section
(
"Installing
#{
pod
}
"
.
green
,
"-> "
.
green
)
do
unless
pod
.
downloaded?
pod
.
implode
download_pod
(
pod
)
...
...
@@ -63,7 +63,7 @@ module Pod
pod
.
clean!
if
config
.
clean?
end
else
UI
.
title
(
"Using
#{
pod
}
"
,
"-> "
.
green
)
UI
.
section
(
"Using
#{
pod
}
"
,
"-> "
.
green
)
end
end
end
...
...
@@ -87,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
.
section
" > Installing documentation"
doc_generator
.
generate
(
config
.
doc_install?
)
else
UI
.
title
" > Using existing documentation"
UI
.
section
" > Using existing documentation"
end
end
...
...
@@ -98,7 +98,7 @@ module Pod
#
def
remove_deleted_dependencies!
resolver
.
removed_pods
.
each
do
|
pod_name
|
UI
.
title
(
"Removing
#{
pod_name
}
"
,
"-> "
.
red
)
do
UI
.
section
(
"Removing
#{
pod_name
}
"
,
"-> "
.
red
)
do
path
=
sandbox
.
root
+
pod_name
path
.
rmtree
if
path
.
exist?
end
...
...
@@ -107,19 +107,19 @@ module Pod
def
install!
@sandbox
.
prepare_for_install
UI
.
title
"Resolving dependencies of
#{
UI
.
path
@podfile
.
defined_in_file
}
"
do
UI
.
section
"Resolving dependencies of
#{
UI
.
path
@podfile
.
defined_in_file
}
"
do
specs_by_target
end
UI
.
title
"Removing deleted dependencies"
do
UI
.
section
"Removing deleted dependencies"
do
remove_deleted_dependencies!
end
unless
resolver
.
removed_pods
.
empty?
UI
.
title
"Downloading dependencies"
do
UI
.
section
"Downloading dependencies"
do
install_dependencies!
end
UI
.
title
"Generating support files"
do
UI
.
section
"Generating support files"
do
UI
.
message
"- Running pre install hooks"
do
run_pre_install_hooks
end
...
...
lib/cocoapods/resolver.rb
View file @
76cb703e
...
...
@@ -69,7 +69,7 @@ module Pod
if
@lockfile
@pods_by_state
=
@lockfile
.
detect_changes_with_podfile
(
podfile
)
UI
.
title
"Finding added, modified or removed dependencies:"
do
UI
.
section
"Finding added, modified or removed dependencies:"
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
|
...
...
@@ -81,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
}
):"
do
UI
.
section
"Resolving dependencies for target `
#{
target_definition
.
name
}
' (
#{
target_definition
.
platform
}
):"
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
)
...
...
lib/cocoapods/user_interface.rb
View file @
76cb703e
module
Pod
require
'colored'
class
UserInterface
autoload
:UIPod
,
'cocoapods/user_interface/ui_pod'
@indentation_level
=
0
@title_level
=
0
@title_colors
=
%w|yellow green|
...
...
@@ -9,14 +13,20 @@ module Pod
attr_accessor
:indentation_level
,
:title_level
def
title
(
title
,
verbose_prefix
=
''
,
relative_indentation
=
2
)
# Prints a title taking an optional verbose prefix and
# a relative indentation valid for the UI action in the passed
# block.
#
# In verbose mode titles are printed with a color according
# to their level. In normal mode titles are printed only if
# they have nesting level smaller than 2.
#
# TODO: refactor to title (for always visible titles like search)
# and sections (titles that reppresent collapsible sections).
#
def
section
(
title
,
verbose_prefix
=
''
,
relative_indentation
=
2
)
if
config
.
verbose?
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
puts
"
#{
title
}
"
title
(
title
,
verbose_prefix
,
relative_indentation
)
elsif
title_level
<
2
puts
title
end
...
...
@@ -28,6 +38,32 @@ module Pod
self
.
title_level
-=
1
end
# A title oposed to a section is always visible
#
def
title
(
title
,
verbose_prefix
=
''
,
relative_indentation
=
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
puts
"
#{
title
}
"
self
.
indentation_level
+=
relative_indentation
self
.
title_level
+=
1
yield
if
block_given?
self
.
indentation_level
-=
relative_indentation
self
.
title_level
-=
1
end
# def title(title, verbose_prefix = '', relative_indentation = 2)
# end
# Prints a verbose message taking an optional verbose prefix and
# a relative indentation valid for the UI action in the passed
# block.
#
# TODO: clean interface.
#
def
message
(
message
,
verbose_prefix
=
''
,
relative_indentation
=
2
)
message
=
verbose_prefix
+
message
if
config
.
verbose?
puts_indented
message
if
config
.
verbose?
...
...
@@ -37,15 +73,24 @@ module Pod
self
.
indentation_level
-=
relative_indentation
end
def
puts
(
message
)
# Prints a message unless config is silent.
#
def
puts
(
message
=
''
)
super
(
message
)
unless
config
.
silent?
end
def
puts_indented
(
message
)
indented
=
wrap_string
(
message
,
" "
*
indentation_level
)
# Prints a message respecting the current indentation level and
# wrapping it to the termina width if necessary.
#
def
puts_indented
(
message
=
''
)
indented
=
wrap_string
(
message
,
" "
*
self
.
indentation_level
)
puts
(
indented
)
end
# Returns a string containing relative location of a path from the Podfile.
# The returned path is quoted. If the argument is nit it returns the
# empty string.
#
def
path
(
pathname
)
if
pathname
"`./
#{
pathname
.
relative_path_from
(
config
.
project_podfile
.
dirname
||
Pathname
.
pwd
)
}
'"
...
...
@@ -54,8 +99,52 @@ module Pod
end
end
# Prints the textual repprensentation of a given set.
#
def
pod
(
set
,
mode
=
:normal
)
if
mode
==
:name
puts_indented
set
.
name
else
pod
=
UIPod
.
new
(
set
)
title
(
"
\n
->
#{
pod
.
name
}
(
#{
pod
.
version
}
)"
.
green
,
''
,
3
)
do
puts_indented
pod
.
summary
labeled
(
'Homepage'
,
pod
.
homepage
)
labeled
(
'Source'
,
pod
.
source_url
)
labeled
(
'Versions'
,
pod
.
versions
)
unless
set
.
versions
.
count
==
1
if
mode
==
:stats
labeled
(
'Pushed'
,
pod
.
github_last_activity
)
labeled
(
'Authors'
,
pod
.
authors
)
if
pod
.
authors
=~
/,/
labeled
(
'Author'
,
pod
.
authors
)
if
pod
.
authors
!~
/,/
labeled
(
'License'
,
pod
.
license
)
labeled
(
'Platform'
,
pod
.
platform
)
labeled
(
'Watchers'
,
pod
.
github_watchers
)
labeled
(
'Forks'
,
pod
.
github_forks
)
end
labeled
(
'Sub specs'
,
pod
.
subspecs
)
end
end
end
# Prints a message with a label.
#
def
labeled
(
label
,
value
)
if
value
''
.
tap
do
|
t
|
t
<<
" -
#{
label
}
:"
.
ljust
(
16
)
if
value
.
is_a?
(
Array
)
separator
=
"
\n
- "
puts_indented
t
<<
separator
<<
value
.
join
(
separator
)
else
puts_indented
t
<<
value
.
to_s
<<
"
\n
"
end
end
end
end
# Wraps a string with a given indent to the width of the terminal.
# adapted from http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
def
wrap_string
(
txt
,
indent
)
#
def
wrap_string
(
txt
,
indent
=
''
)
width
=
`stty size`
.
split
(
' '
)[
1
].
to_i
-
indent
.
length
txt
.
strip
.
gsub
(
/(.{1,
#{
width
}
})( +|$)\n?|(.{
#{
width
}
})/
,
indent
+
"
\\
1
\\
3
\n
"
)
end
...
...
lib/cocoapods/user_interface/ui_pod.rb
0 → 100644
View file @
76cb703e
require
'active_support/core_ext/array/conversions'
module
Pod
class
UserInterface
class
UIPod
attr_accessor
:set
def
initialize
(
set
)
@set
=
set
end
# set information
def
name
@set
.
name
end
def
version
@set
.
versions
.
last
end
def
versions
@set
.
versions
.
reverse
.
join
(
", "
)
end
# specification information
def
spec
@set
.
specification
end
def
authors
spec
.
authors
.
keys
.
to_sentence
end
def
homepage
spec
.
homepage
end
def
description
spec
.
description
end
def
summary
spec
.
summary
end
def
source_url
spec
.
source
.
reject
{
|
k
,
_
|
k
==
:commit
||
k
==
:tag
}.
values
.
first
end
def
platform
spec
.
available_platforms
.
sort
{
|
a
,
b
|
a
.
to_s
.
downcase
<=>
b
.
to_s
.
downcase
}.
join
(
' - '
)
end
def
license
spec
.
license
[
:type
]
if
spec
.
license
end
# will return array of all subspecs (recursevly) or nil
def
subspecs
(
spec
.
recursive_subspecs
.
any?
&&
spec
.
recursive_subspecs
)
||
nil
end
# Statistics information
def
creation_date
Pod
::
Specification
::
Statistics
.
instance
.
creation_date
(
@set
)
end
def
github_watchers
Pod
::
Specification
::
Statistics
.
instance
.
github_watchers
(
@set
)
end
def
github_forks
Pod
::
Specification
::
Statistics
.
instance
.
github_forks
(
@set
)
end
def
github_last_activity
distance_from_now_in_words
(
Pod
::
Specification
::
Statistics
.
instance
.
github_pushed_at
(
@set
))
end
def
==
(
other
)
self
.
class
===
other
&&
@set
==
other
.
set
end
def
eql?
(
other
)
self
.
class
===
other
&&
name
.
eql?
(
other
.
name
)
end
def
hash
name
.
hash
end
private
def
distance_from_now_in_words
(
from_time
)
return
nil
unless
from_time
from_time
=
Time
.
parse
(
from_time
)
to_time
=
Time
.
now
distance_in_days
=
(((
to_time
-
from_time
).
abs
)
/
60
/
60
/
24
).
round
case
distance_in_days
when
0
..
7
"less than a week ago"
when
8
..
29
"
#{
distance_in_days
}
days ago"
when
30
..
45
"1 month ago"
when
46
..
365
"
#{
(
distance_in_days
.
to_f
/
30
).
round
}
months ago"
else
"more than a year ago"
end
end
end
end
end
spec/functional/command/list_spec.rb
View file @
76cb703e
...
...
@@ -31,7 +31,7 @@ describe "Pod::Command::List" do
/MagicalRecord/
,
/A2DynamicDelegate/
,
/\d+ pods were found/
].
each
{
|
regex
|
list
.
output
.
should
=~
regex
}
].
each
{
|
regex
|
Pod
::
UI
.
output
.
should
=~
regex
}
end
it
"returns the new pods"
do
...
...
@@ -46,7 +46,7 @@ describe "Pod::Command::List" do
'FileMD5Hash'
,
'cocoa-oauth'
,
'iRate'
].
each
{
|
s
|
list
.
output
.
should
.
include
s
}
].
each
{
|
s
|
Pod
::
UI
.
output
.
should
.
include
s
}
end
end
...
...
spec/functional/command/push_spec.rb
View file @
76cb703e
...
...
@@ -67,8 +67,8 @@ describe Pod::Command::Push do
cmd
.
expects
(
:validate_podspec_files
).
returns
(
true
)
Dir
.
chdir
(
temporary_directory
)
{
cmd
.
run
}
cmd
.
output
.
should
.
include
(
'[Add] PushTest (1.4)'
)
cmd
.
output
.
should
.
include
(
'[Fix] JSONKit (1.4)'
)
Pod
::
UI
.
output
.
should
.
include
(
'[Add] PushTest (1.4)'
)
Pod
::
UI
.
output
.
should
.
include
(
'[Fix] JSONKit (1.4)'
)
git
(
'upstream'
,
'checkout test'
)
# checkout because test because is it the branch used in the specs.
(
@upstream
.
dir
+
'PushTest/1.4/PushTest.podspec'
).
read
.
should
.
include
(
'PushTest'
)
...
...
spec/functional/command/repo_spec.rb
View file @
76cb703e
...
...
@@ -57,7 +57,7 @@ describe "Pod::Command::Repo" do
it
"lints a repo"
do
cmd
=
command
(
'repo'
,
'lint'
,
'master'
)
lambda
{
cmd
.
run
}.
should
.
raise
Pod
::
Informative
cmd
.
output
.
should
.
include
"Missing license type"
Pod
::
UI
.
output
.
should
.
include
"Missing license type"
end
end
...
...
spec/functional/command/setup_spec.rb
View file @
76cb703e
...
...
@@ -32,9 +32,9 @@ describe "Pod::Command::Setup" do
it
"creates the local spec-repos directory and creates a clone of the `master' repo"
do
output
=
run_command
(
'setup'
)
git_config
(
'master'
,
'remote.origin.url'
).
should
==
fixture
(
'spec-repos/master'
).
to_s
output
.
should
.
include
"Setup completed"
output
.
should
.
not
.
include
"push"
git_config
(
'master'
,
'remote.origin.url'
).
should
==
fixture
(
'spec-repos/master'
).
to_s
end
it
"preserves push access for the `master' repo"
do
...
...
@@ -47,9 +47,8 @@ describe "Pod::Command::Setup" do
it
"can run if needed"
do
output
=
run_command
(
'setup'
)
output
.
should
.
include
"Setup completed"
command
=
command
(
'setup'
)
command
.
run_if_needed
command
.
output
.
should
==
nil
Pod
::
UI
.
output
=
''
command
(
'setup'
)
.
run_if_needed
Pod
::
UI
.
output
.
should
==
''
end
end
spec/functional/command/spec_spec.rb
View file @
76cb703e
...
...
@@ -107,7 +107,7 @@ describe "Pod::Command::Spec#lint" do
Dir
.
chdir
(
fixture
(
'spec-repos'
)
+
'master/JSONKit/1.4/'
)
do
cmd
=
command
(
'spec'
,
'lint'
,
'--quick'
,
'--only-errors'
)
cmd
.
run
cmd
.
output
.
should
.
include
"passed validation"
Pod
::
UI
.
output
.
should
.
include
"passed validation"
end
end
...
...
@@ -129,12 +129,12 @@ describe "Pod::Command::Spec#lint" do
it
"lints a givent podspec"
do
cmd
=
command
(
'spec'
,
'lint'
,
'--quick'
,
@spec_path
)
lambda
{
cmd
.
run
}.
should
.
raise
Pod
::
Informative
cmd
.
output
.
should
.
include
"Missing license type"
Pod
::
UI
.
output
.
should
.
include
"Missing license type"
end
it
"respects the -only--errors option"
do
cmd
=
command
(
'spec'
,
'lint'
,
'--quick'
,
'--only-errors'
,
@spec_path
)
lambda
{
cmd
.
run
}.
should
.
not
.
raise
cmd
.
output
.
should
.
include
"Missing license type"
Pod
::
UI
.
output
.
should
.
include
"Missing license type"
end
end
spec/functional/
command/presenter
_spec.rb
→
spec/functional/
user_interface
_spec.rb
View file @
76cb703e
require
File
.
expand_path
(
'../../
../
spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
require
'net/http'
describe
Pod
::
Command
::
Presenter
do
Presenter
=
Pod
::
Command
::
Presenter
describe
Pod
::
UI
do
extend
SpecHelper
::
Command
before
do
@set
=
Pod
::
Spec
::
Set
.
new
(
fixture
(
'spec-repos/master/CocoaLumberjack'
))
...
...
@@ -11,8 +10,8 @@ describe Pod::Command::Presenter do
end
it
"presents the name, version, description, homepage and source of a specification set"
do
presenter
=
Presenter
.
new
(
argv
()
)
output
=
presenter
.
describe
(
@set
)
Pod
::
UI
.
pod
(
@set
)
output
=
Pod
::
UI
.
output
output
.
should
.
include?
'CocoaLumberjack'
output
.
should
.
include?
'1.0'
output
.
should
.
include?
'1.1'
...
...
@@ -24,8 +23,8 @@ describe Pod::Command::Presenter do
it
"presents the stats of a specification set"
do
repo
=
{
"forks"
=>
42
,
"watchers"
=>
318
,
"pushed_at"
=>
"2011-01-26T19:06:43Z"
}
Octokit
.
expects
(
:repo
).
with
(
"robbiehanson/CocoaLumberjack"
).
returns
(
repo
)
presenter
=
Presenter
.
new
(
argv
(
'--stats'
,
'--no-color'
)
)
output
=
presenter
.
describe
(
@set
)
Pod
::
UI
.
pod
(
@set
,
:stats
)
output
=
Pod
::
UI
.
output
output
.
should
.
include?
'Author: Robbie Hanson'
output
.
should
.
include?
'License: BSD'
output
.
should
.
include?
'Platform: iOS - OS X'
...
...
@@ -35,8 +34,9 @@ describe Pod::Command::Presenter do
end
it
"should print at least one subspec"
do
presenter
=
Presenter
.
new
(
argv
())
output
=
presenter
.
describe
(
Pod
::
Spec
::
Set
.
new
(
fixture
(
'spec-repos/master/RestKit'
)))
@set
=
Pod
::
Spec
::
Set
.
new
(
fixture
(
'spec-repos/master/RestKit'
))
Pod
::
UI
.
pod
(
@set
)
output
=
Pod
::
UI
.
output
output
.
should
.
include?
"RestKit/Network"
end
end
...
...
spec/spec_helper.rb
View file @
76cb703e
...
...
@@ -19,6 +19,7 @@ require 'spec_helper/github'
require
'spec_helper/temporary_directory'
require
'spec_helper/temporary_repos'
require
'spec_helper/config'
require
'spec_helper/user_interface'
module
Bacon
class
Context
...
...
spec/spec_helper/command.rb
View file @
76cb703e
require
'spec_helper/temporary_directory'
class
Pod
::
Command
attr_accessor
:output
def
puts
(
msg
=
''
)
(
@output
||=
''
)
<<
"
#{
msg
}
\n
"
end
end
module
SpecHelper
module
Command
def
command
(
*
argv
)
...
...
@@ -15,9 +9,21 @@ module SpecHelper
def
run_command
(
*
args
)
Dir
.
chdir
(
SpecHelper
.
temporary_directory
)
do
command
=
command
(
*
args
)
command
.
run
command
.
output
Pod
::
UI
.
output
=
''
# TODO: remove this once all cocoapods has
# been converted to use the UI.puts
config_silent
=
config
.
silent?
config
.
silent
=
false
# Very nasty behaviour where the relative increments are
# not reverted and lead to sections being collapsed and
# not being printed to the output.
Pod
::
UI
.
indentation_level
=
0
Pod
::
UI
.
title_level
=
0
command
(
*
args
).
run
config
.
silent
=
config_silent
Pod
::
UI
.
output
end
end
end
...
...
spec/spec_helper/user_interface.rb
0 → 100644
View file @
76cb703e
module
Pod
class
UI
@output
=
''
class
<<
self
attr_accessor
:output
def
puts
(
message
=
''
)
@output
<<
"
#{
message
}
"
end
end
end
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