Class: Batali::Command::Display

Inherits:
Batali::Command show all
Defined in:
lib/batali/command/display.rb

Overview

Display manifest information

Constant Summary

Constants inherited from Batali::Command

DEFAULT_CONFIGURATION_FILES

Instance Method Summary collapse

Methods inherited from Batali::Command

#batali_file, #cache_directory, #dry_run, #infrastructure?, #initialize, #manifest

Constructor Details

This class inherits a constructor from Batali::Command

Instance Method Details

#display(ckbk_names) ⇒ NilClass

Display manifest information

Parameters:

  • names (Array<String>)

    limit to given cookbooks

Returns:

  • (NilClass)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/batali/command/display.rb', line 19

def display(ckbk_names)
  info = Smash.new.tap do |ckbks|
    manifest.cookbook.sort_by(&:name).each do |ckbk|
      ckbks[ckbk.name] ||= []
      ckbks[ckbk.name].push(ckbk)
    end
  end
  info.each do |name, ckbks|
    next unless ckbk_names.empty? || ckbk_names.include?(name)
    ui.puts "  #{ui.color(name, :bold)}:"
    ckbks.each do |ckbk|
      ui.puts "    Version: #{ckbk.version}"
      case ckbk.source
      when Batali::Source::Site
        ui.puts "    Source: #{URI.parse(ckbk.source.url).host}"
      when Batali::Source::Git
        ui.puts "    Source: #{ckbk.source.url}"
        ui.puts "    Reference: #{ckbk.source.ref}"
      when Batali::Source::Path
        ui.puts "    Source: #{ckbk.source.path}"
      end
    end
  end
end

#execute!Object

Display information from manifest



10
11
12
13
# File 'lib/batali/command/display.rb', line 10

def execute!
  ui.puts ui.color('Batali manifest information:', :bold) + "\n"
  display(arguments)
end