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
ac6fcb70
Commit
ac6fcb70
authored
May 16, 2016
by
Nate West
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5328 from CocoaPods/move-commands
[Commands] Reorganize IPC and Lib
parents
474ce948
02539e16
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
572 additions
and
533 deletions
+572
-533
command.rb
lib/cocoapods/command.rb
+1
-1
inter_process_communication.rb
lib/cocoapods/command/inter_process_communication.rb
+0
-177
ipc.rb
lib/cocoapods/command/ipc.rb
+18
-0
list.rb
lib/cocoapods/command/ipc/list.rb
+40
-0
podfile.rb
lib/cocoapods/command/ipc/podfile.rb
+31
-0
repl.rb
lib/cocoapods/command/ipc/repl.rb
+51
-0
spec.rb
lib/cocoapods/command/ipc/spec.rb
+29
-0
update_search_index.rb
lib/cocoapods/command/ipc/update_search_index.rb
+24
-0
lib.rb
lib/cocoapods/command/lib.rb
+3
-207
create.rb
lib/cocoapods/command/lib/create.rb
+104
-0
lint.rb
lib/cocoapods/command/lib/lint.rb
+107
-0
inter_process_communication_spec.rb
spec/functional/command/inter_process_communication_spec.rb
+0
-87
list_spec.rb
spec/functional/command/ipc/list_spec.rb
+21
-0
podfile_spec.rb
spec/functional/command/ipc/podfile_spec.rb
+17
-0
repl_spec.rb
spec/functional/command/ipc/repl_spec.rb
+31
-0
spec_spec.rb
spec/functional/command/ipc/spec_spec.rb
+16
-0
update_search_index_spec.rb
spec/functional/command/ipc/update_search_index_spec.rb
+15
-0
create_spec.rb
spec/functional/command/lib/create_spec.rb
+1
-61
list_spec.rb
spec/functional/command/lib/list_spec.rb
+63
-0
No files found.
lib/cocoapods/command.rb
View file @
ac6fcb70
...
@@ -22,7 +22,7 @@ module Pod
...
@@ -22,7 +22,7 @@ module Pod
require
'cocoapods/command/env'
require
'cocoapods/command/env'
require
'cocoapods/command/init'
require
'cocoapods/command/init'
require
'cocoapods/command/install'
require
'cocoapods/command/install'
require
'cocoapods/command/i
nter_process_communication
'
require
'cocoapods/command/i
pc
'
require
'cocoapods/command/lib'
require
'cocoapods/command/lib'
require
'cocoapods/command/list'
require
'cocoapods/command/list'
require
'cocoapods/command/outdated'
require
'cocoapods/command/outdated'
...
...
lib/cocoapods/command/inter_process_communication.rb
deleted
100644 → 0
View file @
474ce948
module
Pod
class
Command
class
IPC
<
Command
self
.
abstract_command
=
true
self
.
summary
=
'Inter-process communication'
def
output_pipe
STDOUT
end
#-----------------------------------------------------------------------#
class
Spec
<
IPC
self
.
summary
=
'Converts a podspec to JSON'
self
.
description
=
'Converts a podspec to JSON and prints it to STDOUT.'
self
.
arguments
=
[
CLAide
::
Argument
.
new
(
'PATH'
,
true
),
]
def
initialize
(
argv
)
@path
=
argv
.
shift_argument
super
end
def
validate!
super
help!
'A specification path is required.'
unless
@path
end
def
run
require
'json'
spec
=
Specification
.
from_file
(
@path
)
output_pipe
.
puts
(
spec
.
to_pretty_json
)
end
end
#-----------------------------------------------------------------------#
class
Podfile
<
IPC
include
ProjectDirectory
self
.
summary
=
'Converts a Podfile to YAML'
self
.
description
=
'Converts a Podfile to YAML and prints it to STDOUT.'
self
.
arguments
=
[
CLAide
::
Argument
.
new
(
'PATH'
,
true
),
]
def
initialize
(
argv
)
@path
=
argv
.
shift_argument
super
end
def
validate!
super
help!
'A Podfile path is required.'
unless
@path
end
def
run
require
'yaml'
podfile
=
Pod
::
Podfile
.
from_file
(
@path
)
output_pipe
.
puts
podfile
.
to_yaml
end
end
#-----------------------------------------------------------------------#
class
List
<
IPC
self
.
summary
=
'Lists the specifications known to CocoaPods'
self
.
description
=
<<-
DESC
Prints to STDOUT a YAML dictionary where the keys are the name of the
specifications and each corresponding value is a dictionary with
the following keys:
- defined_in_file
- version
- authors
- summary
- description
- platforms
DESC
def
run
require
'yaml'
sets
=
config
.
sources_manager
.
aggregate
.
all_sets
result
=
{}
sets
.
each
do
|
set
|
begin
spec
=
set
.
specification
result
[
spec
.
name
]
=
{
'authors'
=>
spec
.
authors
.
keys
,
'summary'
=>
spec
.
summary
,
'description'
=>
spec
.
description
,
'platforms'
=>
spec
.
available_platforms
.
map
{
|
p
|
p
.
name
.
to_s
},
}
rescue
DSLError
next
end
end
output_pipe
.
puts
result
.
to_yaml
end
end
#-----------------------------------------------------------------------#
class
UpdateSearchIndex
<
IPC
self
.
summary
=
'Updates the search index'
self
.
description
=
<<-
DESC
Updates the search index and prints its path to standard output.
The search index is a YAML encoded dictionary where the keys
are the names of the Pods and the values are a dictionary containing
the following information:
- version
- summary
- description
- authors
DESC
def
run
config
.
sources_manager
.
updated_search_index
output_pipe
.
puts
(
config
.
sources_manager
.
search_index_path
)
end
end
#-----------------------------------------------------------------------#
class
Repl
<
IPC
include
ProjectDirectory
END_OF_OUTPUT_SIGNAL
=
"
\n\r
"
self
.
summary
=
'The repl listens to commands on standard input'
self
.
description
=
<<-
DESC
The repl listens to commands on standard input and prints their
result to standard output.
It accepts all the other ipc subcommands. The repl will signal the
end of output with the the ASCII CR+LF `
\\
n
\\
r`.
DESC
def
run
print_version
signal_end_of_output
listen
end
def
print_version
output_pipe
.
puts
"version: '
#{
Pod
::
VERSION
}
'"
end
def
signal_end_of_output
output_pipe
.
puts
(
END_OF_OUTPUT_SIGNAL
)
STDOUT
.
flush
end
def
listen
while
repl_command
=
STDIN
.
gets
execute_repl_command
(
repl_command
)
end
end
def
execute_repl_command
(
repl_command
)
if
(
repl_command
!=
"
\n
"
)
repl_commands
=
repl_command
.
split
subcommand
=
repl_commands
.
shift
.
capitalize
arguments
=
repl_commands
subcommand_class
=
Pod
::
Command
::
IPC
.
const_get
(
subcommand
)
subcommand_class
.
new
(
CLAide
::
ARGV
.
new
(
arguments
)).
run
signal_end_of_output
end
end
end
#-----------------------------------------------------------------------#
end
end
end
lib/cocoapods/command/ipc.rb
0 → 100644
View file @
ac6fcb70
require
'cocoapods/command/ipc/list'
require
'cocoapods/command/ipc/podfile'
require
'cocoapods/command/ipc/repl'
require
'cocoapods/command/ipc/spec'
require
'cocoapods/command/ipc/update_search_index'
module
Pod
class
Command
class
IPC
<
Command
self
.
abstract_command
=
true
self
.
summary
=
'Inter-process communication'
def
output_pipe
STDOUT
end
end
end
end
lib/cocoapods/command/ipc/list.rb
0 → 100644
View file @
ac6fcb70
module
Pod
class
Command
class
IPC
<
Command
class
List
<
IPC
self
.
summary
=
'Lists the specifications known to CocoaPods'
self
.
description
=
<<-
DESC
Prints to STDOUT a YAML dictionary where the keys are the name of the
specifications and each corresponding value is a dictionary with
the following keys:
- defined_in_file
- version
- authors
- summary
- description
- platforms
DESC
def
run
require
'yaml'
sets
=
config
.
sources_manager
.
aggregate
.
all_sets
result
=
{}
sets
.
each
do
|
set
|
begin
spec
=
set
.
specification
result
[
spec
.
name
]
=
{
'authors'
=>
spec
.
authors
.
keys
,
'summary'
=>
spec
.
summary
,
'description'
=>
spec
.
description
,
'platforms'
=>
spec
.
available_platforms
.
map
{
|
p
|
p
.
name
.
to_s
},
}
rescue
DSLError
next
end
end
output_pipe
.
puts
result
.
to_yaml
end
end
end
end
end
lib/cocoapods/command/ipc/podfile.rb
0 → 100644
View file @
ac6fcb70
module
Pod
class
Command
class
IPC
<
Command
class
Podfile
<
IPC
include
ProjectDirectory
self
.
summary
=
'Converts a Podfile to YAML'
self
.
description
=
'Converts a Podfile to YAML and prints it to STDOUT.'
self
.
arguments
=
[
CLAide
::
Argument
.
new
(
'PATH'
,
true
),
]
def
initialize
(
argv
)
@path
=
argv
.
shift_argument
super
end
def
validate!
super
help!
'A Podfile path is required.'
unless
@path
end
def
run
require
'yaml'
podfile
=
Pod
::
Podfile
.
from_file
(
@path
)
output_pipe
.
puts
podfile
.
to_yaml
end
end
end
end
end
lib/cocoapods/command/ipc/repl.rb
0 → 100644
View file @
ac6fcb70
module
Pod
class
Command
class
IPC
<
Command
class
Repl
<
IPC
include
ProjectDirectory
END_OF_OUTPUT_SIGNAL
=
"
\n\r
"
.
freeze
self
.
summary
=
'The repl listens to commands on standard input'
self
.
description
=
<<-
DESC
The repl listens to commands on standard input and prints their
result to standard output.
It accepts all the other ipc subcommands. The repl will signal the
end of output with the the ASCII CR+LF `
\\
n
\\
r`.
DESC
def
run
print_version
signal_end_of_output
listen
end
def
print_version
output_pipe
.
puts
"version: '
#{
Pod
::
VERSION
}
'"
end
def
signal_end_of_output
output_pipe
.
puts
(
END_OF_OUTPUT_SIGNAL
)
STDOUT
.
flush
end
def
listen
while
repl_command
=
STDIN
.
gets
execute_repl_command
(
repl_command
)
end
end
def
execute_repl_command
(
repl_command
)
unless
repl_command
==
'\n'
repl_commands
=
repl_command
.
split
subcommand
=
repl_commands
.
shift
.
capitalize
arguments
=
repl_commands
subcommand_class
=
Pod
::
Command
::
IPC
.
const_get
(
subcommand
)
subcommand_class
.
new
(
CLAide
::
ARGV
.
new
(
arguments
)).
run
signal_end_of_output
end
end
end
end
end
end
lib/cocoapods/command/ipc/spec.rb
0 → 100644
View file @
ac6fcb70
module
Pod
class
Command
class
IPC
<
Command
class
Spec
<
IPC
self
.
summary
=
'Converts a podspec to JSON'
self
.
description
=
'Converts a podspec to JSON and prints it to STDOUT.'
self
.
arguments
=
[
CLAide
::
Argument
.
new
(
'PATH'
,
true
),
]
def
initialize
(
argv
)
@path
=
argv
.
shift_argument
super
end
def
validate!
super
help!
'A specification path is required.'
unless
@path
end
def
run
require
'json'
spec
=
Specification
.
from_file
(
@path
)
output_pipe
.
puts
(
spec
.
to_pretty_json
)
end
end
end
end
end
lib/cocoapods/command/ipc/update_search_index.rb
0 → 100644
View file @
ac6fcb70
module
Pod
class
Command
class
IPC
<
Command
class
UpdateSearchIndex
<
IPC
self
.
summary
=
'Updates the search index'
self
.
description
=
<<-
DESC
Updates the search index and prints its path to standard output.
The search index is a YAML encoded dictionary where the keys
are the names of the Pods and the values are a dictionary containing
the following information:
- version
- summary
- description
- authors
DESC
def
run
config
.
sources_manager
.
updated_search_index
output_pipe
.
puts
(
config
.
sources_manager
.
search_index_path
)
end
end
end
end
end
lib/cocoapods/command/lib.rb
View file @
ac6fcb70
require
'cocoapods/command/lib/create'
require
'cocoapods/command/lib/lint'
module
Pod
module
Pod
class
Command
class
Command
class
Lib
<
Command
class
Lib
<
Command
self
.
abstract_command
=
true
self
.
abstract_command
=
true
self
.
summary
=
'Develop pods'
self
.
summary
=
'Develop pods'
#-----------------------------------------------------------------------#
class
Create
<
Lib
self
.
summary
=
'Creates a new Pod'
self
.
description
=
<<-
DESC
Creates a scaffold for the development of a new Pod named `NAME`
according to the CocoaPods best practices.
If a `TEMPLATE_URL`, pointing to a git repo containing a compatible
template, is specified, it will be used in place of the default one.
DESC
self
.
arguments
=
[
CLAide
::
Argument
.
new
(
'NAME'
,
true
),
]
def
self
.
options
[
[
'--template-url=URL'
,
'The URL of the git repo containing a '
\
'compatible template'
],
].
concat
(
super
)
end
def
initialize
(
argv
)
@name
=
argv
.
shift_argument
@template_url
=
argv
.
option
(
'template-url'
,
TEMPLATE_REPO
)
super
@additional_args
=
argv
.
remainder!
end
def
validate!
super
help!
'A name for the Pod is required.'
unless
@name
help!
'The Pod name cannot contain spaces.'
if
@name
=~
/\s/
help!
"The Pod name cannot begin with a '.'"
if
@name
[
0
,
1
]
==
'.'
end
def
run
clone_template
configure_template
print_info
end
private
#----------------------------------------#
# !@group Private helpers
extend
Executable
executable
:git
TEMPLATE_REPO
=
'https://github.com/CocoaPods/pod-template.git'
TEMPLATE_INFO_URL
=
'https://github.com/CocoaPods/pod-template'
CREATE_NEW_POD_INFO_URL
=
'http://guides.cocoapods.org/making/making-a-cocoapod'
# Clones the template from the remote in the working directory using
# the name of the Pod.
#
# @return [void]
#
def
clone_template
UI
.
section
(
"Cloning `
#{
template_repo_url
}
` into `
#{
@name
}
`."
)
do
git!
[
'clone'
,
template_repo_url
,
@name
]
end
end
# Runs the template configuration utilities.
#
# @return [void]
#
def
configure_template
UI
.
section
(
"Configuring
#{
@name
}
template."
)
do
Dir
.
chdir
(
@name
)
do
if
File
.
exist?
(
'configure'
)
system
(
'./configure'
,
@name
,
*
@additional_args
)
else
UI
.
warn
'Template does not have a configure file.'
end
end
end
end
# Runs the template configuration utilities.
#
# @return [void]
#
def
print_info
UI
.
puts
"
\n
To learn more about the template see `
#{
template_repo_url
}
`."
UI
.
puts
"To learn more about creating a new pod, see `
#{
CREATE_NEW_POD_INFO_URL
}
`."
end
# Checks if a template URL is given else returns the TEMPLATE_REPO URL
#
# @return String
#
def
template_repo_url
@template_url
||
TEMPLATE_REPO
end
end
#-----------------------------------------------------------------------#
class
Lint
<
Lib
self
.
summary
=
'Validates a Pod'
self
.
description
=
<<-
DESC
Validates the Pod using the files in the working directory.
DESC
def
self
.
options
[
[
'--quick'
,
'Lint skips checks that would require to download and build the spec'
],
[
'--allow-warnings'
,
'Lint validates even if warnings are present'
],
[
'--subspec=NAME'
,
'Lint validates only the given subspec'
],
[
'--no-subspecs'
,
'Lint skips validation of subspecs'
],
[
'--no-clean'
,
'Lint leaves the build directory intact for inspection'
],
[
'--fail-fast'
,
'Lint stops on the first failing platform or subspec'
],
[
'--use-libraries'
,
'Lint uses static libraries to install the spec'
],
[
'--sources=https://github.com/artsy/Specs,master'
,
'The sources from which to pull dependent pods '
\
'(defaults to https://github.com/CocoaPods/Specs.git). '
\
'Multiple sources must be comma-delimited.'
],
[
'--private'
,
'Lint skips checks that apply only to public specs'
],
].
concat
(
super
)
end
def
initialize
(
argv
)
@quick
=
argv
.
flag?
(
'quick'
)
@allow_warnings
=
argv
.
flag?
(
'allow-warnings'
)
@clean
=
argv
.
flag?
(
'clean'
,
true
)
@fail_fast
=
argv
.
flag?
(
'fail-fast'
,
false
)
@subspecs
=
argv
.
flag?
(
'subspecs'
,
true
)
@only_subspec
=
argv
.
option
(
'subspec'
)
@use_frameworks
=
!
argv
.
flag?
(
'use-libraries'
)
@source_urls
=
argv
.
option
(
'sources'
,
'https://github.com/CocoaPods/Specs.git'
).
split
(
','
)
@private
=
argv
.
flag?
(
'private'
,
false
)
@podspecs_paths
=
argv
.
arguments!
super
end
def
validate!
super
end
def
run
UI
.
puts
podspecs_to_lint
.
each
do
|
podspec
|
validator
=
Validator
.
new
(
podspec
,
@source_urls
)
validator
.
local
=
true
validator
.
quick
=
@quick
validator
.
no_clean
=
!
@clean
validator
.
fail_fast
=
@fail_fast
validator
.
allow_warnings
=
@allow_warnings
validator
.
no_subspecs
=
!
@subspecs
||
@only_subspec
validator
.
only_subspec
=
@only_subspec
validator
.
use_frameworks
=
@use_frameworks
validator
.
ignore_public_only_results
=
@private
validator
.
validate
unless
@clean
UI
.
puts
"Pods workspace available at `
#{
validator
.
validation_dir
}
/App.xcworkspace` for inspection."
UI
.
puts
end
if
validator
.
validated?
UI
.
puts
"
#{
validator
.
spec
.
name
}
passed validation."
.
green
else
spec_name
=
podspec
spec_name
=
validator
.
spec
.
name
if
validator
.
spec
message
=
"
#{
spec_name
}
did not pass validation, due to
#{
validator
.
failure_reason
}
."
if
@clean
message
<<
"
\n
You can use the `--no-clean` option to inspect "
\
'any issue.'
end
raise
Informative
,
message
end
end
end
private
#----------------------------------------#
# !@group Private helpers
# @return [Pathname] The path of the podspec found in the current
# working directory.
#
# @raise If no podspec is found.
# @raise If multiple podspecs are found.
#
def
podspecs_to_lint
if
!
@podspecs_paths
.
empty?
Array
(
@podspecs_paths
)
else
podspecs
=
Pathname
.
glob
(
Pathname
.
pwd
+
'*.podspec{.json,}'
)
if
podspecs
.
count
.
zero?
raise
Informative
,
'Unable to find a podspec in the working '
\
'directory'
end
podspecs
end
end
end
#-----------------------------------------------------------------------#
end
end
end
end
end
end
lib/cocoapods/command/lib/create.rb
0 → 100644
View file @
ac6fcb70
module
Pod
class
Command
class
Lib
<
Command
class
Create
<
Lib
self
.
summary
=
'Creates a new Pod'
self
.
description
=
<<-
DESC
Creates a scaffold for the development of a new Pod named `NAME`
according to the CocoaPods best practices.
If a `TEMPLATE_URL`, pointing to a git repo containing a compatible
template, is specified, it will be used in place of the default one.
DESC
self
.
arguments
=
[
CLAide
::
Argument
.
new
(
'NAME'
,
true
),
]
def
self
.
options
[
[
'--template-url=URL'
,
'The URL of the git repo containing a '
\
'compatible template'
],
].
concat
(
super
)
end
def
initialize
(
argv
)
@name
=
argv
.
shift_argument
@template_url
=
argv
.
option
(
'template-url'
,
TEMPLATE_REPO
)
super
@additional_args
=
argv
.
remainder!
end
def
validate!
super
help!
'A name for the Pod is required.'
unless
@name
help!
'The Pod name cannot contain spaces.'
if
@name
=~
/\s/
help!
"The Pod name cannot begin with a '.'"
if
@name
[
0
,
1
]
==
'.'
end
def
run
clone_template
configure_template
print_info
end
private
#----------------------------------------#
# !@group Private helpers
extend
Executable
executable
:git
TEMPLATE_REPO
=
'https://github.com/CocoaPods/pod-template.git'
.
freeze
TEMPLATE_INFO_URL
=
'https://github.com/CocoaPods/pod-template'
.
freeze
CREATE_NEW_POD_INFO_URL
=
'http://guides.cocoapods.org/making/making-a-cocoapod'
.
freeze
# Clones the template from the remote in the working directory using
# the name of the Pod.
#
# @return [void]
#
def
clone_template
UI
.
section
(
"Cloning `
#{
template_repo_url
}
` into `
#{
@name
}
`."
)
do
git!
[
'clone'
,
template_repo_url
,
@name
]
end
end
# Runs the template configuration utilities.
#
# @return [void]
#
def
configure_template
UI
.
section
(
"Configuring
#{
@name
}
template."
)
do
Dir
.
chdir
(
@name
)
do
if
File
.
exist?
(
'configure'
)
system
(
'./configure'
,
@name
,
*
@additional_args
)
else
UI
.
warn
'Template does not have a configure file.'
end
end
end
end
# Runs the template configuration utilities.
#
# @return [void]
#
def
print_info
UI
.
puts
"
\n
To learn more about the template see `
#{
template_repo_url
}
`."
UI
.
puts
"To learn more about creating a new pod, see `
#{
CREATE_NEW_POD_INFO_URL
}
`."
end
# Checks if a template URL is given else returns the TEMPLATE_REPO URL
#
# @return String
#
def
template_repo_url
@template_url
||
TEMPLATE_REPO
end
end
end
end
end
lib/cocoapods/command/lib/lint.rb
0 → 100644
View file @
ac6fcb70
module
Pod
class
Command
class
Lib
<
Command
class
Lint
<
Lib
self
.
summary
=
'Validates a Pod'
self
.
description
=
<<-
DESC
Validates the Pod using the files in the working directory.
DESC
def
self
.
options
[
[
'--quick'
,
'Lint skips checks that would require to download and build the spec'
],
[
'--allow-warnings'
,
'Lint validates even if warnings are present'
],
[
'--subspec=NAME'
,
'Lint validates only the given subspec'
],
[
'--no-subspecs'
,
'Lint skips validation of subspecs'
],
[
'--no-clean'
,
'Lint leaves the build directory intact for inspection'
],
[
'--fail-fast'
,
'Lint stops on the first failing platform or subspec'
],
[
'--use-libraries'
,
'Lint uses static libraries to install the spec'
],
[
'--sources=https://github.com/artsy/Specs,master'
,
'The sources from which to pull dependent pods '
\
'(defaults to https://github.com/CocoaPods/Specs.git). '
\
'Multiple sources must be comma-delimited.'
],
[
'--private'
,
'Lint skips checks that apply only to public specs'
],
].
concat
(
super
)
end
def
initialize
(
argv
)
@quick
=
argv
.
flag?
(
'quick'
)
@allow_warnings
=
argv
.
flag?
(
'allow-warnings'
)
@clean
=
argv
.
flag?
(
'clean'
,
true
)
@fail_fast
=
argv
.
flag?
(
'fail-fast'
,
false
)
@subspecs
=
argv
.
flag?
(
'subspecs'
,
true
)
@only_subspec
=
argv
.
option
(
'subspec'
)
@use_frameworks
=
!
argv
.
flag?
(
'use-libraries'
)
@source_urls
=
argv
.
option
(
'sources'
,
'https://github.com/CocoaPods/Specs.git'
).
split
(
','
)
@private
=
argv
.
flag?
(
'private'
,
false
)
@podspecs_paths
=
argv
.
arguments!
super
end
def
validate!
super
end
def
run
UI
.
puts
podspecs_to_lint
.
each
do
|
podspec
|
validator
=
Validator
.
new
(
podspec
,
@source_urls
)
validator
.
local
=
true
validator
.
quick
=
@quick
validator
.
no_clean
=
!
@clean
validator
.
fail_fast
=
@fail_fast
validator
.
allow_warnings
=
@allow_warnings
validator
.
no_subspecs
=
!
@subspecs
||
@only_subspec
validator
.
only_subspec
=
@only_subspec
validator
.
use_frameworks
=
@use_frameworks
validator
.
ignore_public_only_results
=
@private
validator
.
validate
unless
@clean
UI
.
puts
"Pods workspace available at `
#{
validator
.
validation_dir
}
/App.xcworkspace` for inspection."
UI
.
puts
end
if
validator
.
validated?
UI
.
puts
"
#{
validator
.
spec
.
name
}
passed validation."
.
green
else
spec_name
=
podspec
spec_name
=
validator
.
spec
.
name
if
validator
.
spec
message
=
"
#{
spec_name
}
did not pass validation, due to
#{
validator
.
failure_reason
}
."
if
@clean
message
<<
"
\n
You can use the `--no-clean` option to inspect "
\
'any issue.'
end
raise
Informative
,
message
end
end
end
private
#----------------------------------------#
# !@group Private helpers
# @return [Pathname] The path of the podspec found in the current
# working directory.
#
# @raise If no podspec is found.
# @raise If multiple podspecs are found.
#
def
podspecs_to_lint
if
!
@podspecs_paths
.
empty?
Array
(
@podspecs_paths
)
else
podspecs
=
Pathname
.
glob
(
Pathname
.
pwd
+
'*.podspec{.json,}'
)
if
podspecs
.
count
.
zero?
raise
Informative
,
'Unable to find a podspec in the working '
\
'directory'
end
podspecs
end
end
end
end
end
end
spec/functional/command/inter_process_communication_spec.rb
deleted
100644 → 0
View file @
474ce948
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Command
::
IPC
do
before
do
Command
::
IPC
::
Spec
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
Command
::
IPC
::
Podfile
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
Command
::
IPC
::
List
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
Command
::
IPC
::
UpdateSearchIndex
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
Command
::
IPC
::
Repl
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
end
describe
Command
::
IPC
::
Spec
do
it
'converts a podspec to JSON and prints it to STDOUT'
do
out
=
run_command
(
'ipc'
,
'spec'
,
fixture
(
'banana-lib/BananaLib.podspec'
))
out
.
should
.
match
/"name": "BananaLib"/
out
.
should
.
match
/"version": "1.0"/
out
.
should
.
match
/"description": "Full of chunky bananas."/
end
end
#-------------------------------------------------------------------------#
describe
Command
::
IPC
::
Podfile
do
it
'converts a Podfile to yaml and prints it to STDOUT'
do
out
=
run_command
(
'ipc'
,
'podfile'
,
fixture
(
'Podfile'
))
out
.
should
.
include
(
'---'
)
out
.
should
.
match
/target_definitions:/
out
.
should
.
match
/platform: ios/
out
.
should
.
match
/- SSZipArchive:/
end
end
#-------------------------------------------------------------------------#
describe
Command
::
IPC
::
List
do
it
'prints a list of podspecs in the yaml format and prints it to STDOUT'
do
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
set
=
Specification
::
Set
.
new
(
'BananaLib'
,
[])
set
.
stubs
(
:specification
).
returns
(
spec
)
Source
::
Aggregate
.
any_instance
.
stubs
(
:all_sets
).
returns
([
set
])
out
=
run_command
(
'ipc'
,
'list'
)
out
.
should
.
include
(
'---'
)
out
.
should
.
match
/BananaLib:/
out
.
should
.
match
/description: Full of chunky bananas./
end
end
#-------------------------------------------------------------------------#
describe
Command
::
IPC
::
UpdateSearchIndex
do
it
'updates the search index and prints its path to STDOUT'
do
config
.
sources_manager
.
expects
(
:updated_search_index
)
out
=
run_command
(
'ipc'
,
'update-search-index'
)
out
.
should
.
include
(
config
.
sources_manager
.
search_index_path
.
to_s
)
end
end
#-------------------------------------------------------------------------#
describe
Command
::
IPC
::
Repl
do
it
'prints the version of CocoaPods as its first message'
do
command
=
Command
::
IPC
::
Repl
.
new
(
CLAide
::
ARGV
.
new
([]))
command
.
stubs
(
:listen
)
command
.
run
out
=
UI
.
output
out
.
should
.
match
/version: '
#{
Pod
::
VERSION
}
'/
end
it
'converts forwards the commands to the other ipc subcommands prints the result to STDOUT'
do
command
=
Command
::
IPC
::
Repl
.
new
(
CLAide
::
ARGV
.
new
([]))
command
.
execute_repl_command
(
"podfile
#{
fixture
(
'Podfile'
)
}
"
)
out
=
UI
.
output
out
.
should
.
include
(
'---'
)
out
.
should
.
match
/target_definitions:/
out
.
should
.
match
/platform: ios/
out
.
should
.
match
/- SSZipArchive:/
out
.
should
.
end_with?
(
"
\n\r\n
"
)
end
end
#-------------------------------------------------------------------------#
end
end
spec/functional/command/ipc/list_spec.rb
0 → 100644
View file @
ac6fcb70
require
File
.
expand_path
(
'../../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Command
::
IPC
::
List
do
before
do
Command
::
IPC
::
List
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
end
it
'prints a list of podspecs in the yaml format and prints it to STDOUT'
do
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
set
=
Specification
::
Set
.
new
(
'BananaLib'
,
[])
set
.
stubs
(
:specification
).
returns
(
spec
)
Source
::
Aggregate
.
any_instance
.
stubs
(
:all_sets
).
returns
([
set
])
out
=
run_command
(
'ipc'
,
'list'
)
out
.
should
.
include
(
'---'
)
out
.
should
.
match
/BananaLib:/
out
.
should
.
match
/description: Full of chunky bananas./
end
end
end
spec/functional/command/ipc/podfile_spec.rb
0 → 100644
View file @
ac6fcb70
require
File
.
expand_path
(
'../../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Command
::
IPC
::
Podfile
do
before
do
Command
::
IPC
::
Podfile
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
end
it
'converts a Podfile to yaml and prints it to STDOUT'
do
out
=
run_command
(
'ipc'
,
'podfile'
,
fixture
(
'Podfile'
))
out
.
should
.
include
(
'---'
)
out
.
should
.
match
/target_definitions:/
out
.
should
.
match
/platform: ios/
out
.
should
.
match
/- SSZipArchive:/
end
end
end
spec/functional/command/ipc/repl_spec.rb
0 → 100644
View file @
ac6fcb70
require
File
.
expand_path
(
'../../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Command
::
IPC
::
Repl
do
before
do
Command
::
IPC
::
Repl
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
Command
::
IPC
::
Podfile
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
end
it
'prints the version of CocoaPods as its first message'
do
command
=
Command
::
IPC
::
Repl
.
new
(
CLAide
::
ARGV
.
new
([]))
command
.
stubs
(
:listen
)
command
.
run
out
=
UI
.
output
out
.
should
.
match
/version: '
#{
Pod
::
VERSION
}
'/
end
it
'forwards the commands to the other ipc subcommands and prints the result to STDOUT'
do
command
=
Command
::
IPC
::
Repl
.
new
(
CLAide
::
ARGV
.
new
([]))
command
.
execute_repl_command
(
"podfile
#{
fixture
(
'Podfile'
)
}
"
)
out
=
UI
.
output
out
.
should
.
include
(
'---'
)
out
.
should
.
match
/target_definitions:/
out
.
should
.
match
/platform: ios/
out
.
should
.
match
/- SSZipArchive:/
out
.
should
.
end_with?
(
"
\n\r\n
"
)
end
end
end
spec/functional/command/ipc/spec_spec.rb
0 → 100644
View file @
ac6fcb70
require
File
.
expand_path
(
'../../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Command
::
IPC
::
Spec
do
before
do
Command
::
IPC
::
Spec
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
end
it
'converts a podspec to JSON and prints it to STDOUT'
do
out
=
run_command
(
'ipc'
,
'spec'
,
fixture
(
'banana-lib/BananaLib.podspec'
))
out
.
should
.
match
/"name": "BananaLib"/
out
.
should
.
match
/"version": "1.0"/
out
.
should
.
match
/"description": "Full of chunky bananas."/
end
end
end
spec/functional/command/ipc/update_search_index_spec.rb
0 → 100644
View file @
ac6fcb70
require
File
.
expand_path
(
'../../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Command
::
IPC
::
UpdateSearchIndex
do
before
do
Command
::
IPC
::
UpdateSearchIndex
.
any_instance
.
stubs
(
:output_pipe
).
returns
(
UI
)
end
it
'updates the search index and prints its path to STDOUT'
do
config
.
sources_manager
.
expects
(
:updated_search_index
)
out
=
run_command
(
'ipc'
,
'update-search-index'
)
out
.
should
.
include
(
config
.
sources_manager
.
search_index_path
.
to_s
)
end
end
end
spec/functional/command/lib_spec.rb
→
spec/functional/command/lib
/create
_spec.rb
View file @
ac6fcb70
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../../
../
spec_helper'
,
__FILE__
)
module
Pod
module
Pod
describe
Command
::
Lib
::
Create
do
describe
Command
::
Lib
::
Create
do
...
@@ -57,64 +57,4 @@ module Pod
...
@@ -57,64 +57,4 @@ module Pod
run_command
(
'lib'
,
'create'
,
'TestPod'
)
run_command
(
'lib'
,
'create'
,
'TestPod'
)
end
end
end
end
describe
Command
::
Lib
::
Lint
do
it
'lints the current working directory'
do
Dir
.
chdir
(
fixture
(
'integration/Reachability'
))
do
cmd
=
command
(
'lib'
,
'lint'
,
'--only-errors'
,
'--quick'
)
cmd
.
run
UI
.
output
.
should
.
include
'passed validation'
end
end
it
'lints a single spec in the current working directory'
do
Dir
.
chdir
(
fixture
(
'integration/Reachability'
))
do
cmd
=
command
(
'lib'
,
'lint'
,
'Reachability.podspec'
,
'--quick'
,
'--only-errors'
)
cmd
.
run
UI
.
output
.
should
.
include
'passed validation'
end
end
it
'fails to lint a broken spec file and cleans up'
do
Dir
.
chdir
(
temporary_directory
)
do
open
(
temporary_directory
+
'Broken.podspec'
,
'w'
)
do
|
f
|
f
<<
'Pod::Spec.new do |spec|'
f
<<
"spec.name = 'Broken'"
f
<<
'end'
end
Validator
.
any_instance
.
expects
(
:no_clean
=
).
with
(
false
)
Validator
.
any_instance
.
stubs
(
:perform_extensive_analysis
)
should
.
raise
Pod
::
Informative
do
run_command
(
'lib'
,
'lint'
,
'Broken.podspec'
)
end
UI
.
output
.
should
.
include
'Missing required attribute'
end
end
it
'fails to lint a broken spec file and leaves lint directory'
do
Dir
.
chdir
(
temporary_directory
)
do
open
(
temporary_directory
+
'Broken.podspec'
,
'w'
)
do
|
f
|
f
<<
'Pod::Spec.new do |spec|'
f
<<
"spec.name = 'Broken'"
f
<<
'end'
end
Validator
.
any_instance
.
expects
(
:no_clean
=
).
with
(
true
)
Validator
.
any_instance
.
stubs
(
:perform_extensive_analysis
)
should
.
raise
Pod
::
Informative
do
run_command
(
'lib'
,
'lint'
,
'Broken.podspec'
,
'--no-clean'
)
end
UI
.
output
.
should
.
include
'Missing required attribute'
UI
.
output
.
should
.
include
'Pods workspace available at'
end
end
it
'fails to lint if the spec is not loaded'
do
Dir
.
chdir
(
temporary_directory
)
do
should
.
raise
Pod
::
Informative
do
run_command
(
'lib'
,
'lint'
,
'404.podspec'
)
end
UI
.
output
.
should
.
include
'could not be loaded'
end
end
end
end
end
spec/functional/command/lib/list_spec.rb
0 → 100644
View file @
ac6fcb70
require
File
.
expand_path
(
'../../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Command
::
Lib
::
Lint
do
it
'lints the current working directory'
do
Dir
.
chdir
(
fixture
(
'integration/Reachability'
))
do
cmd
=
command
(
'lib'
,
'lint'
,
'--only-errors'
,
'--quick'
)
cmd
.
run
UI
.
output
.
should
.
include
'passed validation'
end
end
it
'lints a single spec in the current working directory'
do
Dir
.
chdir
(
fixture
(
'integration/Reachability'
))
do
cmd
=
command
(
'lib'
,
'lint'
,
'Reachability.podspec'
,
'--quick'
,
'--only-errors'
)
cmd
.
run
UI
.
output
.
should
.
include
'passed validation'
end
end
it
'fails to lint a broken spec file and cleans up'
do
Dir
.
chdir
(
temporary_directory
)
do
open
(
temporary_directory
+
'Broken.podspec'
,
'w'
)
do
|
f
|
f
<<
'Pod::Spec.new do |spec|'
f
<<
"spec.name = 'Broken'"
f
<<
'end'
end
Validator
.
any_instance
.
expects
(
:no_clean
=
).
with
(
false
)
Validator
.
any_instance
.
stubs
(
:perform_extensive_analysis
)
should
.
raise
Pod
::
Informative
do
run_command
(
'lib'
,
'lint'
,
'Broken.podspec'
)
end
UI
.
output
.
should
.
include
'Missing required attribute'
end
end
it
'fails to lint a broken spec file and leaves lint directory'
do
Dir
.
chdir
(
temporary_directory
)
do
open
(
temporary_directory
+
'Broken.podspec'
,
'w'
)
do
|
f
|
f
<<
'Pod::Spec.new do |spec|'
f
<<
"spec.name = 'Broken'"
f
<<
'end'
end
Validator
.
any_instance
.
expects
(
:no_clean
=
).
with
(
true
)
Validator
.
any_instance
.
stubs
(
:perform_extensive_analysis
)
should
.
raise
Pod
::
Informative
do
run_command
(
'lib'
,
'lint'
,
'Broken.podspec'
,
'--no-clean'
)
end
UI
.
output
.
should
.
include
'Missing required attribute'
UI
.
output
.
should
.
include
'Pods workspace available at'
end
end
it
'fails to lint if the spec is not loaded'
do
Dir
.
chdir
(
temporary_directory
)
do
should
.
raise
Pod
::
Informative
do
run_command
(
'lib'
,
'lint'
,
'404.podspec'
)
end
UI
.
output
.
should
.
include
'could not be loaded'
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