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
a587e4c4
Commit
a587e4c4
authored
Apr 23, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Pod::Command::Spec] support for subspecs
parent
deb70fb0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
60 deletions
+67
-60
spec.rb
lib/cocoapods/command/spec.rb
+66
-59
specification.rb
lib/cocoapods/specification.rb
+1
-1
No files found.
lib/cocoapods/command/spec.rb
View file @
a587e4c4
...
@@ -18,7 +18,6 @@ module Pod
...
@@ -18,7 +18,6 @@ module Pod
provided it validates all its specs.}
provided it validates all its specs.}
end
end
def
self
.
options
def
self
.
options
[
[
"--no-install"
,
"Lint skips checks that would require to donwload the spec"
],
[
[
"--no-install"
,
"Lint skips checks that would require to donwload the spec"
],
[
"--only-errors"
,
"Lint validates even if warnings are present"
]
].
concat
(
super
)
[
"--only-errors"
,
"Lint validates even if warnings are present"
]
].
concat
(
super
)
...
@@ -68,7 +67,6 @@ module Pod
...
@@ -68,7 +67,6 @@ module Pod
end
end
puts
puts
all_valid
=
lint_specs_files
(
files
,
is_repo
)
all_valid
=
lint_specs_files
(
files
,
is_repo
)
raise
Informative
,
"[!] Not all specs passed validation"
.
red
unless
all_valid
raise
Informative
,
"[!] Not all specs passed validation"
.
red
unless
all_valid
end
end
...
@@ -85,70 +83,77 @@ module Pod
...
@@ -85,70 +83,77 @@ module Pod
def
lint_specs_files
(
files
,
is_repo
)
def
lint_specs_files
(
files
,
is_repo
)
tmp_dir
=
Pathname
.
new
(
'/tmp/CocoaPods/Lint'
)
tmp_dir
=
Pathname
.
new
(
'/tmp/CocoaPods/Lint'
)
all_valid
=
true
all_valid
=
true
files
.
each
do
|
file
|
files
.
each
do
|
file
|
file
=
file
.
realpath
file
=
file
.
realpath
spec
=
Specification
.
from_file
(
file
)
file_spec
=
Specification
.
from_file
(
file
)
# Show immediatly which pod is being processed.
# This line will be overwritten once the result is known
specs
=
file_spec
.
recursive_subspecs
.
any?
?
file_spec
.
recursive_subspecs
:
[
file_spec
]
print
" ->
#{
spec
}
\r
"
unless
config
.
silent?
||
is_repo
specs
.
each
do
|
spec
|
$stdout
.
flush
# Show immediatly which pod is being processed.
# This line will be overwritten once the result is known
spec
.
validate!
print
" ->
#{
spec
}
\r
"
unless
config
.
silent?
||
is_repo
warnings
=
warnings_for_spec
(
spec
,
file
,
is_repo
)
$stdout
.
flush
deprecations
=
deprecation_notices_for_spec
(
spec
,
file
,
is_repo
)
# TODO: check that the dependencies of the spec exist
spec
.
validate!
if
is_repo
||
@no_install
warnings
=
warnings_for_spec
(
spec
,
file
,
is_repo
)
build_messages
,
file_errors
=
[],
[]
deprecations
=
deprecation_notices_for_spec
(
spec
,
file
,
is_repo
)
else
if
is_repo
||
@no_install
tmp_dir
.
mkpath
build_messages
,
file_errors
=
[],
[]
build_messages
=
Dir
.
chdir
(
tmp_dir
)
{
build_errors_for_spec
(
spec
,
file
,
is_repo
)
}
else
file_errors
=
Dir
.
chdir
(
tmp_dir
)
{
file_errors_for_spec
(
spec
,
file
,
is_repo
)
}
tmp_dir
.
mkpath
tmp_dir
.
rmtree
build_messages
=
Dir
.
chdir
(
tmp_dir
)
{
build_errors_for_spec
(
spec
,
file
,
is_repo
)
}
end
file_errors
=
Dir
.
chdir
(
tmp_dir
)
{
file_errors_for_spec
(
spec
,
file
,
is_repo
)
}
tmp_dir
.
rmtree
end
# Errors compromise the functionality of a spec, warnings can be ignored
# Errors compromise the functionality of a spec, warnings can be ignored
build_errors
=
build_messages
.
select
{
|
msg
|
msg
.
include?
(
'error'
)}
build_errors
=
build_messages
.
select
{
|
msg
|
msg
.
include?
(
'error'
)}
build_warnings
=
build_messages
-
build_errors
build_warnings
=
build_messages
-
build_errors
all
=
warnings
+
deprecations
+
build_messages
+
file_errors
all
=
warnings
+
deprecations
+
build_messages
+
file_errors
errors
=
file_errors
+
build_errors
errors
=
file_errors
+
build_errors
warnings
=
all
-
errors
warnings
=
all
-
errors
if
@only_errors
all_valid
=
false
unless
errors
.
empty?
else
all_valid
=
false
unless
(
all
-
build_warnings
).
empty?
end
# Clean duplicated multiplatform messages
if
@only_errors
[
errors
,
warnings
].
each
do
|
messages
|
all_valid
=
false
unless
errors
.
empty?
duplicate_candiates
=
messages
.
select
{
|
l
|
l
.
include?
(
"ios: "
)}
else
duplicated
=
duplicate_candiates
.
select
{
|
l
|
messages
.
include?
(
l
.
gsub
(
/ios: /
,
'osx: '
))
}
all_valid
=
false
unless
(
all
-
build_warnings
).
empty?
duplicated
.
each
do
|
l
|
clean
=
l
.
gsub
(
/ios: /
,
''
)
messages
.
insert
(
messages
.
index
(
l
),
clean
)
messages
.
delete
(
l
)
messages
.
delete
(
'osx: '
+
clean
)
end
end
end
# This overwrites the previously printed text
clean_duplicate_platfrom_messages
(
errors
)
unless
config
.
silent?
clean_duplicate_platfrom_messages
(
warnings
)
if
errors
.
empty?
&&
warnings
.
empty?
puts
" -> "
.
green
+
"
#{
spec
}
passed validation"
unless
is_repo
# This overwrites the previously printed text
elsif
errors
.
empty?
unless
config
.
silent?
puts
" -> "
.
yellow
+
spec
.
to_s
if
errors
.
empty?
&&
warnings
.
empty?
else
puts
" -> "
.
green
+
"
#{
spec
}
passed validation"
unless
is_repo
puts
" -> "
.
red
+
spec
.
to_s
elsif
errors
.
empty?
puts
" -> "
.
yellow
+
spec
.
to_s
else
puts
" -> "
.
red
+
spec
.
to_s
end
end
end
end
warnings
.
each
{
|
msg
|
puts
" - WARN |
#{
msg
}
"
}
unless
config
.
silent?
warnings
.
each
{
|
msg
|
puts
" - WARN |
#{
msg
}
"
}
unless
config
.
silent?
errors
.
each
{
|
msg
|
puts
" - ERROR |
#{
msg
}
"
}
unless
config
.
silent?
errors
.
each
{
|
msg
|
puts
" - ERROR |
#{
msg
}
"
}
unless
config
.
silent?
puts
unless
config
.
silent?
||
(
is_repo
&&
all
.
flatten
.
empty?
)
puts
unless
config
.
silent?
||
(
is_repo
&&
all
.
flatten
.
empty?
)
end
end
end
all_valid
all_valid
end
end
def
clean_duplicate_platfrom_messages
(
messages
)
duplicate_candiates
=
messages
.
select
{
|
l
|
l
.
include?
(
"ios: "
)}
duplicated
=
duplicate_candiates
.
select
{
|
l
|
messages
.
include?
(
l
.
gsub
(
/ios: /
,
'osx: '
))
}
duplicated
.
uniq
.
each
do
|
l
|
clean
=
l
.
gsub
(
/ios: /
,
''
)
puts
"duplicated: "
.
magenta
+
l
messages
.
insert
(
messages
.
index
(
l
),
clean
)
messages
.
delete
(
l
)
messages
.
delete
(
'osx: '
+
clean
)
end
end
# It checks a spec for minor non fatal defects
# It checks a spec for minor non fatal defects
#
#
# It returns a array of messages
# It returns a array of messages
...
@@ -163,14 +168,16 @@ module Pod
...
@@ -163,14 +168,16 @@ module Pod
warnings
<<
"Github repositories should end in `.git'"
if
source
&&
source
[
:git
]
=~
/github.com/
&&
source
[
:git
]
!~
/.*\.git/
warnings
<<
"Github repositories should end in `.git'"
if
source
&&
source
[
:git
]
=~
/github.com/
&&
source
[
:git
]
!~
/.*\.git/
warnings
<<
"The description should end with a dot"
if
spec
.
description
&&
spec
.
description
!~
/.*\./
warnings
<<
"The description should end with a dot"
if
spec
.
description
&&
spec
.
description
!~
/.*\./
warnings
<<
"The summary should end with a dot"
if
spec
.
summary
!~
/.*\./
warnings
<<
"The summary should end with a dot"
if
spec
.
summary
!~
/.*\./
#TODO: the following 'is_repo' and '@no_install' checks are there only because at the time of 0.6.0rc1 it would be triggered in all specs
warnings
<<
"Missing license[:file] or [:text]"
unless
is_repo
||
@no_install
||
license
&&
(
license
[
:file
]
||
license
[
:text
])
warnings
<<
"Missing license[:file] or [:text]"
unless
is_repo
||
@no_install
||
license
&&
(
license
[
:file
]
||
license
[
:text
])
warnings
<<
"Comments must be deleted"
if
text
=~
/^\w*#/
# allow a single line comment as it is generally used in subspecs
#TODO: the previous 'is_repo' and '@no_install' checks are there only because at the time of 0.6.0rc1 it would be triggered in all specs
warnings
<<
"Comments must be deleted"
if
text
=~
/^\w*#\n\w*#/
warnings
warnings
end
end
def
path_matches_name?
(
file
,
spec
)
def
path_matches_name?
(
file
,
spec
)
file
.
basename
.
to_s
==
spec
.
name
+
'.podspec'
spec_name
=
spec
.
name
.
match
(
/[^\/]*/
)[
0
]
file
.
basename
.
to_s
==
spec_name
+
'.podspec'
end
end
# It reads a podspec file and checks for strings corresponding
# It reads a podspec file and checks for strings corresponding
...
@@ -221,7 +228,7 @@ module Pod
...
@@ -221,7 +228,7 @@ module Pod
def
process_xcode_build_output
(
output
)
def
process_xcode_build_output
(
output
)
output_by_line
=
output
.
split
(
"
\n
"
)
output_by_line
=
output
.
split
(
"
\n
"
)
selected_lines
=
output_by_line
.
select
do
|
l
|
selected_lines
=
output_by_line
.
select
do
|
l
|
l
.
include?
(
'error'
)\
l
.
include?
(
'error'
)
&&
!
l
.
include?
(
'error generated.'
)
\
||
l
.
include?
(
'warning'
)
&&
!
l
.
include?
(
'warning generated.'
)\
||
l
.
include?
(
'warning'
)
&&
!
l
.
include?
(
'warning generated.'
)\
||
l
.
include?
(
'note'
)
||
l
.
include?
(
'note'
)
end
end
...
@@ -258,7 +265,7 @@ module Pod
...
@@ -258,7 +265,7 @@ module Pod
end
end
def
platform_names
(
spec
)
def
platform_names
(
spec
)
spec
.
platform
.
name
||
[
:ios
,
:osx
]
spec
.
platform
.
name
?
[
spec
.
platform
.
name
]
:
[
:ios
,
:osx
]
end
end
# Templates and github information retrival for spec create
# Templates and github information retrival for spec create
...
...
lib/cocoapods/specification.rb
View file @
a587e4c4
...
@@ -436,7 +436,7 @@ module Pod
...
@@ -436,7 +436,7 @@ module Pod
end
end
# Override the getters to always return the value of the top level parent spec.
# Override the getters to always return the value of the top level parent spec.
[
:version
,
:summary
,
:platform
,
:license
,
:authors
,
:requires_arc
,
:compiler_flags
,
:documentation
].
each
do
|
attr
|
[
:version
,
:summary
,
:platform
,
:license
,
:authors
,
:requires_arc
,
:compiler_flags
,
:documentation
,
:homepage
].
each
do
|
attr
|
define_method
(
attr
)
{
top_level_parent
.
send
(
attr
)
}
define_method
(
attr
)
{
top_level_parent
.
send
(
attr
)
}
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