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
68b677eb
Commit
68b677eb
authored
Oct 01, 2014
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2566 from CocoaPods/validator-sources
[Validator] Allow the validator to take specific sources
parents
89474b59
c1704945
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
21 deletions
+46
-21
CHANGELOG.md
CHANGELOG.md
+9
-2
lib.rb
lib/cocoapods/command/lib.rb
+5
-2
push.rb
lib/cocoapods/command/repo/push.rb
+1
-1
spec.rb
lib/cocoapods/command/spec.rb
+5
-2
validator.rb
lib/cocoapods/validator.rb
+13
-1
validator_spec.rb
spec/unit/validator_spec.rb
+13
-13
No files found.
CHANGELOG.md
View file @
68b677eb
...
@@ -7,14 +7,21 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
...
@@ -7,14 +7,21 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
##### Bug Fixes
##### Bug Fixes
*
Improved sanitizing of configuration names to avoid generating invalid
*
Improved sanitizing of configuration names to avoid generating invalid
preprocessor definitions.
preprocessor definitions.
[
Boris Bügling
](
https://github.com/neonichu
)
[
Boris Bügling
](
https://github.com/neonichu
)
[
#2542
](
https://github.com/CocoaPods/CocoaPods/issues/2542
)
[
#2542
](
https://github.com/CocoaPods/CocoaPods/issues/2542
)
*
More robust generation of source names from URLs.
*
More robust generation of source names from URLs.
[
Samuel Giddins
](
https://github.com/segiddins
)
[
Samuel Giddins
](
https://github.com/segiddins
)
[
#2534
](
https://github.com/CocoaPods/CocoaPods/issues/2534
)
[
#2534
](
https://github.com/CocoaPods/CocoaPods/issues/2534
)
*
Allow the
`Validator`
to only use specific sources.
Allows customizable source for
`pod spec lint`
and
`pod lib lint`
,
with both defaulting to
`master`
.
[
Samuel Giddins
](
https://github.com/segiddins
)
[
#2543
](
https://github.com/CocoaPods/CocoaPods/issues/2543
)
[
cocoapods-trunk#28
](
https://github.com/CocoaPods/cocoapods-trunk/issues/28
)
## 0.34.1
## 0.34.1
...
...
lib/cocoapods/command/lib.rb
View file @
68b677eb
...
@@ -112,7 +112,9 @@ module Pod
...
@@ -112,7 +112,9 @@ module Pod
[
'--only-errors'
,
'Lint validates even if warnings are present'
],
[
'--only-errors'
,
'Lint validates even if warnings are present'
],
[
'--subspec=NAME'
,
'Lint validates only the given subspec'
],
[
'--subspec=NAME'
,
'Lint validates only the given subspec'
],
[
'--no-subspecs'
,
'Lint skips validation of subspecs'
],
[
'--no-subspecs'
,
'Lint skips validation of subspecs'
],
[
'--no-clean'
,
'Lint leaves the build directory intact for inspection'
]].
concat
(
super
)
[
'--no-clean'
,
'Lint leaves the build directory intact for inspection'
],
[
'--sources=https://github.com/artsy/Specs'
,
'The sources to pull dependant pods from '
\
'(defaults to https://github.com/CocoaPods/Specs.git)'
]].
concat
(
super
)
end
end
def
initialize
(
argv
)
def
initialize
(
argv
)
...
@@ -121,6 +123,7 @@ module Pod
...
@@ -121,6 +123,7 @@ module Pod
@clean
=
argv
.
flag?
(
'clean'
,
true
)
@clean
=
argv
.
flag?
(
'clean'
,
true
)
@subspecs
=
argv
.
flag?
(
'subspecs'
,
true
)
@subspecs
=
argv
.
flag?
(
'subspecs'
,
true
)
@only_subspec
=
argv
.
option
(
'subspec'
)
@only_subspec
=
argv
.
option
(
'subspec'
)
@source_urls
=
argv
.
option
(
'sources'
,
'https://github.com/CocoaPods/Specs.git'
).
split
(
','
)
@podspecs_paths
=
argv
.
arguments!
@podspecs_paths
=
argv
.
arguments!
super
super
end
end
...
@@ -133,7 +136,7 @@ module Pod
...
@@ -133,7 +136,7 @@ module Pod
UI
.
puts
UI
.
puts
podspecs_to_lint
.
each
do
|
podspec
|
podspecs_to_lint
.
each
do
|
podspec
|
validator
=
Validator
.
new
(
podspec
)
validator
=
Validator
.
new
(
podspec
,
@source_urls
)
validator
.
local
=
true
validator
.
local
=
true
validator
.
quick
=
@quick
validator
.
quick
=
@quick
validator
.
no_clean
=
!
@clean
validator
.
no_clean
=
!
@clean
...
...
lib/cocoapods/command/repo/push.rb
View file @
68b677eb
...
@@ -82,7 +82,7 @@ module Pod
...
@@ -82,7 +82,7 @@ module Pod
def
validate_podspec_files
def
validate_podspec_files
UI
.
puts
"
\n
Validating
#{
'spec'
.
pluralize
(
count
)
}
"
.
yellow
UI
.
puts
"
\n
Validating
#{
'spec'
.
pluralize
(
count
)
}
"
.
yellow
podspec_files
.
each
do
|
podspec
|
podspec_files
.
each
do
|
podspec
|
validator
=
Validator
.
new
(
podspec
)
validator
=
Validator
.
new
(
podspec
,
SourcesManager
.
all
.
map
(
&
:url
)
)
validator
.
only_errors
=
@allow_warnings
validator
.
only_errors
=
@allow_warnings
begin
begin
validator
.
validate
validator
.
validate
...
...
lib/cocoapods/command/spec.rb
View file @
68b677eb
...
@@ -67,7 +67,9 @@ module Pod
...
@@ -67,7 +67,9 @@ module Pod
[
'--only-errors'
,
'Lint validates even if warnings are present'
],
[
'--only-errors'
,
'Lint validates even if warnings are present'
],
[
'--subspec=NAME'
,
'Lint validates only the given subspec'
],
[
'--subspec=NAME'
,
'Lint validates only the given subspec'
],
[
'--no-subspecs'
,
'Lint skips validation of subspecs'
],
[
'--no-subspecs'
,
'Lint skips validation of subspecs'
],
[
'--no-clean'
,
'Lint leaves the build directory intact for inspection'
]].
concat
(
super
)
[
'--no-clean'
,
'Lint leaves the build directory intact for inspection'
],
[
'--sources=https://github.com/artsy/Specs'
,
'The sources to pull dependant pods from '
\
'(defaults to https://github.com/CocoaPods/Specs.git)'
]].
concat
(
super
)
end
end
def
initialize
(
argv
)
def
initialize
(
argv
)
...
@@ -76,6 +78,7 @@ module Pod
...
@@ -76,6 +78,7 @@ module Pod
@clean
=
argv
.
flag?
(
'clean'
,
true
)
@clean
=
argv
.
flag?
(
'clean'
,
true
)
@subspecs
=
argv
.
flag?
(
'subspecs'
,
true
)
@subspecs
=
argv
.
flag?
(
'subspecs'
,
true
)
@only_subspec
=
argv
.
option
(
'subspec'
)
@only_subspec
=
argv
.
option
(
'subspec'
)
@source_urls
=
argv
.
option
(
'sources'
,
'https://github.com/CocoaPods/Specs.git'
).
split
(
','
)
@podspecs_paths
=
argv
.
arguments!
@podspecs_paths
=
argv
.
arguments!
super
super
end
end
...
@@ -84,7 +87,7 @@ module Pod
...
@@ -84,7 +87,7 @@ module Pod
UI
.
puts
UI
.
puts
invalid_count
=
0
invalid_count
=
0
podspecs_to_lint
.
each
do
|
podspec
|
podspecs_to_lint
.
each
do
|
podspec
|
validator
=
Validator
.
new
(
podspec
)
validator
=
Validator
.
new
(
podspec
,
@source_urls
)
validator
.
quick
=
@quick
validator
.
quick
=
@quick
validator
.
no_clean
=
!
@clean
validator
.
no_clean
=
!
@clean
validator
.
only_errors
=
@only_errors
validator
.
only_errors
=
@only_errors
...
...
lib/cocoapods/validator.rb
View file @
68b677eb
...
@@ -19,7 +19,11 @@ module Pod
...
@@ -19,7 +19,11 @@ module Pod
# @param [Specification, Pathname, String] spec_or_path
# @param [Specification, Pathname, String] spec_or_path
# the Specification or the path of the `podspec` file to lint.
# the Specification or the path of the `podspec` file to lint.
#
#
def
initialize
(
spec_or_path
)
# @param [Array<String>] source_urls
# the Source URLs to use in creating a {Podfile}.
#
def
initialize
(
spec_or_path
,
source_urls
)
@source_urls
=
source_urls
@linter
=
Specification
::
Linter
.
new
(
spec_or_path
)
@linter
=
Specification
::
Linter
.
new
(
spec_or_path
)
end
end
...
@@ -412,6 +416,13 @@ module Pod
...
@@ -412,6 +416,13 @@ module Pod
# !@group Helpers
# !@group Helpers
# @return [Array<Source>] an array of sources used to create the
# {Podfile} used in the linting process
#
def
sources
@sources
||=
@source_urls
.
map
{
|
url
|
SourcesManager
.
find_or_create_source_with_url
(
url
)
}
end
# @return [Podfile] a podfile that requires the specification on the
# @return [Podfile] a podfile that requires the specification on the
# current platform.
# current platform.
#
#
...
@@ -423,6 +434,7 @@ module Pod
...
@@ -423,6 +434,7 @@ module Pod
podspec
=
file
.
realpath
podspec
=
file
.
realpath
local
=
local?
local
=
local?
podfile
=
Pod
::
Podfile
.
new
do
podfile
=
Pod
::
Podfile
.
new
do
sources
.
each
{
|
s
|
source
(
s
.
url
)
}
platform
(
platform_name
,
deployment_target
)
platform
(
platform_name
,
deployment_target
)
if
local
if
local
pod
name
,
:path
=>
podspec
.
dirname
.
to_s
pod
name
,
:path
=>
podspec
.
dirname
.
to_s
...
...
spec/unit/validator_spec.rb
View file @
68b677eb
...
@@ -47,7 +47,7 @@ module Pod
...
@@ -47,7 +47,7 @@ module Pod
describe
'Quick mode'
do
describe
'Quick mode'
do
it
'validates a correct podspec'
do
it
'validates a correct podspec'
do
sut
=
Validator
.
new
(
podspec_path
)
sut
=
Validator
.
new
(
podspec_path
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
quick
=
true
sut
.
quick
=
true
sut
.
validate
sut
.
validate
sut
.
results
.
should
==
[]
sut
.
results
.
should
==
[]
...
@@ -57,7 +57,7 @@ module Pod
...
@@ -57,7 +57,7 @@ module Pod
it
'lints the podspec during validation'
do
it
'lints the podspec during validation'
do
podspec
=
stub_podspec
(
/.*name.*/
,
'"name": "TEST",'
)
podspec
=
stub_podspec
(
/.*name.*/
,
'"name": "TEST",'
)
file
=
write_podspec
(
podspec
)
file
=
write_podspec
(
podspec
)
sut
=
Validator
.
new
(
file
)
sut
=
Validator
.
new
(
file
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
quick
=
true
sut
.
quick
=
true
sut
.
validate
sut
.
validate
sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/should match the name/
sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/should match the name/
...
@@ -66,7 +66,7 @@ module Pod
...
@@ -66,7 +66,7 @@ module Pod
it
'respects quick mode'
do
it
'respects quick mode'
do
file
=
write_podspec
(
stub_podspec
)
file
=
write_podspec
(
stub_podspec
)
sut
=
Validator
.
new
(
file
)
sut
=
Validator
.
new
(
file
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
quick
=
true
sut
.
quick
=
true
sut
.
expects
(
:perform_extensive_analysis
).
never
sut
.
expects
(
:perform_extensive_analysis
).
never
sut
.
validate
sut
.
validate
...
@@ -75,7 +75,7 @@ module Pod
...
@@ -75,7 +75,7 @@ module Pod
it
'respects the only errors option'
do
it
'respects the only errors option'
do
podspec
=
stub_podspec
(
/.*summary.*/
,
'"summary": "A short description of",'
)
podspec
=
stub_podspec
(
/.*summary.*/
,
'"summary": "A short description of",'
)
file
=
write_podspec
(
podspec
)
file
=
write_podspec
(
podspec
)
sut
=
Validator
.
new
(
file
)
sut
=
Validator
.
new
(
file
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
quick
=
true
sut
.
quick
=
true
sut
.
only_errors
=
true
sut
.
only_errors
=
true
sut
.
validate
sut
.
validate
...
@@ -85,7 +85,7 @@ module Pod
...
@@ -85,7 +85,7 @@ module Pod
it
'handles symlinks'
do
it
'handles symlinks'
do
file
=
write_podspec
(
stub_podspec
)
file
=
write_podspec
(
stub_podspec
)
validator
=
Validator
.
new
(
file
)
validator
=
Validator
.
new
(
file
,
SourcesManager
.
master
.
map
(
&
:url
)
)
validator
.
quick
=
true
validator
.
quick
=
true
validator
.
stubs
(
:validate_url
)
validator
.
stubs
(
:validate_url
)
validator
.
validate
validator
.
validate
...
@@ -99,7 +99,7 @@ module Pod
...
@@ -99,7 +99,7 @@ module Pod
describe
'URL validation'
do
describe
'URL validation'
do
before
do
before
do
@sut
=
Validator
.
new
(
podspec_path
)
@sut
=
Validator
.
new
(
podspec_path
,
SourcesManager
.
master
.
map
(
&
:url
)
)
@sut
.
stubs
(
:install_pod
)
@sut
.
stubs
(
:install_pod
)
@sut
.
stubs
(
:build_pod
)
@sut
.
stubs
(
:build_pod
)
@sut
.
stubs
(
:check_file_patterns
)
@sut
.
stubs
(
:check_file_patterns
)
...
@@ -257,7 +257,7 @@ module Pod
...
@@ -257,7 +257,7 @@ module Pod
it
'respects the no clean option'
do
it
'respects the no clean option'
do
file
=
write_podspec
(
stub_podspec
)
file
=
write_podspec
(
stub_podspec
)
sut
=
Validator
.
new
(
file
)
sut
=
Validator
.
new
(
file
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
stubs
(
:validate_url
)
sut
.
stubs
(
:validate_url
)
sut
.
no_clean
=
true
sut
.
no_clean
=
true
sut
.
validate
sut
.
validate
...
@@ -266,7 +266,7 @@ module Pod
...
@@ -266,7 +266,7 @@ module Pod
it
'builds the pod per platform'
do
it
'builds the pod per platform'
do
file
=
write_podspec
(
stub_podspec
)
file
=
write_podspec
(
stub_podspec
)
sut
=
Validator
.
new
(
file
)
sut
=
Validator
.
new
(
file
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
stubs
(
:validate_url
)
sut
.
stubs
(
:validate_url
)
sut
.
expects
(
:install_pod
).
twice
sut
.
expects
(
:install_pod
).
twice
sut
.
expects
(
:build_pod
).
twice
sut
.
expects
(
:build_pod
).
twice
...
@@ -275,7 +275,7 @@ module Pod
...
@@ -275,7 +275,7 @@ module Pod
end
end
it
'uses the deployment target of the specification'
do
it
'uses the deployment target of the specification'
do
sut
=
Validator
.
new
(
podspec_path
)
sut
=
Validator
.
new
(
podspec_path
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
stubs
(
:validate_url
)
sut
.
stubs
(
:validate_url
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
stubs
(
:validate_screenshots
)
podfile
=
sut
.
send
(
:podfile_from_spec
,
:ios
,
'5.0'
)
podfile
=
sut
.
send
(
:podfile_from_spec
,
:ios
,
'5.0'
)
...
@@ -284,7 +284,7 @@ module Pod
...
@@ -284,7 +284,7 @@ module Pod
end
end
it
'respects the local option'
do
it
'respects the local option'
do
sut
=
Validator
.
new
(
podspec_path
)
sut
=
Validator
.
new
(
podspec_path
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
stubs
(
:validate_url
)
sut
.
stubs
(
:validate_url
)
podfile
=
sut
.
send
(
:podfile_from_spec
,
:ios
,
'5.0'
)
podfile
=
sut
.
send
(
:podfile_from_spec
,
:ios
,
'5.0'
)
deployment_target
=
podfile
.
target_definitions
[
'Pods'
].
platform
.
deployment_target
deployment_target
=
podfile
.
target_definitions
[
'Pods'
].
platform
.
deployment_target
...
@@ -292,7 +292,7 @@ module Pod
...
@@ -292,7 +292,7 @@ module Pod
end
end
it
'uses xcodebuild to generate notes and warnings'
do
it
'uses xcodebuild to generate notes and warnings'
do
sut
=
Validator
.
new
(
podspec_path
)
sut
=
Validator
.
new
(
podspec_path
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
stubs
(
:check_file_patterns
)
sut
.
stubs
(
:check_file_patterns
)
sut
.
stubs
(
:xcodebuild
).
returns
(
"file.m:1:1: warning: direct access to objective-c's isa is deprecated"
)
sut
.
stubs
(
:xcodebuild
).
returns
(
"file.m:1:1: warning: direct access to objective-c's isa is deprecated"
)
sut
.
stubs
(
:validate_url
)
sut
.
stubs
(
:validate_url
)
...
@@ -313,7 +313,7 @@ module Pod
...
@@ -313,7 +313,7 @@ module Pod
it
'checks for file patterns'
do
it
'checks for file patterns'
do
file
=
write_podspec
(
stub_podspec
(
/.*source_files.*/
,
'"source_files": "wrong_paht.*",'
))
file
=
write_podspec
(
stub_podspec
(
/.*source_files.*/
,
'"source_files": "wrong_paht.*",'
))
sut
=
Validator
.
new
(
file
)
sut
=
Validator
.
new
(
file
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
stubs
(
:build_pod
)
sut
.
stubs
(
:build_pod
)
sut
.
stubs
(
:validate_url
)
sut
.
stubs
(
:validate_url
)
sut
.
validate
sut
.
validate
...
@@ -328,7 +328,7 @@ module Pod
...
@@ -328,7 +328,7 @@ module Pod
file
=
write_podspec
(
podspec
,
'ZKit.podspec.json'
)
file
=
write_podspec
(
podspec
,
'ZKit.podspec.json'
)
spec
=
Specification
.
from_file
(
file
)
spec
=
Specification
.
from_file
(
file
)
sut
=
Validator
.
new
(
spec
)
sut
=
Validator
.
new
(
spec
,
SourcesManager
.
master
.
map
(
&
:url
)
)
sut
.
stubs
(
:validate_url
)
sut
.
stubs
(
:validate_url
)
sut
.
stubs
(
:build_pod
)
sut
.
stubs
(
:build_pod
)
sut
.
validate
sut
.
validate
...
...
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