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
feda6564
Commit
feda6564
authored
Aug 11, 2014
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Installer] Add post install hook for plugins
parent
03d5b793
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
140 additions
and
6 deletions
+140
-6
installer.rb
lib/cocoapods/installer.rb
+11
-2
hooks_context.rb
lib/cocoapods/installer/hooks_context.rb
+77
-0
hooks_context_spec.rb
spec/unit/installer/hooks_context_spec.rb
+31
-0
installer_spec.rb
spec/unit/installer_spec.rb
+21
-4
No files found.
lib/cocoapods/installer.rb
View file @
feda6564
...
...
@@ -37,6 +37,7 @@ module Pod
autoload
:AggregateTargetInstaller
,
'cocoapods/installer/target_installer/aggregate_target_installer'
autoload
:PodTargetInstaller
,
'cocoapods/installer/target_installer/pod_target_installer'
autoload
:UserProjectIntegrator
,
'cocoapods/installer/user_project_integrator'
autoload
:HooksContext
,
'cocoapods/installer/hooks_context'
include
Config
::
Mixin
...
...
@@ -117,7 +118,7 @@ module Pod
install_libraries
set_target_dependencies
link_aggregate_target
run_post_install_hooks
run_po
dfile_po
st_install_hooks
write_pod_project
write_lockfiles
end
...
...
@@ -293,9 +294,17 @@ module Pod
# @return [void]
#
def
perform_post_install_actions
run_plugins_post_install_hooks
warn_for_deprecations
end
# Runs the registered callbacks for the plugins post install hooks.
#
def
run_plugins_post_install_hooks
context
=
HooksContext
.
generate
(
sandbox
,
aggregate_targets
)
HooksManager
.
run
(
:post_install
,
context
)
end
# Prints a warning for any pods that are deprecated
#
# @return [void]
...
...
@@ -521,7 +530,7 @@ module Pod
#
# @return [void]
#
def
run_post_install_hooks
def
run_po
dfile_po
st_install_hooks
UI
.
message
"- Running post install hooks"
do
executed
=
run_podfile_post_install_hook
UI
.
message
"- Podfile"
if
executed
...
...
lib/cocoapods/installer/hooks_context.rb
0 → 100644
View file @
feda6564
module
Pod
class
Installer
# Context object designed to be used with the HooksManager which describes
# the context of the installer.
#
class
HooksContext
# @return [String] The path to the sandbox root (`Pods` directory).
#
attr_accessor
:sandbox_root
# @return [Array<UmbrellaTargetDescription>] The list of
# the CocoaPods umbrella targets generated by the installer.
#
attr_accessor
:umbrella_targets
# @return [HooksContext] Convenience class method to generate the
# static context.
#
def
self
.
generate
(
sandbox
,
aggregate_targets
)
umbrella_targets_descriptions
=
[]
aggregate_targets
.
each
do
|
umbrella
|
desc
=
UmbrellaTargetDescription
.
new
desc
.
user_project_path
=
umbrella
.
user_project_path
desc
.
user_target_uuids
=
umbrella
.
user_target_uuids
desc
.
specs
=
umbrella
.
specs
desc
.
platform_name
=
umbrella
.
platform
.
name
desc
.
platform_deployment_target
=
umbrella
.
platform
.
deployment_target
.
to_s
desc
.
cocoapods_target_label
=
umbrella
.
label
umbrella_targets_descriptions
<<
desc
end
result
=
new
result
.
sandbox_root
=
sandbox
.
root
.
to_s
result
.
umbrella_targets
=
umbrella_targets_descriptions
result
end
# Pure data class which describes and umbrella target.
#
class
UmbrellaTargetDescription
# @return [String] The path of the user project
# integrated by this target.
#
attr_accessor
:user_project_path
# @return [Array<String>] The list of the UUIDs of the
# user targets integrated by this umbrella
# target. They can be used to find the
# targets opening the project They can be used
# to find the targets opening the project with
# Xcodeproj.
#
attr_accessor
:user_target_uuids
# @return [Array<Specification>] The list of the
# specifications of the target.
#
attr_accessor
:specs
# @return [Symbol] The platform (either `:ios` or `:osx`).
#
attr_accessor
:platform_name
# @return [String] The deployment target.
#
attr_accessor
:platform_deployment_target
# @return [String] The label for the target.
#
attr_accessor
:cocoapods_target_label
end
end
end
end
spec/unit/installer/hooks_context_spec.rb
0 → 100644
View file @
feda6564
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Installer
::
HooksContext
do
it
"offers a convenience method to be generated"
do
sandbox
=
stub
(
:root
=>
'/path'
)
spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
target_definition
=
Podfile
::
TargetDefinition
.
new
(
'Pods'
,
nil
)
pod_target
=
PodTarget
.
new
([
spec
],
target_definition
,
config
.
sandbox
)
umbrella
=
AggregateTarget
.
new
(
target_definition
,
config
.
sandbox
)
umbrella
.
user_project_path
=
'/path/project.xcodeproj'
umbrella
.
user_target_uuids
=
[
'UUID'
]
umbrella
.
stubs
(
:platform
).
returns
(
Platform
.
new
(
:ios
,
'8.0'
))
umbrella
.
pod_targets
=
[
pod_target
]
result
=
Installer
::
HooksContext
.
generate
(
sandbox
,
[
umbrella
])
result
.
class
.
should
==
Installer
::
HooksContext
result
.
sandbox_root
.
should
==
'/path'
result
.
umbrella_targets
.
count
.
should
==
1
umbrella_target
=
result
.
umbrella_targets
.
first
umbrella_target
.
user_target_uuids
.
should
==
[
'UUID'
]
umbrella_target
.
user_project_path
.
should
==
'/path/project.xcodeproj'
umbrella_target
.
specs
.
should
==
[
spec
]
umbrella_target
.
platform_name
.
should
==
:ios
umbrella_target
.
platform_deployment_target
.
should
==
'8.0'
umbrella_target
.
cocoapods_target_label
.
should
==
'Pods'
end
end
end
spec/unit/installer_spec.rb
View file @
feda6564
...
...
@@ -52,6 +52,7 @@ module Pod
@installer
.
stubs
(
:download_dependencies
)
@installer
.
stubs
(
:generate_pods_project
)
@installer
.
stubs
(
:integrate_user_project
)
@installer
.
stubs
(
:run_plugins_post_install_hooks
)
@installer
.
stubs
(
:perform_post_install_actions
)
end
...
...
@@ -77,7 +78,7 @@ module Pod
@installer
.
stubs
(
:write_lockfiles
)
@installer
.
stubs
(
:aggregate_targets
).
returns
([])
@installer
.
unstub
(
:generate_pods_project
)
def
@installer
.
run_post_install_hooks
def
@installer
.
run_po
dfile_po
st_install_hooks
@hook_called
=
true
end
def
@installer
.
write_pod_project
...
...
@@ -475,6 +476,22 @@ module Pod
end
describe
"Plugins Hooks"
do
before
do
@installer
.
send
(
:analyze
)
@specs
=
@installer
.
pod_targets
.
map
(
&
:specs
).
flatten
@spec
=
@specs
.
find
{
|
spec
|
spec
&&
spec
.
name
==
'JSONKit'
}
@installer
.
stubs
(
:installed_specs
).
returns
(
@specs
)
end
it
"runs plugins post install hook"
do
context
=
stub
()
Installer
::
HooksContext
.
expects
(
:generate
).
returns
(
context
)
HooksManager
.
expects
(
:run
).
with
(
:post_install
,
context
)
@installer
.
send
(
:run_plugins_post_install_hooks
)
end
end
#-------------------------------------------------------------------------#
describe
"Hooks"
do
...
...
@@ -497,13 +514,13 @@ module Pod
@installer
.
send
(
:run_pre_install_hooks
)
end
it
"run_post_install_hooks"
do
it
"run_po
dfile_po
st_install_hooks"
do
installer_rep
=
stub
()
target_installer_data
=
stub
()
@installer
.
expects
(
:installer_rep
).
returns
(
installer_rep
)
@installer
.
podfile
.
expects
(
:post_install!
).
with
(
installer_rep
)
@installer
.
send
(
:run_post_install_hooks
)
@installer
.
send
(
:run_po
dfile_po
st_install_hooks
)
end
it
"calls the hooks in the specs for each target"
do
...
...
@@ -519,7 +536,7 @@ module Pod
@installer
.
stubs
(
:installer_rep
).
returns
(
stub
())
@installer
.
podfile
.
expects
(
:pre_install!
)
@installer
.
send
(
:run_pre_install_hooks
)
@installer
.
send
(
:run_post_install_hooks
)
@installer
.
send
(
:run_po
dfile_po
st_install_hooks
)
end
it
"returns the hook representation of the installer"
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