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
3ed1918d
Commit
3ed1918d
authored
Sep 06, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Project] Major improvements to support PodsProjectGenerator
parent
b14f3708
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
10 deletions
+97
-10
project.rb
lib/cocoapods/project.rb
+52
-7
project_spec.rb
spec/unit/project_spec.rb
+45
-3
No files found.
lib/cocoapods/project.rb
View file @
3ed1918d
...
@@ -15,24 +15,47 @@ module Pod
...
@@ -15,24 +15,47 @@ module Pod
#
#
def
initialize
(
path
,
skip_initialization
=
false
)
def
initialize
(
path
,
skip_initialization
=
false
)
super
(
path
,
skip_initialization
)
super
(
path
,
skip_initialization
)
@support_files_group
=
new_group
(
'Targets Support Files'
)
@refs_by_absolute_path
=
{}
@refs_by_absolute_path
=
{}
@pods
=
new_group
(
'Pods'
)
@development_pods
=
new_group
(
'Development Pods'
)
end
end
# @return [Hash] The names of the specification subgroups by key.
#
ROOT_GROUPS
=
{
:support_files
=>
'Targets Support Files'
,
:pods
=>
'Pods'
,
:development_pods
=>
'Development Pods'
,
}
# @return [PBXGroup] The group for the support files of the aggregate
# @return [PBXGroup] The group for the support files of the aggregate
# targets.
# targets.
#
#
attr_reader
:support_files_group
def
support_files_group
create_group_if_needed
(
ROOT_GROUPS
[
:support_files
])
end
# @return [PBXGroup] The group for the Pods.
# @return [PBXGroup] The group for the Pods.
#
#
attr_reader
:pods
def
pods
name
=
'Pods'
create_group_if_needed
(
ROOT_GROUPS
[
:pods
])
end
# @return [PBXGroup] The group for Development Pods.
# @return [PBXGroup] The group for Development Pods.
#
#
attr_reader
:development_pods
def
development_pods
name
=
'Development Pods'
create_group_if_needed
(
ROOT_GROUPS
[
:development_pods
])
end
# Cleans up the project to prepare it for serialization.
#
# @return [void]
#
def
prepare_for_serialization
pods
.
remove_from_project
if
pods
.
empty?
development_pods
.
remove_from_project
if
development_pods
.
empty?
main_group
.
recursively_sort_by_type
end
public
public
...
@@ -172,17 +195,39 @@ module Pod
...
@@ -172,17 +195,39 @@ module Pod
#
#
def
add_podfile
(
podfile_path
)
def
add_podfile
(
podfile_path
)
podfile_ref
=
new_file
(
podfile_path
,
:project
)
podfile_ref
=
new_file
(
podfile_path
,
:project
)
podfile_ref
.
name
=
'Podfile'
podfile_ref
.
xc_language_specification_identifier
=
'xcode.lang.ruby'
podfile_ref
.
xc_language_specification_identifier
=
'xcode.lang.ruby'
podfile_ref
.
last_known_file_type
=
'text'
podfile_ref
.
last_known_file_type
=
'text'
podfile_ref
podfile_ref
end
end
# @return [PBXFileReference] The file reference of the Podfile.
#
def
podfile
main_group
[
'Podfile'
]
end
private
private
# @!group Private helpers
# @!group Private helpers
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
# Returns the group with the given name, creating it if needed.
#
# @param [String] name
# The name of the group.
#
# @param [String] parent
# The parent group. If nil resolves to the maingroup.
#
# @return [PBXGroup] The group.
#
def
create_group_if_needed
(
name
,
parent
=
nil
)
parent
||=
main_group
parent
[
name
]
||
parent
.
new_group
(
name
)
end
# @return [Hash{String => PBXFileReference}] The file references grouped
# @return [Hash{String => PBXFileReference}] The file references grouped
# by absolute path.
# by absolute path.
#
#
...
@@ -202,7 +247,7 @@ module Pod
...
@@ -202,7 +247,7 @@ module Pod
if
spec_name
!=
pod_name
if
spec_name
!=
pod_name
subspecs_names
=
spec_name
.
gsub
(
pod_name
+
'/'
,
''
).
split
(
'/'
)
subspecs_names
=
spec_name
.
gsub
(
pod_name
+
'/'
,
''
).
split
(
'/'
)
subspecs_names
.
each
do
|
name
|
subspecs_names
.
each
do
|
name
|
subspecs_group
=
group
[
SPEC_SUBGROUPS
[
:subspecs
]]
||
group
.
new_group
(
SPEC_SUBGROUPS
[
:subspecs
]
)
subspecs_group
=
create_group_if_needed
(
SPEC_SUBGROUPS
[
:subspecs
],
group
)
group
=
subspecs_group
[
name
]
||
subspecs_group
.
new_group
(
name
)
group
=
subspecs_group
[
name
]
||
subspecs_group
.
new_group
(
name
)
end
end
end
end
...
...
spec/unit/project_spec.rb
View file @
3ed1918d
...
@@ -11,18 +11,33 @@ module Pod
...
@@ -11,18 +11,33 @@ module Pod
describe
"In general"
do
describe
"In general"
do
it
"
creates the support files group on initialization
"
do
it
"
returns the support files group
"
do
@project
.
support_files_group
.
name
.
should
==
'Targets Support Files'
@project
.
support_files_group
.
name
.
should
==
'Targets Support Files'
end
end
it
"
creates the Pods group on initialization
"
do
it
"
returns the pods group
"
do
@project
.
pods
.
name
.
should
==
'Pods'
@project
.
pods
.
name
.
should
==
'Pods'
end
end
it
"
creates the development Pods group on initialization
"
do
it
"
returns development Pods group
"
do
@project
.
development_pods
.
name
.
should
==
'Development Pods'
@project
.
development_pods
.
name
.
should
==
'Development Pods'
end
end
describe
"#prepare_for_serialization"
do
it
"deletes the Pod and the Development Pods groups if empty"
do
@project
.
prepare_for_serialization
@project
[
Project
::
ROOT_GROUPS
[
:pods
]].
should
.
be
.
nil
@project
[
Project
::
ROOT_GROUPS
[
:development_pods
]].
should
.
be
.
nil
end
it
"sorts the groups recursively"
do
@project
.
pods
.
new_group
(
'group_2'
)
@project
.
pods
.
new_group
(
'group_1'
)
@project
.
prepare_for_serialization
@project
.
pods
.
children
.
map
(
&
:name
).
should
==
[
"group_1"
,
"group_2"
]
end
end
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
@@ -202,12 +217,39 @@ module Pod
...
@@ -202,12 +217,39 @@ module Pod
f
.
path
.
should
==
'../Podfile'
f
.
path
.
should
==
'../Podfile'
end
end
it
"returns the file reference of the Podfile"
do
ref
=
@project
.
add_podfile
(
config
.
sandbox
.
root
+
'../Podfile'
)
@project
.
podfile
.
should
.
equal
(
ref
)
end
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
describe
"Private helpers"
do
describe
"Private helpers"
do
describe
"#create_group_if_needed"
do
it
"creates a new group"
do
group
=
@project
.
send
(
:create_group_if_needed
,
'Group'
)
group
.
hierarchy_path
.
should
==
'/Group'
end
it
"creates a new group"
do
group
=
@project
.
send
(
:create_group_if_needed
,
'Group'
,
@project
.
pods
)
group
.
hierarchy_path
.
should
==
'/Pods/Group'
end
it
"returns an already existing group"
do
group_1
=
@project
.
send
(
:create_group_if_needed
,
'Group'
)
group_2
=
@project
.
send
(
:create_group_if_needed
,
'Group'
)
group_1
.
should
.
be
.
equal
(
group_2
)
end
end
#----------------------------------------#
describe
"#spec_group"
do
describe
"#spec_group"
do
before
do
before
do
...
...
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