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
918619a6
Commit
918619a6
authored
Mar 28, 2012
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for Specification attributes that can take values for different platforms.
parent
08aa7961
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
130 additions
and
30 deletions
+130
-30
specification.rb
lib/cocoapods/specification.rb
+31
-30
specification_spec.rb
spec/unit/specification_spec.rb
+99
-0
No files found.
lib/cocoapods/specification.rb
View file @
918619a6
...
...
@@ -36,7 +36,7 @@ module Pod
@xcconfig
=
Xcodeproj
::
Config
.
new
end
# Attributes
# Attributes
**without** multiple platform support
attr_accessor
:name
attr_accessor
:homepage
...
...
@@ -90,6 +90,35 @@ module Pod
@part_of
=
dependency
(
*
name_and_version_requirements
)
end
def
clean_paths
=
(
patterns
)
@clean_paths
=
pattern_list
(
patterns
)
end
attr_reader
:clean_paths
alias_method
:clean_path
=
,
:clean_paths
=
def
header_dir
=
(
dir
)
@header_dir
=
Pathname
.
new
(
dir
)
end
def
header_dir
@header_dir
||
pod_destroot_name
end
def
platform
=
(
platform
)
@platform
=
Platform
.
new
(
platform
)
end
attr_reader
:platform
attr_accessor
:requires_arc
def
subspec
(
name
,
&
block
)
subspec
=
Subspec
.
new
(
self
,
name
,
&
block
)
@subspecs
<<
subspec
subspec
end
attr_reader
:subspecs
### Attributes **with** multiple platform support
def
source_files
=
(
patterns
)
@source_files
=
pattern_list
(
patterns
)
end
...
...
@@ -101,12 +130,6 @@ module Pod
attr_reader
:resources
alias_method
:resource
=
,
:resources
=
def
clean_paths
=
(
patterns
)
@clean_paths
=
pattern_list
(
patterns
)
end
attr_reader
:clean_paths
alias_method
:clean_path
=
,
:clean_paths
=
def
xcconfig
=
(
hash
)
@xcconfig
.
merge!
(
hash
)
end
...
...
@@ -124,14 +147,6 @@ module Pod
end
alias_method
:library
=
,
:libraries
=
def
header_dir
=
(
dir
)
@header_dir
=
Pathname
.
new
(
dir
)
end
def
header_dir
@header_dir
||
pod_destroot_name
end
attr_writer
:compiler_flags
def
compiler_flags
flags
=
"
#{
@compiler_flags
}
"
...
...
@@ -139,13 +154,6 @@ module Pod
flags
end
def
platform
=
(
platform
)
@platform
=
Platform
.
new
(
platform
)
end
attr_reader
:platform
attr_accessor
:requires_arc
def
dependency
(
*
name_and_version_requirements
)
name
,
*
version_requirements
=
name_and_version_requirements
.
flatten
dep
=
Dependency
.
new
(
name
,
*
version_requirements
)
...
...
@@ -154,14 +162,7 @@ module Pod
end
attr_reader
:dependencies
def
subspec
(
name
,
&
block
)
subspec
=
Subspec
.
new
(
self
,
name
,
&
block
)
@subspecs
<<
subspec
subspec
end
attr_reader
:subspecs
# Not attributes
### Not attributes
include
Config
::
Mixin
...
...
spec/unit/specification_spec.rb
View file @
918619a6
...
...
@@ -410,3 +410,102 @@ describe "A Pod::Specification with :local source" do
end
end
describe
"A Pod::Specification, concerning its attributes that support different values per platform,"
do
describe
"when **no** platform specific values are given"
do
before
do
@spec
=
Pod
::
Spec
.
new
do
|
s
|
s
.
source_files
=
'file1'
,
'file2'
s
.
resources
=
'file1'
,
'file2'
s
.
xcconfig
=
{
'OTHER_LDFLAGS'
=>
'-lObjC'
}
s
.
framework
=
'QuartzCore'
s
.
library
=
'z'
s
.
compiler_flags
=
'-Wdeprecated-implementations'
s
.
requires_arc
=
true
s
.
dependency
'JSONKit'
s
.
dependency
'SSZipArchive'
end
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 }
}
end
it
"returns the same list of resources for each platform"
do
@spec
.
resources
.
should
==
{
:ios
=>
%w{ file1 file2 }
,
:osx
=>
%w{ file1 file2 }
}
end
it
"returns the same list of xcconfig build settings for each platform"
do
build_settings
=
{
'OTHER_LDFLAGS'
=>
'-lObjC -framework QuartzCore -lz'
}
@spec
.
xcconfig
.
should
==
{
:ios
=>
build_settings
,
:osx
=>
build_settings
}
end
it
"returns the same list of compiler flags for each platform"
do
compiler_flags
=
'-Wdeprecated-implementations -fobjc-arc'
@spec
.
compiler_flags
.
should
==
{
:ios
=>
compiler_flags
,
:osx
=>
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
}
end
end
describe
"when platform specific values are given"
do
before
do
@spec
=
Pod
::
Spec
.
new
do
|
s
|
s
.
ios
.
source_file
=
'file1'
s
.
osx
.
source_files
=
'file1'
,
'file2'
s
.
ios
.
resource
=
'file1'
s
.
osx
.
resources
=
'file1'
,
'file2'
s
.
ios
.
xcconfig
=
{
'OTHER_LDFLAGS'
=>
'-lObjC'
}
s
.
osx
.
xcconfig
=
{
'OTHER_LDFLAGS'
=>
'-lObjC -all_load'
}
s
.
ios
.
framework
=
'QuartzCore'
s
.
osx
.
frameworks
=
'QuartzCore'
,
'CoreData'
s
.
ios
.
library
=
'z'
s
.
osx
.
libraries
=
'z'
,
'xml'
s
.
ios
.
compiler_flags
=
'-Wdeprecated-implementations'
s
.
osx
.
compiler_flags
=
'-Wfloat-equal'
s
.
requires_arc
=
true
# does not take platform options, just here to check it's added to compiler_flags
s
.
ios
.
dependency
'JSONKit'
s
.
osx
.
dependency
'SSZipArchive'
end
end
it
"returns a different list of source files for each platform"
do
@spec
.
source_files
.
should
==
{
:ios
=>
%w{ file1 }
,
:osx
=>
%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 }
}
end
it
"returns a different list of xcconfig build settings for each platform"
do
@spec
.
xcconfig
.
should
==
{
:ios
=>
{
'OTHER_LDFLAGS'
=>
'-lObjC -framework QuartzCore -lz'
},
:osx
=>
{
'OTHER_LDFLAGS'
=>
'-lObjC -all_load -framework QuartzCore -framework CoreData -lz -lxml'
}
}
end
it
"returns the same list of compiler flags for each platform"
do
@spec
.
compiler_flags
.
should
==
{
:ios
=>
'-Wdeprecated-implementations -fobjc-arc'
,
:osx
=>
'-Wfloat-equal -fobjc-arc'
}
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'
)
}
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