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
2cd77b5a
Commit
2cd77b5a
authored
Apr 27, 2015
by
Marius Rackwitz
Committed by
Samuel E. Giddins
Apr 28, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Installer] Extract run_prepare_command in own controller class
parent
a572eb55
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
26 deletions
+75
-26
cache.rb
lib/cocoapods/downloader/cache.rb
+1
-0
installer.rb
lib/cocoapods/installer.rb
+1
-0
pod_source_installer.rb
lib/cocoapods/installer/pod_source_installer.rb
+1
-24
pod_source_preparer.rb
lib/cocoapods/installer/pod_source_preparer.rb
+70
-0
pod_source_installer_spec.rb
spec/unit/installer/pod_source_installer_spec.rb
+2
-2
No files found.
lib/cocoapods/downloader/cache.rb
View file @
2cd77b5a
...
@@ -188,6 +188,7 @@ module Pod
...
@@ -188,6 +188,7 @@ module Pod
end
end
destination
.
parent
.
mkpath
destination
.
parent
.
mkpath
FileUtils
.
cp_r
(
source
,
destination
)
FileUtils
.
cp_r
(
source
,
destination
)
Pod
::
Installer
::
PodSourcePreparer
.
new
(
spec
,
destination
).
prepare!
Sandbox
::
PodDirCleaner
.
new
(
destination
,
specs_by_platform
).
clean!
Sandbox
::
PodDirCleaner
.
new
(
destination
,
specs_by_platform
).
clean!
end
end
...
...
lib/cocoapods/installer.rb
View file @
2cd77b5a
...
@@ -34,6 +34,7 @@ module Pod
...
@@ -34,6 +34,7 @@ module Pod
autoload
:HooksContext
,
'cocoapods/installer/hooks_context'
autoload
:HooksContext
,
'cocoapods/installer/hooks_context'
autoload
:Migrator
,
'cocoapods/installer/migrator'
autoload
:Migrator
,
'cocoapods/installer/migrator'
autoload
:PodSourceInstaller
,
'cocoapods/installer/pod_source_installer'
autoload
:PodSourceInstaller
,
'cocoapods/installer/pod_source_installer'
autoload
:PodSourcePreparer
,
'cocoapods/installer/pod_source_preparer'
autoload
:PodTargetInstaller
,
'cocoapods/installer/target_installer/pod_target_installer'
autoload
:PodTargetInstaller
,
'cocoapods/installer/target_installer/pod_target_installer'
autoload
:TargetInstaller
,
'cocoapods/installer/target_installer'
autoload
:TargetInstaller
,
'cocoapods/installer/target_installer'
autoload
:UserProjectIntegrator
,
'cocoapods/installer/user_project_integrator'
autoload
:UserProjectIntegrator
,
'cocoapods/installer/user_project_integrator'
...
...
lib/cocoapods/installer/pod_source_installer.rb
View file @
2cd77b5a
...
@@ -43,7 +43,7 @@ module Pod
...
@@ -43,7 +43,7 @@ module Pod
#
#
def
install!
def
install!
download_source
unless
predownloaded?
||
local?
download_source
unless
predownloaded?
||
local?
run_prepare_command
PodSourcePreparer
.
new
(
root_spec
,
root
).
prepare!
if
local?
lock_files!
lock_files!
end
end
...
@@ -109,29 +109,6 @@ module Pod
...
@@ -109,29 +109,6 @@ module Pod
end
end
end
end
extend
Executable
executable
:bash
# Runs the prepare command bash script of the spec.
#
# @note Unsets the `CDPATH` env variable before running the
# shell script to avoid issues with relative paths
# (issue #1694).
#
# @return [void]
#
def
run_prepare_command
return
unless
root_spec
.
prepare_command
UI
.
section
(
' > Running prepare command'
,
''
,
1
)
do
Dir
.
chdir
(
root
)
do
ENV
.
delete
(
'CDPATH'
)
prepare_command
=
root_spec
.
prepare_command
.
strip_heredoc
.
chomp
full_command
=
"
\n
set -e
\n
"
+
prepare_command
bash!
(
'-c'
,
full_command
)
end
end
end
# Removes all the files not needed for the installation according to the
# Removes all the files not needed for the installation according to the
# specs by platform.
# specs by platform.
#
#
...
...
lib/cocoapods/installer/pod_source_preparer.rb
0 → 100644
View file @
2cd77b5a
module
Pod
class
Installer
# Controller class responsible of executing the prepare command
# of a single Pod.
#
class
PodSourcePreparer
# @return [Specification] the root specification of the Pod.
#
attr_reader
:spec
# @return [Pathname] the folder where the source of the Pod is located.
#
attr_reader
:path
# @param [Specification] spec the root specification of the Pod.
# @param [Pathname] path the folder where the source of the Pod is located.
#
def
initialize
(
spec
,
path
)
raise
"Given spec isn't a root spec, but must be."
unless
spec
.
root?
@spec
=
spec
@path
=
path
end
#-----------------------------------------------------------------------#
public
# @!group Preparation
# Executes the prepare command if there is one.
#
# @return [void]
#
def
prepare!
run_prepare_command
end
#-----------------------------------------------------------------------#
private
# @!group Preparation Steps
extend
Executable
executable
:bash
# Runs the prepare command bash script of the spec.
#
# @note Unsets the `CDPATH` env variable before running the
# shell script to avoid issues with relative paths
# (issue #1694).
#
# @return [void]
#
def
run_prepare_command
return
unless
spec
.
prepare_command
UI
.
section
(
' > Running prepare command'
,
''
,
1
)
do
Dir
.
chdir
(
path
)
do
ENV
.
delete
(
'CDPATH'
)
prepare_command
=
spec
.
prepare_command
.
strip_heredoc
.
chomp
full_command
=
"
\n
set -e
\n
"
+
prepare_command
bash!
(
'-c'
,
full_command
)
end
end
end
#-----------------------------------------------------------------------#
end
end
end
spec/unit/installer/pod_source_installer_spec.rb
View file @
2cd77b5a
...
@@ -67,12 +67,12 @@ module Pod
...
@@ -67,12 +67,12 @@ module Pod
describe
'Prepare command'
do
describe
'Prepare command'
do
it
'runs the prepare command if one has been declared in the spec'
do
it
'runs the prepare command if one has been declared in the spec'
do
@spec
.
prepare_command
=
'echo test'
@spec
.
prepare_command
=
'echo test'
@installer
.
expects
(
:bash!
).
once
Installer
::
PodSourcePreparer
.
any_instance
.
expects
(
:bash!
).
once
@installer
.
install!
@installer
.
install!
end
end
it
"doesn't run the prepare command if it hasn't been declared in the spec"
do
it
"doesn't run the prepare command if it hasn't been declared in the spec"
do
@installer
.
expects
(
:bash!
).
never
Installer
::
PodSourcePreparer
.
any_instance
.
expects
(
:bash!
).
never
@installer
.
install!
@installer
.
install!
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