Class: Pantry::Chef::ListCookbooks

Inherits:
Pantry::Command
  • Object
show all
Defined in:
lib/pantry/chef/list_cookbooks.rb

Overview

List all cookbooks known by the Server. This message includes the size and checksum of the cookbooks’s tarball as it’s used when sending cookbooks down to a Client.

Instance Method Summary collapse

Instance Method Details

#perform(message) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/pantry/chef/list_cookbooks.rb', line 14

def perform(message)
  Dir[Pantry.root.join("chef", "cookbook-cache", "*")].map do |cookbook_path|
    [
      File.basename(cookbook_path, ".tgz"),
      File.size(cookbook_path),
      Pantry.file_checksum(cookbook_path)
    ]
  end
end

#receive_server_response(message) ⇒ Object



24
25
26
# File 'lib/pantry/chef/list_cookbooks.rb', line 24

def receive_server_response(message)
  Pantry.ui.list(message.body.map(&:first).sort)
end