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
0c5c43c1
Commit
0c5c43c1
authored
May 10, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speficiation#activate_for_platform and collateral improvements.
parent
8b505899
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
145 additions
and
121 deletions
+145
-121
spec.rb
lib/cocoapods/command/spec.rb
+0
-0
target_installer.rb
lib/cocoapods/installer/target_installer.rb
+7
-8
local_pod.rb
lib/cocoapods/local_pod.rb
+9
-6
platform.rb
lib/cocoapods/platform.rb
+1
-1
resolver.rb
lib/cocoapods/resolver.rb
+3
-2
specification.rb
lib/cocoapods/specification.rb
+48
-41
spec_spec.rb
spec/functional/command/spec_spec.rb
+13
-12
spec_spec.rb
spec/unit/command/spec_spec.rb
+12
-12
platform_spec.rb
spec/unit/platform_spec.rb
+9
-9
specification_spec.rb
spec/unit/specification_spec.rb
+43
-30
No files found.
lib/cocoapods/command/spec.rb
View file @
0c5c43c1
This diff is collapsed.
Click to expand it.
lib/cocoapods/installer/target_installer.rb
View file @
0c5c43c1
...
...
@@ -63,19 +63,18 @@ module Pod
@target
=
@project
.
add_pod_target
(
@target_definition
.
label
,
@target_definition
.
platform
)
pods
.
each
do
|
pod
|
# TODO add methods like xcconfig to LocalPod as well? (which returns the correct platform)
xcconfig
.
merge!
(
pod
.
specification
.
xcconfig
[
@target_definition
.
platform
.
name
])
xcconfig
.
merge!
(
pod
.
specification
.
xcconfig
)
pod
.
add_to_target
(
@target
)
# TODO: this doesn't need to be done here, it has nothing to do with the target
pod
.
link_headers
end
xcconfig
.
merge!
(
'HEADER_SEARCH_PATHS'
=>
quoted
(
sandbox
.
header_search_paths
).
join
(
" "
))
support_files_group
=
@project
.
group
(
"Targets Support Files"
).
create_group
(
@target_definition
.
label
)
support_files_group
.
create_files
(
target_support_files
)
xcconfig_file
=
support_files_group
.
files
.
where
(
:path
=>
@target_definition
.
xcconfig_name
)
configure_build_configurations
(
xcconfig_file
)
create_files
(
pods
,
sandbox
)
...
...
@@ -104,13 +103,13 @@ module Pod
puts
"* Generating copy resources script at `
#{
sandbox
.
root
+
@target_definition
.
copy_resources_script_name
}
'"
if
config
.
verbose?
copy_resources_script_for
(
pods
).
save_as
(
sandbox
.
root
+
@target_definition
.
copy_resources_script_name
)
end
private
def
quoted
(
strings
)
strings
.
map
{
|
s
|
"
\"
#{
s
}
\"
"
}
end
def
default_ld_flags
flags
=
%w{-ObjC}
flags
<<
'-fobjc-arc'
if
@podfile
.
set_arc_compatibility_flag?
&&
self
.
requires_arc
...
...
lib/cocoapods/local_pod.rb
View file @
0c5c43c1
...
...
@@ -2,10 +2,10 @@ module Pod
class
LocalPod
attr_reader
:specification
attr_reader
:sandbox
attr_reader
:platform
def
initialize
(
specification
,
sandbox
,
platform
)
@specification
,
@sandbox
,
@platform
=
specification
,
sandbox
,
platform
@specification
,
@sandbox
=
specification
,
sandbox
@specification
.
activate_platform
(
platform
)
end
def
self
.
from_podspec
(
podspec
,
sandbox
,
platform
)
...
...
@@ -28,6 +28,10 @@ module Pod
specification
.
name
end
def
platform
specification
.
active_platform
end
def
create
root
.
mkpath
unless
exists?
end
...
...
@@ -83,7 +87,7 @@ module Pod
def
add_to_target
(
target
)
implementation_files
.
each
do
|
file
|
target
.
add_source_file
(
file
,
nil
,
specification
.
compiler_flags
[
@platform
.
name
]
.
strip
)
target
.
add_source_file
(
file
,
nil
,
specification
.
compiler_flags
.
strip
)
end
end
...
...
@@ -92,7 +96,7 @@ module Pod
end
def
dependencies
specification
.
dependencies
[
@platform
.
name
]
specification
.
dependencies
end
private
...
...
@@ -116,8 +120,7 @@ module Pod
end
end
def
expanded_paths
(
platforms_with_patterns
,
options
=
{})
patterns
=
platforms_with_patterns
.
is_a?
(
Hash
)
?
platforms_with_patterns
[
@platform
.
name
]
:
platforms_with_patterns
def
expanded_paths
(
patterns
,
options
=
{})
patterns
.
map
do
|
pattern
|
pattern
=
root
+
pattern
...
...
lib/cocoapods/platform.rb
View file @
0c5c43c1
...
...
@@ -34,7 +34,7 @@ module Pod
end
end
def
support?
(
other
)
def
support
s
?
(
other
)
return
true
if
@symbolic_name
.
nil?
||
other
.
nil?
@symbolic_name
==
other
.
name
&&
(
deployment_target
.
nil?
||
other
.
deployment_target
.
nil?
||
deployment_target
>=
other
.
deployment_target
)
end
...
...
lib/cocoapods/resolver.rb
View file @
0c5c43c1
...
...
@@ -60,8 +60,9 @@ module Pod
spec
=
set
.
specification_by_name
(
dependency
.
name
)
@loaded_specs
<<
spec
.
name
@specs
[
spec
.
name
]
=
spec
spec
.
activate_platform
(
target_definition
.
platform
)
# And recursively load the dependencies of the spec.
find_dependency_sets
(
spec
,
(
spec
.
dependencies
[
target_definition
.
platform
.
to_sym
]),
target_definition
)
if
spec
.
dependencies
[
target_definition
.
platform
.
to_sym
]
find_dependency_sets
(
spec
,
spec
.
dependencies
,
target_definition
)
if
spec
.
dependencies
end
validate_platform!
(
spec
||
@specs
[
dependency
.
name
],
target_definition
)
end
...
...
@@ -69,7 +70,7 @@ module Pod
end
def
validate_platform!
(
spec
,
target
)
unless
spec
.
available_platforms
.
any?
{
|
platform
|
target
.
platform
.
support?
(
platform
)
}
unless
spec
.
available_platforms
.
any?
{
|
platform
|
target
.
platform
.
support
s
?
(
platform
)
}
raise
Informative
,
"[!] The platform of the target `
#{
target
.
name
}
' (
#{
target
.
platform
}
) is not compatible with `
#{
spec
}
' which has a minimun requirement of
#{
spec
.
available_platforms
.
join
(
' - '
)
}
."
.
red
end
end
...
...
lib/cocoapods/specification.rb
View file @
0c5c43c1
...
...
@@ -24,7 +24,7 @@ module Pod
spec
.
subspec_by_name
(
subspec_name
)
end
attr_accessor
:
defined_in_file
,
:
parent
attr_accessor
:parent
def
initialize
(
parent
=
nil
,
name
=
nil
)
@parent
,
@name
=
parent
,
name
if
parent
...
...
@@ -37,8 +37,6 @@ module Pod
@define_for_platforms
=
[
:osx
,
:ios
]
@clean_paths
,
@subspecs
=
[],
[]
@deployment_target
=
{}
@platform
=
Platform
.
new
(
nil
)
initialized_multiplatform_attributes
# deprecated attributes
...
...
@@ -48,11 +46,11 @@ module Pod
# Deprecated attributes
# TODO: remove once master repo and fixtures are updated
def
part_of_dependency
=
(
value
)
puts
"[!] `part_of_dependency' is deprecated in
#{
name
}
"
puts
"[!] `part_of_dependency' is deprecated in
#{
name
}
"
.
cyan
end
def
part_of
=
(
value
)
puts
"[!] `part_of' is deprecated in
#{
name
}
"
puts
"[!] `part_of' is deprecated in
#{
name
}
"
.
cyan
end
# Normal attributes
...
...
@@ -107,13 +105,24 @@ module Pod
top_attr_writer
attr
,
writer_labmda
end
# TODO: First defined
def
platform
@platform
||
(
@parent
?
@parent
.
platform
:
Platform
.
new
(
nil
)
)
end
def
platform
=
(
platform
)
@platform
=
Platform
.
new
(
*
platform
)
end
top_attr_accessor
:defined_in_file
top_attr_accessor
:homepage
top_attr_accessor
:source
top_attr_accessor
:documentation
top_attr_accessor
:requires_arc
top_attr_accessor
:license
,
lambda
{
|
l
|
(
l
.
kind_of?
String
)
?
{
:
type
=>
l
}
:
l
}
top_attr_accessor
:version
,
lambda
{
|
v
|
Version
.
new
(
v
)
}
top_attr_accessor
:platform
,
lambda
{
|
p
|
Platform
.
new
(
*
p
)
}
top_attr_accessor
:readme_file
,
lambda
{
|
file
|
Pathname
.
new
(
file
)
}
top_attr_accessor
:authors
,
lambda
{
|
a
|
parse_authors
(
a
)
}
alias_method
:author
=
,
:authors
=
...
...
@@ -167,14 +176,19 @@ module Pod
# It returns the value of the attribute for the current platform. In this way clients do not need to be aware of wich
# attributes are multiplatform
def
self
.
platform_attr_reader
(
attr
)
# TODO: implement
attr_reader
attr
define_method
(
attr
)
do
raise
Informative
,
"
#{
self
.
inspect
}
#
#{
attr
}
not activated for a platform before consumption."
unless
active_platform
instance_variable_get
(
"@
#{
attr
}
"
)[
active_platform
]
end
end
# It returns the value of a pod merged with upstream. The optional lambda can specify how to merge the values
def
self
.
pltf_chained_attr_reader
(
attr
,
merge_lambda
=
nil
)
# TODO: chain the value with the upstream
attr_reader
attr
define_method
(
attr
)
do
raise
Informative
,
"
#{
self
.
inspect
}
#
#{
attr
}
not activated for a platform before consumption."
unless
active_platform
instance_variable_get
(
"@
#{
attr
}
"
)[
active_platform
]
end
end
def
self
.
platform_attr_writer
(
attr
,
block
=
nil
)
...
...
@@ -216,35 +230,27 @@ module Pod
alias_method
:library
=
,
:libraries
=
def
xcconfig
result
=
{}
@define_for_platforms
.
each
do
|
platform
|
if
@parent
chained
=
@xcconfig
[
platform
].
dup
.
unshift
@parent
.
xcconfig
[
platform
]
else
chained
=
@xcconfig
[
platform
].
dup
end
chained
.
merge!
({
'OTHER_LDFLAGS'
=>
'-l'
<<
libraries
[
platform
].
join
(
' -l'
).
strip
})
unless
libraries
[
platform
].
empty?
chained
.
merge!
({
'OTHER_LDFLAGS'
=>
'-framework '
<<
frameworks
[
platform
].
join
(
' -framework '
).
strip
})
unless
frameworks
[
platform
].
empty?
result
[
platform
]
=
chained
if
@parent
chained
=
@parent
.
xcconfig
.
dup
.
merge!
@xcconfig
[
active_platform
]
else
chained
=
@xcconfig
[
active_platform
].
dup
end
result
chained
.
merge!
({
'OTHER_LDFLAGS'
=>
'-l'
<<
libraries
.
join
(
' -l'
).
strip
})
unless
libraries
.
empty?
chained
.
merge!
({
'OTHER_LDFLAGS'
=>
'-framework '
<<
frameworks
.
join
(
' -framework '
).
strip
})
unless
frameworks
.
empty?
chained
end
platform_attr_writer
:xcconfig
,
lambda
{
|
value
,
current
|
current
.
tap
{
|
c
|
c
.
merge!
(
value
)
}
}
def
compiler_flags
result
=
{}
@define_for_platforms
.
each
do
|
platform
|
if
@parent
chained
=
@compiler_flags
[
platform
].
dup
.
unshift
@parent
.
compiler_flags
[
platform
]
else
chained
=
@compiler_flags
[
platform
].
dup
chained
.
unshift
'-fobjc-arc'
if
@requires_arc
chained
.
unshift
''
end
result
[
platform
]
=
chained
.
join
(
' '
)
if
@parent
chained
=
@compiler_flags
[
active_platform
].
dup
.
unshift
@parent
.
compiler_flags
[
active_platform
]
else
chained
=
@compiler_flags
[
active_platform
].
dup
chained
.
unshift
'-fobjc-arc'
if
@requires_arc
chained
.
unshift
''
end
result
chained
.
join
(
' '
)
end
platform_attr_writer
:compiler_flags
,
lambda
{
|
value
,
current
|
current
<<
value
}
...
...
@@ -259,12 +265,8 @@ module Pod
end
def
dependencies
result
=
{}
@define_for_platforms
.
each
do
|
platform
|
inherited_subspecs
=
subspecs
.
map
{
|
s
|
Dependency
.
new
(
s
.
name
,
version
)
}
result
[
platform
]
=
@dependencies
[
platform
]
+
inherited_subspecs
end
result
raise
Informative
,
"
#{
self
.
inspect
}
#dependencies not activated for a platform before consumption."
unless
active_platform
@dependencies
[
active_platform
]
+
subspecs
.
map
{
|
s
|
Dependency
.
new
(
s
.
name
,
version
)
}
end
# TODO: make top level?
...
...
@@ -329,12 +331,17 @@ module Pod
available_platforms
.
any?
{
|
p
|
platform
.
supports?
p
}
end
# Defines the active platform for comsumption of the specification.
def
activate_for_platform
(
platform
)
raise
"[!]
#{
name
}
does not support platform"
.
red
unless
supports_platform?
(
plaform
)
@active_platform
=
platform
# Defines the active platform for comsumption of the specification and returns self
def
activate_platform
(
platform
)
platform
=
Platform
.
new
(
platform
)
if
platform
.
is_a?
Hash
raise
"[!]
#{
name
}
does not support platform"
.
red
unless
supports_platform?
(
platform
)
top_level_parent
.
active_platform
=
platform
.
to_sym
self
end
# The active platform needs to be the same accross the chain
top_attr_accessor
:active_platform
def
local?
!
source
.
nil?
&&
!
source
[
:local
].
nil?
end
...
...
spec/functional/command/spec_spec.rb
View file @
0c5c43c1
...
...
@@ -23,16 +23,17 @@ describe "Pod::Command::Spec#create" do
it
"creates a new podspec stub file"
do
run_command
(
'spec'
,
'create'
,
'Bananas'
)
path
=
temporary_directory
+
'Bananas.podspec'
spec
=
Pod
::
Specification
.
from_file
(
path
)
spec
.
name
.
should
==
'Bananas'
spec
.
license
.
should
==
{
:type
=>
"MIT"
,
:file
=>
"LICENSE"
}
spec
.
version
.
should
==
Pod
::
Version
.
new
(
'0.0.1'
)
spec
.
summary
.
should
==
'A short description of Bananas.'
spec
.
homepage
.
should
==
'http://EXAMPLE/Bananas'
spec
.
authors
.
should
==
{
`git config --get user.name`
.
strip
=>
`git config --get user.email`
.
strip
}
spec
.
source
.
should
==
{
:git
=>
'http://EXAMPLE/Bananas.git'
,
:tag
=>
'0.0.1'
}
spec
.
description
.
should
==
'An optional longer description of Bananas.'
spec
.
source_files
[
:ios
].
should
==
[
'Classes'
,
'Classes/**/*.{h,m}'
]
spec
=
Pod
::
Specification
.
from_file
(
path
).
activate_platform
(
:ios
)
spec
.
name
.
should
==
'Bananas'
spec
.
license
.
should
==
{
:type
=>
"MIT"
,
:file
=>
"LICENSE"
}
spec
.
version
.
should
==
Pod
::
Version
.
new
(
'0.0.1'
)
spec
.
summary
.
should
==
'A short description of Bananas.'
spec
.
homepage
.
should
==
'http://EXAMPLE/Bananas'
spec
.
authors
.
should
==
{
`git config --get user.name`
.
strip
=>
`git config --get user.email`
.
strip
}
spec
.
source
.
should
==
{
:git
=>
'http://EXAMPLE/Bananas.git'
,
:tag
=>
'0.0.1'
}
spec
.
description
.
should
==
'An optional longer description of Bananas.'
spec
.
source_files
.
should
==
[
'Classes'
,
'Classes/**/*.{h,m}'
]
end
it
"correctly creates a podspec from github"
do
...
...
@@ -128,13 +129,13 @@ describe "Pod::Command::Spec#lint" do
spec_file
=
fixture
(
'spec-repos'
)
+
'master/JSONKit/1.4/JSONKit.podspec'
cmd
=
command
(
'spec'
,
'lint'
,
'--quick'
,
spec_file
.
to_s
)
lambda
{
cmd
.
run
}.
should
.
raise
Pod
::
Informative
cmd
.
output
.
should
.
include
"Missing license
[:file] or [:text]
"
cmd
.
output
.
should
.
include
"Missing license
file or text
"
end
it
"respects the -only--errors option"
do
spec_file
=
fixture
(
'spec-repos'
)
+
'master/JSONKit/1.4/JSONKit.podspec'
cmd
=
command
(
'spec'
,
'lint'
,
'--quick'
,
'--only-errors'
,
spec_file
.
to_s
)
lambda
{
cmd
.
run
}.
should
.
not
.
raise
cmd
.
output
.
should
.
include
"Missing license
[:file] or [:text]
"
cmd
.
output
.
should
.
include
"Missing license
file or text
"
end
end
spec/unit/command/spec_spec.rb
View file @
0c5c43c1
...
...
@@ -19,7 +19,7 @@ describe "Pod::Command::Spec::Linter" do
it
"fails a specifications that does not contain the minimum required attributes"
do
spec
,
file
=
write_podspec
(
'Pod::Spec.new do |s| end'
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
,
file
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lint
.
should
==
false
linter
.
errors
.
join
(
' | '
)
=~
/name.*version.*summary.*homepage.*authors.*(source.*part_of).*source_files/
...
...
@@ -27,7 +27,7 @@ describe "Pod::Command::Spec::Linter" do
it
"fails specifications if the name does not match the name of the file"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/s.name *= 'JSONKit'/
,
"s.name = 'JSONKitAAA'"
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
,
file
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lint
.
should
==
false
linter
.
errors
.
count
.
should
==
1
...
...
@@ -36,16 +36,16 @@ describe "Pod::Command::Spec::Linter" do
it
"fails a specification if a path starts with a slash"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/s.source_files = 'JSONKit\.\*'/
,
"s.source_files = '/JSONKit.*'"
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
,
file
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lint
.
should
==
false
linter
.
errors
.
count
.
should
==
1
linter
.
errors
[
0
].
should
=~
/Paths cannot start with a slash/
end
it
"fails a specification if the pla
fro
m is unrecognized"
do
it
"fails a specification if the pla
tfor
m is unrecognized"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/s.name *= 'JSONKit'/
,
"s.name = 'JSONKit'
\n
s.platform = :iososx
\n
"
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
,
file
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lint
.
should
==
false
linter
.
errors
.
count
.
should
==
1
...
...
@@ -54,7 +54,7 @@ describe "Pod::Command::Spec::Linter" do
it
"fails validation if the specification contains warnings"
do
spec
,
file
=
write_podspec
(
stub_podspec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
,
file
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
lenient
,
linter
.
quick
=
false
,
true
linter
.
lint
.
should
==
false
linter
.
errors
.
should
.
be
.
empty
...
...
@@ -63,7 +63,7 @@ describe "Pod::Command::Spec::Linter" do
it
"validates in lenient mode if there are no erros but there are warnings"
do
spec
,
file
=
write_podspec
(
stub_podspec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
,
file
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
lenient
,
linter
.
quick
=
true
,
true
linter
.
lint
.
should
==
true
linter
.
errors
.
should
.
be
.
empty
...
...
@@ -72,7 +72,7 @@ describe "Pod::Command::Spec::Linter" do
it
"respects quick mode"
do
spec
,
file
=
write_podspec
(
stub_podspec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
,
file
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
expects
(
:peform_multiplatform_analysis
).
never
linter
.
expects
(
:install_pod
).
never
linter
.
expects
(
:xcodebuild_output_for_platfrom
).
never
...
...
@@ -83,7 +83,7 @@ describe "Pod::Command::Spec::Linter" do
it
"produces deprecation notices"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/s\.source_files = 'JSONKit\.\*'/
,
"s.source_files = 'JSONKit.*'
\n
if config.ios?
\n
end"
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
,
file
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
lenient
,
linter
.
quick
=
false
,
true
linter
.
lint
.
should
==
false
linter
.
errors
.
should
.
be
.
empty
...
...
@@ -92,7 +92,7 @@ describe "Pod::Command::Spec::Linter" do
it
"uses xcodebuild to generate notes and warnings"
do
spec
,
file
=
write_podspec
(
stub_podspec
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
,
file
)
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
lenient
,
linter
.
quick
=
false
,
false
linter
.
lint
.
should
==
false
linter
.
notes
.
join
(
' | '
).
should
.
include
"JSONKit/JSONKit.m:1640:27: warning: equality comparison with extraneous parentheses"
unless
`which xcodebuild`
.
strip
.
empty?
...
...
@@ -100,8 +100,8 @@ describe "Pod::Command::Spec::Linter" do
it
"checks for file patterns"
do
spec
,
file
=
write_podspec
(
stub_podspec
(
/s\.source_files = 'JSONKit\.\*'/
,
"s.source_files = 'JSONKit.*'
\n
s.resources = 'WRONG_FOLDER'"
))
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
,
file
)
linter
.
stubs
(
:xcodebuild_output
_for_platfrom
).
returns
([])
linter
=
Pod
::
Command
::
Spec
::
Linter
.
new
(
spec
)
linter
.
stubs
(
:xcodebuild_output
).
returns
([])
linter
.
lenient
,
linter
.
quick
=
false
,
false
linter
.
lint
.
should
==
false
linter
.
errors
.
join
(
' | '
).
should
.
include
"[resources = 'WRONG_FOLDER'] -> did not match any file"
...
...
spec/unit/platform_spec.rb
View file @
0c5c43c1
...
...
@@ -68,34 +68,34 @@ describe "Pod::Platform with a nil value" do
end
end
describe
"Pod::Platform#support?"
do
describe
"Pod::Platform#support
s
?"
do
it
"supports another platform is with the same operating system"
do
p1
=
Pod
::
Platform
.
new
(
:ios
)
p2
=
Pod
::
Platform
.
new
(
:ios
)
p1
.
should
.
support?
(
p2
)
p1
.
should
.
support
s
?
(
p2
)
p1
=
Pod
::
Platform
.
new
(
:osx
)
p2
=
Pod
::
Platform
.
new
(
:osx
)
p1
.
should
.
support?
(
p2
)
p1
.
should
.
support
s
?
(
p2
)
end
it
"supports a nil platform"
do
p1
=
Pod
::
Platform
.
new
(
:ios
)
p1
.
should
.
support?
(
nil
)
p1
.
should
.
support
s
?
(
nil
)
end
it
"supports a platform with a lower or equal deployment_target"
do
p1
=
Pod
::
Platform
.
new
(
:ios
,
'5.0'
)
p2
=
Pod
::
Platform
.
new
(
:ios
,
'4.0'
)
p1
.
should
.
support?
(
p1
)
p1
.
should
.
support?
(
p2
)
p2
.
should
.
not
.
support?
(
p1
)
p1
.
should
.
support
s
?
(
p1
)
p1
.
should
.
support
s
?
(
p2
)
p2
.
should
.
not
.
support
s
?
(
p1
)
end
it
"supports a platform regardless of the deployment_target if one of the two does not specify it"
do
p1
=
Pod
::
Platform
.
new
(
:ios
)
p2
=
Pod
::
Platform
.
new
(
:ios
,
'4.0'
)
p1
.
should
.
support?
(
p2
)
p2
.
should
.
support?
(
p1
)
p1
.
should
.
support
s
?
(
p2
)
p2
.
should
.
support
s
?
(
p1
)
end
end
spec/unit/specification_spec.rb
View file @
0c5c43c1
...
...
@@ -57,24 +57,23 @@ describe "A Pod::Specification loaded from a podspec" do
end
it
"returns the pod's source files"
do
@spec
.
source_files
[
:ios
]
.
should
==
[
'Classes/*.{h,m}'
,
'Vendor'
]
@spec
.
source_files
[
:osx
]
.
should
==
[
'Classes/*.{h,m}'
,
'Vendor'
]
@spec
.
activate_platform
(
:ios
).
source_files
.
should
==
[
'Classes/*.{h,m}'
,
'Vendor'
]
@spec
.
activate_platform
(
:osx
).
source_files
.
should
==
[
'Classes/*.{h,m}'
,
'Vendor'
]
end
it
"returns the pod's dependencies"
do
expected
=
Pod
::
Dependency
.
new
(
'monkey'
,
'~> 1.0.1'
,
'< 1.0.9'
)
@spec
.
dependencies
.
should
==
{
:ios
=>
[
expected
],
:osx
=>
[
expected
]
}
@spec
.
activate_platform
(
:ios
).
dependencies
.
should
==
[
expected
]
@spec
.
activate_platform
(
:osx
).
dependencies
.
should
==
[
expected
]
end
it
"returns the pod's xcconfig settings"
do
@spec
.
xcconfig
[
:ios
].
should
==
{
'OTHER_LDFLAGS'
=>
'-framework SystemConfiguration'
}
@spec
.
activate_platform
(
:ios
).
xcconfig
.
should
==
{
'OTHER_LDFLAGS'
=>
'-framework SystemConfiguration'
}
end
it
"has a shortcut to add frameworks to the xcconfig"
do
@spec
.
frameworks
=
'CFNetwork'
,
'CoreText'
@spec
.
xcconfig
[
:ios
]
.
should
==
{
@spec
.
activate_platform
(
:ios
).
xcconfig
.
should
==
{
'OTHER_LDFLAGS'
=>
'-framework SystemConfiguration '
\
'-framework CFNetwork '
\
'-framework CoreText'
...
...
@@ -83,7 +82,7 @@ describe "A Pod::Specification loaded from a podspec" do
it
"has a shortcut to add libraries to the xcconfig"
do
@spec
.
libraries
=
'z'
,
'xml2'
@spec
.
xcconfig
[
:ios
]
.
should
==
{
@spec
.
activate_platform
(
:ios
).
xcconfig
.
should
==
{
'OTHER_LDFLAGS'
=>
'-framework SystemConfiguration -lz -lxml2'
}
end
...
...
@@ -102,9 +101,11 @@ describe "A Pod::Specification loaded from a podspec" do
it
"adds compiler flags if ARC is required"
do
@spec
.
parent
.
should
==
nil
@spec
.
requires_arc
=
true
@spec
.
compiler_flags
.
should
==
{
:ios
=>
" -fobjc-arc"
,
:osx
=>
" -fobjc-arc"
}
@spec
.
activate_platform
(
:ios
).
compiler_flags
.
should
==
" -fobjc-arc"
@spec
.
activate_platform
(
:osx
).
compiler_flags
.
should
==
" -fobjc-arc"
@spec
.
compiler_flags
=
"-Wunused-value"
@spec
.
compiler_flags
.
should
==
{
:ios
=>
" -fobjc-arc -Wunused-value"
,
:osx
=>
" -fobjc-arc -Wunused-value"
}
@spec
.
activate_platform
(
:ios
).
compiler_flags
.
should
==
" -fobjc-arc -Wunused-value"
@spec
.
activate_platform
(
:osx
).
compiler_flags
.
should
==
" -fobjc-arc -Wunused-value"
end
end
...
...
@@ -231,7 +232,8 @@ describe "A Pod::Specification subspec" do
end
it
"automatically forwards undefined attributes to the top level parent"
do
[
:version
,
:summary
,
:platform
,
:license
,
:authors
,
:requires_arc
,
:compiler_flags
].
each
do
|
attr
|
@spec
.
activate_platform
(
:ios
)
[
:version
,
:summary
,
:platform
,
:license
,
:authors
,
:requires_arc
].
each
do
|
attr
|
@spec
.
subspecs
.
first
.
send
(
attr
).
should
==
@spec
.
send
(
attr
)
@spec
.
subspecs
.
first
.
subspecs
.
first
.
send
(
attr
).
should
==
@spec
.
send
(
attr
)
end
...
...
@@ -243,6 +245,16 @@ describe "A Pod::Specification subspec" do
@spec
.
subspec_by_name
(
'MainSpec/FirstSubSpec'
).
should
==
@spec
.
subspecs
.
first
@spec
.
subspec_by_name
(
'MainSpec/FirstSubSpec/SecondSubSpec'
).
should
==
@spec
.
subspecs
.
first
.
subspecs
.
first
end
xit
"can be activated for a platorm"
xit
"raises if not activated"
xit
"returns self on activation for method chainablity"
xit
"does not cache platform attributes and can activate another platform"
xit
"resolves chained attributes"
xit
"resolves not chained attributes"
xit
"has the same active platform accross the chain attributes"
xit
"raises a top level attribute is assigned to a spec with a parent"
end
describe
"A Pod::Specification with :local source"
do
...
...
@@ -281,26 +293,31 @@ describe "A Pod::Specification, concerning its attributes that support different
end
it
"returns the same list of source files for each platform"
do
@spec
.
source_files
.
should
==
{
:ios
=>
%w{ file1 file2 }
,
:osx
=>
%w{ file1 file2 }
}
@spec
.
activate_platform
(
:ios
).
source_files
.
should
==
%w{ file1 file2 }
@spec
.
activate_platform
(
:osx
).
source_files
.
should
==
%w{ file1 file2 }
end
it
"returns the same list of resources for each platform"
do
@spec
.
resources
.
should
==
{
:ios
=>
%w{ file1 file2 }
,
:osx
=>
%w{ file1 file2 }
}
@spec
.
activate_platform
(
:ios
).
resources
.
should
==
%w{ file1 file2 }
@spec
.
activate_platform
(
:osx
).
resources
.
should
==
%w{ file1 file2 }
end
it
"returns the same list of xcconfig build settings for each platform"
do
build_settings
=
{
'OTHER_LDFLAGS'
=>
'-lObjC -lz -framework QuartzCore'
}
@spec
.
xcconfig
.
should
==
{
:ios
=>
build_settings
,
:osx
=>
build_settings
}
@spec
.
activate_platform
(
:ios
).
xcconfig
.
should
==
build_settings
@spec
.
activate_platform
(
:osx
).
xcconfig
.
should
==
build_settings
end
it
"returns the same list of compiler flags for each platform"
do
compiler_flags
=
' -fobjc-arc -Wdeprecated-implementations'
@spec
.
compiler_flags
.
should
==
{
:ios
=>
compiler_flags
,
:osx
=>
compiler_flags
}
@spec
.
activate_platform
(
:ios
).
compiler_flags
.
should
==
compiler_flags
@spec
.
activate_platform
(
:osx
).
compiler_flags
.
should
==
compiler_flags
end
it
"returns the same list of dependencies for each platform"
do
dependencies
=
%w{ JSONKit SSZipArchive }
.
map
{
|
name
|
Pod
::
Dependency
.
new
(
name
)
}
@spec
.
dependencies
.
should
==
{
:ios
=>
dependencies
,
:osx
=>
dependencies
}
@spec
.
activate_platform
(
:ios
).
dependencies
.
should
==
dependencies
@spec
.
activate_platform
(
:osx
).
dependencies
.
should
==
dependencies
end
end
...
...
@@ -335,18 +352,18 @@ describe "A Pod::Specification, concerning its attributes that support different
end
it
"returns a different list of source files for each platform"
do
@spec
.
source_files
.
should
==
{
:ios
=>
%w{ file1 }
,
:osx
=>
%w{ file1 file2 }
}
@spec
.
activate_platform
(
:ios
).
source_files
.
should
==
%w{ file1 }
@spec
.
activate_platform
(
:osx
).
source_files
.
should
==
%w{ file1 file2 }
end
it
"returns a different list of resources for each platform"
do
@spec
.
resources
.
should
==
{
:ios
=>
%w{ file1 }
,
:osx
=>
%w{ file1 file2 }
}
@spec
.
activate_platform
(
:ios
).
resources
.
should
==
%w{ file1 }
@spec
.
activate_platform
(
:osx
).
resources
.
should
==
%w{ file1 file2 }
end
it
"returns a different list of xcconfig build settings for each platform"
do
@spec
.
xcconfig
.
should
==
{
:ios
=>
{
'OTHER_LDFLAGS'
=>
'-lObjC -lz -framework QuartzCore'
},
:osx
=>
{
'OTHER_LDFLAGS'
=>
'-lObjC -all_load -lz -lxml -framework QuartzCore -framework CoreData'
}
}
@spec
.
activate_platform
(
:ios
).
xcconfig
.
should
==
{
'OTHER_LDFLAGS'
=>
'-lObjC -lz -framework QuartzCore'
}
@spec
.
activate_platform
(
:osx
).
xcconfig
.
should
==
{
'OTHER_LDFLAGS'
=>
'-lObjC -all_load -lz -lxml -framework QuartzCore -framework CoreData'
}
end
it
"returns the list of the supported platfroms and deployment targets"
do
...
...
@@ -356,17 +373,13 @@ describe "A Pod::Specification, concerning its attributes that support different
end
it
"returns the same list of compiler flags for each platform"
do
@spec
.
compiler_flags
.
should
==
{
:ios
=>
' -fobjc-arc -Wdeprecated-implementations'
,
:osx
=>
' -fobjc-arc -Wfloat-equal'
}
@spec
.
activate_platform
(
:ios
).
compiler_flags
.
should
==
' -fobjc-arc -Wdeprecated-implementations'
@spec
.
activate_platform
(
:osx
).
compiler_flags
.
should
==
' -fobjc-arc -Wfloat-equal'
end
it
"returns the same list of dependencies for each platform"
do
@spec
.
dependencies
.
should
==
{
:ios
=>
[
Pod
::
Dependency
.
new
(
'JSONKit'
)],
:osx
=>
[
Pod
::
Dependency
.
new
(
'SSZipArchive'
)]
}
@spec
.
activate_platform
(
:ios
).
dependencies
.
should
==
[
Pod
::
Dependency
.
new
(
'JSONKit'
)]
@spec
.
activate_platform
(
:osx
).
dependencies
.
should
==
[
Pod
::
Dependency
.
new
(
'SSZipArchive'
)]
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