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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
34 deletions
+28
-34
init.rb
lib/cocoapods/command/init.rb
+8
-13
init_spec.rb
spec/functional/command/init_spec.rb
+20
-21
No files found.
lib/cocoapods/command/init.rb
View file @
2c8e43a3
...
@@ -63,17 +63,13 @@ module Pod
...
@@ -63,17 +63,13 @@ module Pod
PLATFORM
PLATFORM
# Split out the targets into app and test targets
# Split out the targets into app and test targets
all_app_targets
=
project
.
native_targets
.
reject
{
|
t
|
t
.
name
=~
/tests?/i
}
test_targets
,
app_targets
=
project
.
native_targets
.
partition
{
|
t
|
t
.
name
=~
/test/i
}
all_tests_targets
=
project
.
native_targets
.
select
{
|
t
|
t
.
name
=~
/tests?/i
}
# Create an array of [app, (optional)test] target pairs
app_targets
.
each
do
|
app_target
|
app_test_pairs
=
all_app_targets
.
map
do
|
target
|
test_targets_for_app
=
test_targets
.
select
do
|
target
|
test
=
all_tests_targets
.
select
{
|
t
|
t
.
name
.
start_with?
target
.
name
}
target
.
name
.
downcase
.
start_with?
(
app_target
.
name
.
downcase
)
[
target
,
*
test
].
compact
end
end
podfile
<<
target_module
(
app_target
,
test_targets_for_app
)
app_test_pairs
.
each
do
|
target_pair
|
podfile
<<
target_module
(
target_pair
)
end
end
podfile
podfile
...
@@ -85,12 +81,11 @@ module Pod
...
@@ -85,12 +81,11 @@ module Pod
#
#
# @return [String] the text for the target module
# @return [String] the text for the target module
#
#
def
target_module
(
targets
)
def
target_module
(
app
,
tests
)
app
=
targets
.
first
target_module
=
"
\n
target '
#{
app
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
=
"
\n
target '
#{
app
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
template_contents
(
config
.
default_podfile_path
,
" "
,
"Pods for
#{
app
.
name
}
\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
<<
"
\n
target '
#{
test
.
name
.
gsub
(
/'/
,
"
\\\\\'
"
)
}
' do
\n
"
target_module
<<
" inherit! :search_paths
\n
"
target_module
<<
" inherit! :search_paths
\n
"
target_module
<<
template_contents
(
config
.
default_test_podfile_path
,
" "
,
"Pods for testing"
)
target_module
<<
template_contents
(
config
.
default_test_podfile_path
,
" "
,
"Pods for testing"
)
...
...
spec/functional/command/init_spec.rb
View file @
2c8e43a3
...
@@ -96,30 +96,29 @@ module Pod
...
@@ -96,30 +96,29 @@ module Pod
run_command
(
'init'
)
run_command
(
'init'
)
podfile_text
=
File
.
read
(
temporary_directory
+
"Podfile"
)
expected_podfile
=
<<-
RUBY
.
strip_heredoc
podfile_exact
=
<<-
PODFILE
.
strip_heredoc
# Uncomment this line to define a global platform for your project
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# platform :ios, '9.0'
# Uncomment this line if you're using Swift
# Uncomment this line if you're using Swift
# use_frameworks!
# use_frameworks!
target 'App' do
# Pods for App
target 'AppTests' do
inherit! :search_paths
# Pods for testing
end
target 'AppFeatureTests' do
target 'App' do
inherit! :search_paths
# Pods for App
# Pods for testing
end
target 'AppTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'AppFeatureTests' do
PODFILE
inherit! :search_paths
# Pods for testing
end
end
RUBY
podfile_text
.
should
==
podfile_exact
File
.
read
(
'Podfile'
).
should
==
expected_podfile
end
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