Class: VagrantPlugins::Vundler::PluginCommand::List

Inherits:
CommandPlugin::Command::List
  • Object
show all
Includes:
Logging
Defined in:
lib/vundler/plugin_command/list.rb

Overview

Override the built in ‘plugin list` command to output project specific plugins information

Instance Method Summary collapse

Methods included from Logging

#vundler_debug

Instance Method Details

#display(plugin, version = nil) ⇒ Object



38
39
40
41
42
# File 'lib/vundler/plugin_command/list.rb', line 38

def display(plugin, version = nil)
  label = "  -> #{plugin}"
  label << " #{version}" if version
  @env.ui.info label
end

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vundler/plugin_command/list.rb', line 11

def execute
  return unless super == 0

  plugins_json = @env.cwd.join('plugins.json')

  if plugins_json.file?
    data = JSON.parse(plugins_json.read)
    vundler_debug "plugins.json data: #{data.inspect}"

    if data.any?
      @env.ui.info "\nProject dependencies:"
      data.each do |plugin|
        if plugin.is_a?(String)
          display plugin
        else
          display *plugin.first
        end
      end
    end
  else
    @env.ui.info "\nNo project specific plugins.json file found!"
  end

  # Success, exit status 0
  0
end