class Busser::Command::PluginInstall

Plugin install command.

@author Fletcher Nichol <fnichol@nichol.ca>

Public Instance Methods

install_all() click to toggle source
# File lib/busser/command/plugin_install.rb, line 43
def install_all
  if options[:verbose]
    Gem.configuration.verbose = 2 if options[:verbose]
    info("Using http_proxy=#{rbg_options[:http_proxy].inspect}")
  end

  silence_gem_ui do
    plugins.each { |plugin| install(plugin) }
  end
end

Private Instance Methods

drop_ssl_verify_peer() { || ... } click to toggle source

Drops SSL verify peer to VERIFY_NONE within a given block. While this is normally a massive anti-pattern and should be discouraged, there may be some Busser code that needs to be executed in an environment that lacks a proper SSL certificate store.

Please use with extreme caution.

# File lib/busser/command/plugin_install.rb, line 103
def drop_ssl_verify_peer
  before = OpenSSL::SSL::VERIFY_PEER
  OpenSSL::SSL.send(:remove_const, 'VERIFY_PEER')
  OpenSSL::SSL.const_set('VERIFY_PEER', OpenSSL::SSL::VERIFY_NONE)
  yield
  OpenSSL::SSL.send(:remove_const, 'VERIFY_PEER')
  OpenSSL::SSL.const_set('VERIFY_PEER', before)
end
install(plugin) click to toggle source
# File lib/busser/command/plugin_install.rb, line 56
def install(plugin)
  gem_name, version = plugin.split("@")
  name = gem_name.sub(/^busser-/, '')

  new_install = install_plugin_gem(gem_name, version, name)

  if options[:force_postinstall] || new_install
    load_plugin(name)
    run_postinstall(name)
  end
end
install_plugin_gem(gem, version, name) click to toggle source
# File lib/busser/command/plugin_install.rb, line 68
def install_plugin_gem(gem, version, name)
  if internal_plugin?(name) || gem_installed?(gem, version)
    info "Plugin #{name} already installed"
    return false
  else
    spec = install_gem(gem, version)
    info "Plugin #{name} installed (version #{spec.version})"
    return true
  end
end
internal_plugin?(name) click to toggle source
# File lib/busser/command/plugin_install.rb, line 91
def internal_plugin?(name)
  spec = Busser::Plugin.gem_from_path(Busser::Plugin.runner_plugin(name))
  spec && spec.name == "busser"
end
load_plugin(name) click to toggle source
# File lib/busser/command/plugin_install.rb, line 79
def load_plugin(name)
  Busser::Plugin.require!(Busser::Plugin.runner_plugin(name))
end
run_postinstall(name) click to toggle source
# File lib/busser/command/plugin_install.rb, line 83
def run_postinstall(name)
  klass = Busser::Plugin.runner_class(::Thor::Util.camel_case(name))
  if klass.respond_to?(:run_postinstall)
    banner "Running postinstall for #{name} plugin"
    drop_ssl_verify_peer { klass.run_postinstall }
  end
end