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
bc3b1ce9
Commit
bc3b1ce9
authored
Nov 22, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define the essential stuff for a Subspec.
parent
36361198
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
8 deletions
+93
-8
specification.rb
lib/cocoapods/specification.rb
+53
-8
specification_spec.rb
spec/unit/specification_spec.rb
+40
-0
No files found.
lib/cocoapods/specification.rb
View file @
bc3b1ce9
...
...
@@ -21,7 +21,7 @@ module Pod
attr_accessor
:defined_in_file
def
initialize
@dependencies
,
@resources
,
@clean_paths
=
[],
[],
[]
@dependencies
,
@resources
,
@clean_paths
,
@subspecs
=
[],
[],
[],
[]
@xcconfig
=
Xcodeproj
::
Config
.
new
yield
self
if
block_given?
end
...
...
@@ -115,15 +115,10 @@ module Pod
flags
end
# These are attributes which are also on a Podfile
attr_accessor
:platform
attr_accessor
:requires_arc
attr_accessor
:generate_bridge_support
alias_method
:generate_bridge_support?
,
:generate_bridge_support
def
dependency
(
*
name_and_version_requirements
)
name
,
*
version_requirements
=
name_and_version_requirements
.
flatten
dep
=
Dependency
.
new
(
name
,
*
version_requirements
)
...
...
@@ -132,14 +127,64 @@ module Pod
end
attr_reader
:dependencies
class
Subspec
<
Specification
attr_reader
:parent
def
initialize
(
parent
,
name
)
@parent
,
@name
=
parent
,
name
# TODO a MacRuby bug, the correct super impl `initialize' is not called consistently
#super(&block)
@dependencies
,
@resources
,
@clean_paths
,
@subspecs
=
[],
[],
[],
[]
@xcconfig
=
Xcodeproj
::
Config
.
new
self
.
part_of
=
top_level_parent
.
name
,
top_level_parent
.
version
yield
self
if
block_given?
end
undef_method
:name
=
,
:version
=
,
:source
=
def
top_level_parent
top_level_parent
=
@parent
top_level_parent
=
top_level_parent
.
parent
while
top_level_parent
.
is_a?
(
Subspec
)
top_level_parent
end
def
name
"
#{
@parent
.
name
}
/
#{
@name
}
"
end
def
summary
@summary
?
@summary
:
top_level_parent
.
summary
end
def
source
top_level_parent
.
source
end
end
def
subspec
(
name
,
&
block
)
subspec
=
Subspec
.
new
(
self
,
name
,
&
block
)
@subspecs
<<
subspec
subspec
end
attr_reader
:subspecs
# These are attributes which are also on a Podfile
# TODO remove this, we no longer allow to install specs as Podfile
attr_accessor
:generate_bridge_support
alias_method
:generate_bridge_support?
,
:generate_bridge_support
# Not attributes
include
Config
::
Mixin
def
==
(
other
)
self
.
class
===
other
&&
object_id
==
other
.
object_id
||
(
self
.
class
===
other
&&
name
&&
name
==
other
.
name
&&
version
&&
version
==
other
.
version
version
&&
version
==
other
.
version
)
end
def
dependency_by_name
(
name
)
...
...
spec/unit/specification_spec.rb
View file @
bc3b1ce9
...
...
@@ -2,6 +2,7 @@ require File.expand_path('../../spec_helper', __FILE__)
describe
"A Pod::Specification loaded from a podspec"
do
before
do
fixture
(
'banana-lib'
)
# ensure the archive is unpacked
@spec
=
Pod
::
Specification
.
from_file
(
fixture
(
'banana-lib/BananaLib.podspec'
))
end
...
...
@@ -279,3 +280,42 @@ describe "A Pod::Specification, in general," do
list
.
glob
.
should
==
FileList
[(
ROOT
+
'*'
).
to_s
].
exclude
(
'Rakefile'
).
map
{
|
path
|
Pathname
.
new
(
path
)
}
end
end
describe
"A Pod::Specification subspec"
do
before
do
@spec
=
Pod
::
Spec
.
new
do
|
s
|
s
.
name
=
'MainSpec'
s
.
version
=
'1.2.3'
s
.
summary
=
'A spec with subspecs'
s
.
source
=
{
:git
=>
'/some/url'
}
s
.
subspec
'FirstSubSpec'
do
|
fss
|
fss
.
subspec
'SecondSubSpec'
do
|
sss
|
end
end
end
end
it
"returns the top level parent spec"
do
@spec
.
subspecs
.
first
.
top_level_parent
.
should
==
@spec
@spec
.
subspecs
.
first
.
subspecs
.
first
.
top_level_parent
.
should
==
@spec
end
it
"is named after the parent spec"
do
@spec
.
subspecs
.
first
.
name
.
should
==
'MainSpec/FirstSubSpec'
@spec
.
subspecs
.
first
.
subspecs
.
first
.
name
.
should
==
'MainSpec/FirstSubSpec/SecondSubSpec'
end
it
"is a `part_of' the top level parent spec"
do
dependency
=
Pod
::
Dependency
.
new
(
'MainSpec'
,
'1.2.3'
).
tap
{
|
d
|
d
.
only_part_of_other_pod
=
true
}
@spec
.
subspecs
.
first
.
part_of
.
should
==
dependency
@spec
.
subspecs
.
first
.
subspecs
.
first
.
part_of
.
should
==
dependency
end
it
"automatically forwards undefined attributes to the top level parent"
do
@spec
.
subspecs
.
first
.
summary
.
should
==
@spec
.
summary
@spec
.
subspecs
.
first
.
source
.
should
==
@spec
.
source
@spec
.
subspecs
.
first
.
subspecs
.
first
.
summary
.
should
==
@spec
.
summary
@spec
.
subspecs
.
first
.
subspecs
.
first
.
source
.
should
==
@spec
.
source
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