lib/vagrant/plugin/manager.rb
def install_plugin(name, **opts)
        local = false
        if name =~ /\.gem$/
          # If this is a gem file, then we install that gem locally.
          local_spec = Vagrant::Bundler.instance.install_local(name, opts)
          name       = local_spec.name
          opts[:version] = local_spec.version.to_s
        end

        plugins = installed_plugins
        plugins[name] = {
          "require"     => opts[:require],
          "gem_version" => opts[:version],
          "sources"     => opts[:sources],
        }

        if local_spec.nil?
          result = nil
          install_lambda = lambda do
            Vagrant::Bundler.instance.install(plugins, local).each do |spec|
              next if spec.name != name
              next if result && result.version >= spec.version
              result = spec
            end
          end

          if opts[:verbose]
            Vagrant::Bundler.instance.verbose(&install_lambda)
          else
            install_lambda.call
          end
        else
          result = local_spec
        end
        # Add the plugin to the state file
        @user_file.add_plugin(
          result.name,
          version: opts[:version],
          require: opts[:require],
          sources: opts[:sources],
          installed_gem_version: result.version.to_s
        )

        # After install clean plugin gems to remove any cruft. This is useful
        # for removing outdated dependencies or other versions of an installed
        # plugin if the plugin is upgraded/downgraded
        Vagrant::Bundler.instance.clean(installed_plugins)
        result
      rescue Gem::GemNotFoundException
        raise Errors::PluginGemNotFound, name: name
      rescue Gem::Exception => e
        raise Errors::BundlerError, message: e.to_s
      end
# Installs another plugin into our gem directory.
#
# @param [String] name Name of the plugin (gem)
# @return [Gem::Specification]
Installs another plugin into our gem directory.
Installs another plugin into our gem directory .
def install_plugin(name, **opts)
        local = false
        if name =~ /\.gem$/
          local_spec = Vagrant::Bundler.instance.install_local(name, opts)
          name       = local_spec.name
          opts[:version] = local_spec.version.to_s
        end
        plugins = installed_plugins
        plugins[name] = {
          "require"     => opts[:require],
          "gem_version" => opts[:version],
          "sources"     => opts[:sources],
        }
        if local_spec.nil?
          result = nil
          install_lambda = lambda do
            Vagrant::Bundler.instance.install(plugins, local).each do |spec|
              next if spec.name != name
              next if result && result.version >= spec.version
              result = spec
            end
          end
          if opts[:verbose]
            Vagrant::Bundler.instance.verbose(&install_lambda)
          else
            install_lambda.call
          end
        else
          result = local_spec
        end
        @user_file.add_plugin(
          result.name,
          version: opts[:version],
          require: opts[:require],
          sources: opts[:sources],
          installed_gem_version: result.version.to_s
        )
        Vagrant::Bundler.instance.clean(installed_plugins)
        result
      rescue Gem::GemNotFoundException
        raise Errors::PluginGemNotFound, name: name
      rescue Gem::Exception => e
        raise Errors::BundlerError, message: e.to_s
      end
def install_plugin ( name , ** opts ) local = false if name =~ / \. gem$ / local_spec = Vagrant :: Bundler . instance . install_local ( name , opts ) name = local_spec . name opts [ :version ] = local_spec . version . to_s end plugins = installed_plugins plugins [ name ] = { "require" => opts [ :require ] , "gem_version" => opts [ :version ] , "sources" => opts [ :sources ] , } if local_spec . nil? result = nil install_lambda = lambda do Vagrant :: Bundler . instance . install ( plugins , local ) . each do | spec | next if spec . name != name next if result && result . version >= spec . version result = spec end end if opts [ :verbose ] Vagrant :: Bundler . instance . verbose ( & install_lambda ) else install_lambda . call end else result = local_spec end @user_file . add_plugin ( result . name , version : opts [ :version ] , require : opts [ :require ] , sources : opts [ :sources ] , installed_gem_version : result . version . to_s ) Vagrant :: Bundler . instance . clean ( installed_plugins ) result rescue Gem :: GemNotFoundException raise Errors :: PluginGemNotFound , name : name rescue Gem :: Exception => e raise Errors :: BundlerError , message : e . to_s end
Installs another plugin into our gem directory.
Installs another plugin into our gem directory .
# If this is a gem file, then we install that gem locally. # Add the plugin to the state file # After install clean plugin gems to remove any cruft. This is useful # for removing outdated dependencies or other versions of an installed # plugin if the plugin is upgraded/downgraded
None
Gem::Specification
name
opts
name Name of the plugin (gem)
name Name of the plugin ( gem )