vagrant/plugins/commands/plugin/action/list_plugins.rb

74 lines
2.2 KiB
Ruby
Raw Normal View History

require "vagrant/plugin/manager"
2013-02-03 07:52:34 +00:00
module VagrantPlugins
module CommandPlugin
module Action
2013-02-03 07:59:48 +00:00
# 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.
2013-02-03 07:52:34 +00:00
class ListPlugins
def initialize(app, env)
@app = app
end
def call(env)
manager = Vagrant::Plugin::Manager.instance
plugins = manager.installed_plugins
specs = Hash[
manager.installed_specs.map do |spec|
[spec.name, spec]
end
]
# Output!
if specs.empty?
env[:ui].info(I18n.t("vagrant.commands.plugin.no_plugins"))
return @app.call(env)
end
plugins.each do |plugin_name, plugin|
spec = specs[plugin_name]
next if spec.nil?
system = ""
system = ", system" if plugin && plugin["system"]
env[:ui].info "#{spec.name} (#{spec.version}#{system})"
env[:ui].machine("plugin-name", spec.name)
env[:ui].machine(
"plugin-version",
"#{spec.version}#{system}",
target: spec.name)
if plugin["gem_version"] && plugin["gem_version"] != ""
env[:ui].info(I18n.t(
"vagrant.commands.plugin.plugin_version",
version: plugin["gem_version"]))
env[:ui].machine(
"plugin-version-constraint",
plugin["gem_version"],
target: spec.name)
end
if plugin["require"] && plugin["require"] != ""
env[:ui].info(I18n.t(
"vagrant.commands.plugin.plugin_require",
require: plugin["require"]))
env[:ui].machine(
"plugin-custom-entrypoint",
plugin["require"],
target: spec.name)
end
2013-02-03 07:52:34 +00:00
end
@app.call(env)
end
end
end
end
end