Method: Inspec::Plugin::V2::Installer#install

Defined in:
lib/inspec/plugin/v2/installer.rb

#install(plugin_name, opts = {}) ⇒ Object

Installs a plugin. Defaults to assuming the plugin provided is a gem, and will try to install from whatever gemsources rubygems thinks it should use. If it’s a gem, installs it and its dependencies to the gem_path. The gem is not activated. If it’s a path, leaves it in place. Finally, updates the plugins.json file with the new information. No attempt is made to load the plugin.

Parameters:

  • plugin_name (String)
  • opts (Hash) (defaults to: {})

    The installation options

Options Hash (opts):

  • :gem_file (String)

    Path to a local gem file to install from

  • :path (String)

    Path to a file to be used as the entry point for a path-based plugin

  • :version (String)

    Version constraint for remote gem installs



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/inspec/plugin/v2/installer.rb', line 59

def install(plugin_name, opts = {})
  # TODO: - check plugins.json for validity before trying anything that needs to modify it.
  validate_installation_opts(plugin_name, opts)

  # TODO: change all of these to return installed spec/gem/thingy
  # TODO: return installed thingy
  if opts[:path]
    install_from_path(plugin_name, opts)
  elsif opts[:gem_file]
    install_from_gem_file(plugin_name, opts)
  else
    install_from_remote_gems(plugin_name, opts)
  end

  update_plugin_config_file(plugin_name, opts.merge({ action: :install }))
end