class Berkshelf::CommunityREST

def download(name, version)

Returns:
  • (String, nil) -

Parameters:
  • version (String) --
  • name (String) --
def download(name, version)
  archive = stream(find(name, version)["file"])
  scratch = Dir.mktmpdir
  extracted = self.class.unpack(archive.path, scratch)
  if File.cookbook?(extracted)
    extracted
  else
    Dir.glob("#{extracted}/*").find do |dir|
      File.cookbook?(dir)
    end
  end
ensure
  archive.unlink unless archive.nil?
end