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
d382eb07
Commit
d382eb07
authored
Jun 10, 2013
by
Ian Ynda-Hummel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address line note comments on code style.
parent
7c334329
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
20 deletions
+36
-20
init.rb
lib/cocoapods/command/init.rb
+24
-20
init_spec.rb
spec/functional/command/init_spec.rb
+12
-0
No files found.
lib/cocoapods/command/init.rb
View file @
d382eb07
require
'xcodeproj'
require
'active_support/core_ext/string/strip'
module
Pod
class
Command
...
...
@@ -22,7 +23,7 @@ module Pod
def
validate!
super
help!
"Existing Podfile found in directory"
if
File
.
file?
@podfile_path
help!
"Existing Podfile found in directory"
unless
config
.
podfile
.
nil?
unless
@project_path
help!
"No xcode project found, please specify one"
unless
@project_paths
.
length
>
0
help!
"Multiple xcode projects found, please specify one"
unless
@project_paths
.
length
==
1
...
...
@@ -36,33 +37,36 @@ module Pod
@podfile_path
.
open
(
'w'
)
{
|
f
|
f
<<
podfile_template
(
@xcode_project
)
}
end
private
# @param [Xcodeproj::Project] project
# The xcode project to generate a podfile for.
#
# @return [String] the text of the Podfile for the provided project
#
def
podfile_template
(
project
)
platforms
=
project
.
targets
.
map
{
|
t
|
t
.
platform_name
}.
uniq
has_global_platform
=
platforms
.
length
==
1
if
has_global_platform
podfile
=
<<-
PLATFORM
platform :
#{
platforms
.
first
}
PLATFORM
else
podfile
=
<<-
PLATFORM
# Uncomment this line to define a global platform for your project
# platform :ios, "6.0"
PLATFORM
end
podfile
=
<<-
PLATFORM
.
strip_heredoc
# Uncomment this line to define a global platform for your project
# platform :ios, "6.0"
PLATFORM
for
target
in
project
.
targets
podfile
<<
target_module
(
target
,
!
has_global_platform
)
end
podfile
end
def
target_module
(
target
,
define_platform
=
true
)
platform
=
"platform :
#{
target
.
platform_name
}
"
if
define_platform
return
<<-
TARGET
# @param [Xcodeproj::PBXTarget] target
# A target to generate a Podfile target module for.
#
# @return [String] the text for the target module
#
def
target_module
(
target
)
return
<<-
TARGET
.
strip_heredoc
target "
#{
target
.
name
}
" do
#{
platform
}
end
TARGET
target "
#{
target
.
name
}
" do
end
TARGET
end
end
end
...
...
spec/functional/command/init_spec.rb
View file @
d382eb07
...
...
@@ -26,6 +26,17 @@ module Pod
Dir
.
chdir
(
pwd
)
end
it
"complains if a Podfile already exists"
do
pwd
=
Dir
.
pwd
Dir
.
chdir
(
temporary_directory
)
(
Pathname
.
pwd
+
'Podfile'
).
open
(
'w'
)
{
|
f
|
f
<<
"pod 'AFNetworking'"
}
Xcodeproj
::
Project
.
new
.
save_as
(
temporary_directory
+
'test1.xcodeproj'
)
lambda
{
run_command
(
'init'
)
}.
should
.
raise
CLAide
::
Help
Dir
.
chdir
(
pwd
)
end
it
"creates a Podfile for a project in current directory"
do
pwd
=
Dir
.
pwd
Dir
.
chdir
(
temporary_directory
)
...
...
@@ -45,6 +56,7 @@ module Pod
Xcodeproj
::
Project
.
new
.
save_as
(
temporary_directory
+
'test2.xcodeproj'
)
run_command
(
'init'
,
'test2.xcodeproj'
)
Pathname
.
new
(
temporary_directory
+
'Podfile'
).
exist?
.
should
==
true
config
.
podfile
.
nil?
.
should
==
false
Dir
.
chdir
(
pwd
)
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