Sha256: 80e792e6d1e133ad75754b0541445198eb0a08e89e4cdba916951bb254b58476

Contents?: true

Size: 1.43 KB

Versions: 15

Compression:

Stored size: 1.43 KB

Contents

require "vagrant/plugin/manager"

module VagrantPlugins
  module CommandPlugin
    module Action
      class UpdateGems
        def initialize(app, env)
          @app    = app
        end

        def call(env)
          names = env[:plugin_name] || []

          if names.empty?
            env[:ui].info(I18n.t("vagrant.commands.plugin.updating"))
          else
            env[:ui].info(I18n.t("vagrant.commands.plugin.updating_specific",
                                 names: names.join(", ")))
          end

          manager = Vagrant::Plugin::Manager.instance
          installed_specs = manager.installed_specs
          new_specs       = manager.update_plugins(names)

          updated = {}
          installed_specs.each do |ispec|
            new_specs.each do |uspec|
              next if uspec.name != ispec.name
              next if ispec.version >= uspec.version
              next if updated[uspec.name] && updated[uspec.name].version >= uspec.version

              updated[uspec.name] = uspec
            end
          end

          if updated.empty?
            env[:ui].success(I18n.t("vagrant.commands.plugin.up_to_date"))
          end

          updated.values.each do |spec|
            env[:ui].success(I18n.t("vagrant.commands.plugin.updated",
                                    name: spec.name, version: spec.version.to_s))
          end

          # Continue
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

15 entries across 12 versions & 4 rubygems

Version Path
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/plugin/action/update_gems.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/plugin/action/update_gems.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/plugin/action/update_gems.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/plugin/action/update_gems.rb
vagrant-unbundled-1.8.5.2 plugins/commands/plugin/action/update_gems.rb
vagrant-unbundled-1.8.5.1 plugins/commands/plugin/action/update_gems.rb
vagrant-unbundled-1.8.4.2 plugins/commands/plugin/action/update_gems.rb
vagrant-unbundled-1.8.4.1 plugins/commands/plugin/action/update_gems.rb
vagrant-unbundled-1.8.1.2 plugins/commands/plugin/action/update_gems.rb
vagrant-unbundled-1.8.1.1 plugins/commands/plugin/action/update_gems.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/plugins/commands/plugin/action/update_gems.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/plugins/commands/plugin/action/update_gems.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-309e896975d1/plugins/commands/plugin/action/update_gems.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-272fb27e0536/plugins/commands/plugin/action/update_gems.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/bundler/gems/vagrant-1e28f1ac31e7/plugins/commands/plugin/action/update_gems.rb