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
441eac88
Commit
441eac88
authored
Oct 29, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return a groups children as an object list.
parent
4b20d585
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
34 deletions
+35
-34
project.rb
lib/cocoapods/xcode/project.rb
+33
-32
project_spec.rb
spec/unit/xcode/project_spec.rb
+2
-2
No files found.
lib/cocoapods/xcode/project.rb
View file @
441eac88
...
@@ -16,9 +16,9 @@ module Pod
...
@@ -16,9 +16,9 @@ module Pod
names
.
each
{
|
name
|
attribute
(
name
)
}
names
.
each
{
|
name
|
attribute
(
name
)
}
end
end
def
self
.
has_many
(
plural_attr_name
,
options
)
def
self
.
has_many
(
plural_attr_name
,
options
=
{}
)
klass
=
options
[
:class
]
klass
=
options
[
:class
]
||
PBXFileReference
singular_attr_name
=
plural_attr_name
.
to_s
[
0
..-
2
]
# strip off 's'
singular_attr_name
=
options
[
:singular
]
||
plural_attr_name
.
to_s
[
0
..-
2
]
# strip off 's'
uuid_list_name
=
"
#{
singular_attr_name
}
References"
uuid_list_name
=
"
#{
singular_attr_name
}
References"
attribute
(
plural_attr_name
,
uuid_list_name
)
attribute
(
plural_attr_name
,
uuid_list_name
)
define_method
(
plural_attr_name
)
do
define_method
(
plural_attr_name
)
do
...
@@ -80,25 +80,48 @@ module Pod
...
@@ -80,25 +80,48 @@ module Pod
end
end
end
end
class
PBX
Group
<
PBXObject
class
PBX
FileReference
<
PBXObject
attributes
:
sourceTree
,
:children
attributes
:
path
,
:sourceTree
def
initialize
(
project
,
uuid
,
attributes
)
def
initialize
(
project
,
uuid
,
attributes
)
is_new
=
uuid
.
nil?
super
self
.
name
||=
pathname
.
basename
.
to_s
self
.
sourceTree
||=
'SOURCE_ROOT'
if
is_new
@project
.
build_files
.
new
.
file
=
self
end
end
def
pathname
Pathname
.
new
(
path
)
end
def
build_file
@project
.
build_files
.
find
{
|
o
|
o
.
fileRef
==
uuid
}
end
end
class
PBXGroup
<
PBXObject
attributes
:sourceTree
has_many
:children
,
:singular
=>
:child
def
initialize
(
*
)
super
super
self
.
sourceTree
||=
'<group>'
self
.
sourceTree
||=
'<group>'
self
.
child
ren
||=
[]
self
.
child
References
||=
[]
end
end
def
files
def
files
list_by_class
(
child
ren
,
PBXFileReference
)
list_by_class
(
child
References
,
PBXFileReference
)
end
end
def
source_files
def
source_files
list_by_class
(
child
ren
,
PBXFileReference
,
files
.
select
{
|
file
|
!
file
.
build_file
.
nil?
})
list_by_class
(
child
References
,
PBXFileReference
,
files
.
select
{
|
file
|
!
file
.
build_file
.
nil?
})
end
end
def
groups
def
groups
list_by_class
(
child
ren
,
PBXGroup
)
list_by_class
(
child
References
,
PBXGroup
)
end
end
def
add_source_file
(
path
,
copy_header_phase
=
nil
,
compiler_flags
=
nil
)
def
add_source_file
(
path
,
copy_header_phase
=
nil
,
compiler_flags
=
nil
)
...
@@ -119,29 +142,7 @@ module Pod
...
@@ -119,29 +142,7 @@ module Pod
end
end
def
<<
(
child
)
def
<<
(
child
)
children
<<
child
.
uuid
childReferences
<<
child
.
uuid
end
end
class
PBXFileReference
<
PBXObject
attributes
:path
,
:sourceTree
def
initialize
(
project
,
uuid
,
attributes
)
is_new
=
uuid
.
nil?
super
self
.
name
||=
pathname
.
basename
.
to_s
self
.
sourceTree
||=
'SOURCE_ROOT'
if
is_new
@project
.
build_files
.
new
.
file
=
self
end
end
def
pathname
Pathname
.
new
(
path
)
end
def
build_file
@project
.
build_files
.
find
{
|
o
|
o
.
fileRef
==
uuid
}
end
end
end
end
...
...
spec/unit/xcode/project_spec.rb
View file @
441eac88
...
@@ -220,7 +220,7 @@ describe "Pod::Xcode::Project" do
...
@@ -220,7 +220,7 @@ describe "Pod::Xcode::Project" do
it
"adds a group to the `Pods' group"
do
it
"adds a group to the `Pods' group"
do
group
=
@project
.
add_pod_group
(
'JSONKit'
)
group
=
@project
.
add_pod_group
(
'JSONKit'
)
@project
.
pods
.
child
ren
.
should
.
include
group
.
uuid
@project
.
pods
.
child
References
.
should
.
include
group
.
uuid
find_object
({
find_object
({
'isa'
=>
'PBXGroup'
,
'isa'
=>
'PBXGroup'
,
'name'
=>
'JSONKit'
,
'name'
=>
'JSONKit'
,
...
@@ -251,7 +251,7 @@ describe "Pod::Xcode::Project" do
...
@@ -251,7 +251,7 @@ describe "Pod::Xcode::Project" do
})
})
build_file_uuids
<<
build_file_uuid
build_file_uuids
<<
build_file_uuid
group
.
child
ren
.
should
==
file_ref_uuids
group
.
child
References
.
should
==
file_ref_uuids
_
,
object
=
find_object
(
'isa'
=>
'PBXSourcesBuildPhase'
)
_
,
object
=
find_object
(
'isa'
=>
'PBXSourcesBuildPhase'
)
object
[
'files'
].
should
==
build_file_uuids
object
[
'files'
].
should
==
build_file_uuids
...
...
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