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
2c8e43a3
Commit
2c8e43a3
authored
Apr 19, 2016
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Init] Clean up target partitioning
parent
91eaa5f7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
16 deletions
+10
-16
init.rb
lib/cocoapods/command/init.rb
+7
-12
init_spec.rb
spec/functional/command/init_spec.rb
+3
-4
No files found.
lib/cocoapods/command/init.rb
View file @
2c8e43a3
...
...
@@ -63,17 +63,13 @@ module Pod
PLATFORM
# Split out the targets into app and test targets
all_app_targets
=
project
.
native_targets
.
reject
{
|
t
|
t
.
name
=~
/tests?/i
}
all_tests_targets
=
project
.
native_targets
.
select
{
|
t
|
t
.
name
=~
/tests?/i
}
test_targets
,
app_targets
=
project
.
native_targets
.
partition
{
|
t
|
t
.
name
=~
/test/i
}
# Create an array of [app, (optional)test] target pairs
app_test_pairs
=
all_app_targets
.
map
do
|
target
|
test
=
all_tests_targets
.
select
{
|
t
|
t
.
name
.
start_with?
target
.
name
}
[
target
,
*
test
].
compact
app_targets
.
each
do
|
app_target
|
test_targets_for_app
=
test_targets
.
select
do
|
target
|
target
.
name
.
downcase
.
start_with?
(
app_target
.
name
.
downcase
)
end
app_test_pairs
.
each
do
|
target_pair
|
podfile
<<
target_module
(
target_pair
)
podfile
<<
target_module
(
app_target
,
test_targets_for_app
)
end
podfile
...
...
@@ -85,12 +81,11 @@ module Pod
#
# @return [String] the text for the target module
#
def
target_module
(
targets
)
app
=
targets
.
first
def
target_module
(
app
,
tests
)
target_module
=
"
\n
target '
#{
app
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
template_contents
(
config
.
default_podfile_path
,
" "
,
"Pods for
#{
app
.
name
}
\n
"
)
t
argets
[
1
..-
1
]
.
each
do
|
test
|
t
ests
.
each
do
|
test
|
target_module
<<
"
\n
target '
#{
test
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
" inherit! :search_paths
\n
"
target_module
<<
template_contents
(
config
.
default_test_podfile_path
,
" "
,
"Pods for testing"
)
...
...
spec/functional/command/init_spec.rb
View file @
2c8e43a3
...
...
@@ -96,8 +96,7 @@ module Pod
run_command
(
'init'
)
podfile_text
=
File
.
read
(
temporary_directory
+
"Podfile"
)
podfile_exact
=
<<-
PODFILE
.
strip_heredoc
expected_podfile
=
<<-
RUBY
.
strip_heredoc
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# Uncomment this line if you're using Swift
...
...
@@ -117,9 +116,9 @@ module Pod
end
end
PODFILE
RUBY
podfile_text
.
should
==
podfile_exact
File
.
read
(
'Podfile'
).
should
==
expected_podfile
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