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
15c2cb7e
Commit
15c2cb7e
authored
Jul 07, 2015
by
Eric Amorde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Installer] Add support for source provider plugin hook
parent
9e796e48
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
127 additions
and
12 deletions
+127
-12
CHANGELOG.md
CHANGELOG.md
+4
-0
installer.rb
lib/cocoapods/installer.rb
+26
-12
source_provider_hooks_context.rb
lib/cocoapods/installer/source_provider_hooks_context.rb
+32
-0
source_provider_hooks_context_spec.rb
spec/unit/installer/source_provider_hooks_context_spec.rb
+12
-0
installer_spec.rb
spec/unit/installer_spec.rb
+53
-0
No files found.
CHANGELOG.md
View file @
15c2cb7e
...
@@ -136,6 +136,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
...
@@ -136,6 +136,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
is now a default plugin.
is now a default plugin.
[
Samuel Giddins
](
https://github.com/segiddins
)
[
Samuel Giddins
](
https://github.com/segiddins
)
*
Added a
`:source_provider`
hook to allow plugins to provide their own sources
[
Eric Amorde
](
https://github.com/amorde
)
[
#3792
](
https://github.com/CocoaPods/CocoaPods/pull/3792
)
##### Bug Fixes
##### Bug Fixes
*
Ensure that the
`prepare_command`
is run even when skipping the download
*
Ensure that the
`prepare_command`
is run even when skipping the download
...
...
lib/cocoapods/installer.rb
View file @
15c2cb7e
...
@@ -29,18 +29,19 @@ module Pod
...
@@ -29,18 +29,19 @@ module Pod
# source control.
# source control.
#
#
class
Installer
class
Installer
autoload
:AggregateTargetInstaller
,
'cocoapods/installer/target_installer/aggregate_target_installer'
autoload
:AggregateTargetInstaller
,
'cocoapods/installer/target_installer/aggregate_target_installer'
autoload
:Analyzer
,
'cocoapods/installer/analyzer'
autoload
:Analyzer
,
'cocoapods/installer/analyzer'
autoload
:FileReferencesInstaller
,
'cocoapods/installer/file_references_installer'
autoload
:FileReferencesInstaller
,
'cocoapods/installer/file_references_installer'
autoload
:PostInstallHooksContext
,
'cocoapods/installer/post_install_hooks_context'
autoload
:PostInstallHooksContext
,
'cocoapods/installer/post_install_hooks_context'
autoload
:PreInstallHooksContext
,
'cocoapods/installer/pre_install_hooks_context'
autoload
:PreInstallHooksContext
,
'cocoapods/installer/pre_install_hooks_context'
autoload
:Migrator
,
'cocoapods/installer/migrator'
autoload
:SourceProviderHooksContext
,
'cocoapods/installer/source_provider_hooks_context'
autoload
:PodfileValidator
,
'cocoapods/installer/podfile_validator'
autoload
:Migrator
,
'cocoapods/installer/migrator'
autoload
:PodSourceInstaller
,
'cocoapods/installer/pod_source_installer'
autoload
:PodfileValidator
,
'cocoapods/installer/podfile_validator'
autoload
:PodSourcePreparer
,
'cocoapods/installer/pod_source_preparer'
autoload
:PodSourceInstaller
,
'cocoapods/installer/pod_source_installer'
autoload
:PodTargetInstaller
,
'cocoapods/installer/target_installer/pod_target_installer'
autoload
:PodSourcePreparer
,
'cocoapods/installer/pod_source_preparer'
autoload
:TargetInstaller
,
'cocoapods/installer/target_installer'
autoload
:PodTargetInstaller
,
'cocoapods/installer/target_installer/pod_target_installer'
autoload
:UserProjectIntegrator
,
'cocoapods/installer/user_project_integrator'
autoload
:TargetInstaller
,
'cocoapods/installer/target_installer'
autoload
:UserProjectIntegrator
,
'cocoapods/installer/user_project_integrator'
include
Config
::
Mixin
include
Config
::
Mixin
...
@@ -125,6 +126,9 @@ module Pod
...
@@ -125,6 +126,9 @@ module Pod
def
resolve_dependencies
def
resolve_dependencies
analyzer
=
create_analyzer
analyzer
=
create_analyzer
plugin_sources
=
run_source_provider_hooks
analyzer
.
sources
.
push
(
*
plugin_sources
)
UI
.
section
'Updating local specs repositories'
do
UI
.
section
'Updating local specs repositories'
do
analyzer
.
update_repositories
analyzer
.
update_repositories
end
unless
config
.
skip_repo_update?
end
unless
config
.
skip_repo_update?
...
@@ -453,6 +457,16 @@ module Pod
...
@@ -453,6 +457,16 @@ module Pod
HooksManager
.
run
(
:post_install
,
context
,
plugins
)
HooksManager
.
run
(
:post_install
,
context
,
plugins
)
end
end
# Runs the registered callbacks for the source provider plugin hooks.
#
# @return [void]
#
def
run_source_provider_hooks
context
=
SourceProviderHooksContext
.
generate
HooksManager
.
run
(
:source_provider
,
context
,
plugins
)
context
.
sources
end
# Ensures that all plugins specified in the {#podfile} are loaded.
# Ensures that all plugins specified in the {#podfile} are loaded.
#
#
# @return [void]
# @return [void]
...
...
lib/cocoapods/installer/source_provider_hooks_context.rb
0 → 100644
View file @
15c2cb7e
module
Pod
class
Installer
# Context object designed to be used with the HooksManager which describes
# the context of the installer before spec sources have been created
#
class
SourceProviderHooksContext
# @return [Array<Source>] The source objects to send to the installer
#
attr_reader
:sources
# @return [SourceProviderHooksContext] Convenience class method to generate the
# static context.
#
def
self
.
generate
result
=
new
result
end
def
initialize
@sources
=
[]
end
# @param [Source] Source object to be added to the installer
#
def
add_source
(
source
)
unless
source
.
nil?
@sources
<<
source
end
end
end
end
end
spec/unit/installer/source_provider_hooks_context_spec.rb
0 → 100644
View file @
15c2cb7e
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Installer
::
SourceProviderHooksContext
do
it
'offers a convenience method to be generated'
do
result
=
Installer
::
SourceProviderHooksContext
.
generate
result
.
class
.
should
==
Installer
::
SourceProviderHooksContext
result
.
sources
.
should
==
[]
end
end
end
spec/unit/installer_spec.rb
View file @
15c2cb7e
...
@@ -93,6 +93,51 @@ module Pod
...
@@ -93,6 +93,51 @@ module Pod
@installer
.
install!
@installer
.
install!
end
end
it
'runs source provider hooks before analyzing'
do
config
.
skip_repo_update
=
true
@installer
.
unstub
(
:resolve_dependencies
)
@installer
.
stubs
(
:validate_build_configurations
)
@installer
.
stubs
(
:prepare_for_legacy_compatibility
)
@installer
.
stubs
(
:clean_sandbox
)
def
@installer
.
run_source_provider_hooks
@hook_called
=
true
end
def
@installer
.
analyze
(
*
)
@hook_called
.
should
.
be
.
true
end
@installer
.
install!
end
it
'includes sources from source provider plugins'
do
plugin_name
=
'test-plugin'
Pod
::
HooksManager
.
register
(
plugin_name
,
:source_provider
)
do
|
context
,
options
|
source_url
=
options
[
'sources'
].
first
return
unless
source_url
source
=
Pod
::
Source
.
new
(
source_url
)
context
.
add_source
(
source
)
end
test_source_name
=
'https://github.com/artsy/Specs.git'
plugins_hash
=
Installer
::
DEFAULT_PLUGINS
.
merge
(
plugin_name
=>
{
'sources'
=>
[
test_source_name
]
})
@installer
.
podfile
.
stubs
(
:plugins
).
returns
(
plugins_hash
)
@installer
.
unstub
(
:resolve_dependencies
)
@installer
.
stubs
(
:validate_build_configurations
)
@installer
.
stubs
(
:prepare_for_legacy_compatibility
)
@installer
.
stubs
(
:clean_sandbox
)
@installer
.
stubs
(
:ensure_plugins_are_installed!
)
@installer
.
stubs
(
:analyze
)
config
.
skip_repo_update
=
true
analyzer
=
Installer
::
Analyzer
.
new
(
config
.
sandbox
,
@installer
.
podfile
,
@installer
.
lockfile
)
analyzer
.
stubs
(
:analyze
)
@installer
.
stubs
(
:create_analyzer
).
returns
(
analyzer
)
@installer
.
install!
source
=
Pod
::
Source
.
new
(
test_source_name
)
names
=
analyzer
.
sources
.
map
(
&
:name
)
names
.
should
.
include
(
source
.
name
)
end
it
'integrates the user targets if the corresponding config is set'
do
it
'integrates the user targets if the corresponding config is set'
do
config
.
integrate_targets
=
true
config
.
integrate_targets
=
true
@installer
.
expects
(
:integrate_user_project
)
@installer
.
expects
(
:integrate_user_project
)
...
@@ -726,6 +771,14 @@ module Pod
...
@@ -726,6 +771,14 @@ module Pod
@installer
.
send
(
:run_plugins_post_install_hooks
)
@installer
.
send
(
:run_plugins_post_install_hooks
)
end
end
it
'runs plugins source provider hook'
do
context
=
stub
context
.
stubs
(
:sources
).
returns
([])
Installer
::
SourceProviderHooksContext
.
expects
(
:generate
).
returns
(
context
)
HooksManager
.
expects
(
:run
).
with
(
:source_provider
,
context
,
Installer
::
DEFAULT_PLUGINS
)
@installer
.
send
(
:run_source_provider_hooks
)
end
it
'only runs the podfile-specified hooks'
do
it
'only runs the podfile-specified hooks'
do
context
=
stub
context
=
stub
Installer
::
PostInstallHooksContext
.
expects
(
:generate
).
returns
(
context
)
Installer
::
PostInstallHooksContext
.
expects
(
:generate
).
returns
(
context
)
...
...
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