class Capistrano::Configuration::PluginInstaller

Public Instance Methods

install(plugin, load_hooks: true, load_immediately: false) click to toggle source

“Installs” a Plugin into Capistrano by loading its tasks, hooks, and defaults at the appropriate time. The hooks in particular can be skipped, if you want full control over when and how the plugin’s tasks are executed. Simply pass ‘load_hooks:false` to opt out.

The plugin class or instance may be provided. These are equivalent:

install(Capistrano::SCM::Git) install(Capistrano::SCM::Git.new)

Note that the :load_immediately flag is for internal use only and will be removed in an upcoming release.

# File lib/capistrano/configuration/plugin_installer.rb, line 24
def install(plugin, load_hooks: true, load_immediately: false)
  plugin = plugin.is_a?(Class) ? plugin.new : plugin

  plugin.define_tasks
  plugin.register_hooks if load_hooks
  @scm_installed ||= provides_scm?(plugin)

  if load_immediately
    plugin.set_defaults
  else
    Rake::Task.define_task("load:defaults") do
      plugin.set_defaults
    end
  end
end
scm_installed?() click to toggle source
# File lib/capistrano/configuration/plugin_installer.rb, line 40
def scm_installed?
  @scm_installed
end

Private Instance Methods

provides_scm?(plugin) click to toggle source
# File lib/capistrano/configuration/plugin_installer.rb, line 46
def provides_scm?(plugin)
  plugin.respond_to?(:scm?) && plugin.scm?
end