Sha256: ed6d93f80f28d7c349ba1e13cdf463e444f4aae6c287b64364ac05c90aac0721

Contents?: true

Size: 1.69 KB

Versions: 19

Compression:

Stored size: 1.69 KB

Contents

require "rubygems"
require "set"

module VagrantPlugins
  module CommandPlugin
    module Action
      # This middleware lists all the installed plugins.
      #
      # This is a bit more complicated than simply listing installed
      # gems or what is in the state file as installed. Instead, this
      # actually compares installed gems with what the state file claims
      # is installed, and outputs the appropriate truly installed
      # plugins.
      class ListPlugins
        def initialize(app, env)
          @app = app
        end

        def call(env)
          # Get the list of installed plugins according to the state file
          installed = Set.new(env[:plugin_state_file].installed_plugins)

          # Go through the plugins installed in this environment and
          # get the latest version of each.
          installed_map = {}
          env[:gem_helper].with_environment do
            Gem::Specification.find_all.each do |spec|
              # Ignore specs that aren't in our installed list
              next if !installed.include?(spec.name)

              # If we already have a newer version in our list of installed,
              # then ignore it
              next if installed_map.has_key?(spec.name) &&
                installed_map[spec.name].version >= spec.version

              installed_map[spec.name] = spec
            end
          end

          # Output!
          if installed_map.empty?
            env[:ui].info(I18n.t("vagrant.commands.plugin.no_plugins"))
          else
            installed_map.values.each do |spec|
              env[:ui].info "#{spec.name} (#{spec.version})"
            end
          end

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

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/plugins/commands/plugin/action/list_plugins.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/plugins/commands/plugin/action/list_plugins.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/plugins/commands/plugin/action/list_plugins.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/plugins/commands/plugin/action/list_plugins.rb
tnargav-1.3.6 plugins/commands/plugin/action/list_plugins.rb
tnargav-1.3.3 plugins/commands/plugin/action/list_plugins.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/commands/plugin/action/list_plugins.rb
tnargav-1.2.3 plugins/commands/plugin/action/list_plugins.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/commands/plugin/action/list_plugins.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/plugins/commands/plugin/action/list_plugins.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/plugins/commands/plugin/action/list_plugins.rb
tnargav-1.2.2 plugins/commands/plugin/action/list_plugins.rb
vagrantup-1.1.3 plugins/commands/plugin/action/list_plugins.rb
vagrantup-1.1.2 plugins/commands/plugin/action/list_plugins.rb
vagrantup-1.1.1 plugins/commands/plugin/action/list_plugins.rb
vagrantup-1.1.0 plugins/commands/plugin/action/list_plugins.rb
vagrantup-1.1.4 plugins/commands/plugin/action/list_plugins.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/plugins/commands/plugin/action/list_plugins.rb
vagrant-lxc-0.0.1 vendor/vagrant/plugins/commands/plugin/action/list_plugins.rb