Class: Ladder::Upload

Inherits:
Command
  • Object
show all
Defined in:
lib/chef/ladder.rb

Instance Method Summary collapse

Methods inherited from Command

#selected_cookbooks

Instance Method Details

#executeObject



57
58
59
60
61
62
63
64
65
# File 'lib/chef/ladder.rb', line 57

def execute
  super
  puts "Uploading cookbooks:"
  for cookbook in selected_cookbooks
    chef_cookbook = load_cookbook(cookbook)
    puts " + #{chef_cookbook.metadata.name} version #{chef_cookbook.version}"
    upload_cookbook(chef_cookbook)
  end
end

#load_cookbook(cookbook) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/chef/ladder.rb', line 67

def load_cookbook(cookbook)
  @loader ||= Chef::CookbookLoader.new(global_options[:directory])
  chef_cookbook = @loader.load_cookbook(cookbook.name)
  if chef_cookbook.nil?
    raise "Could not load cookbook '#{cookbook.name}'"
  else
    return chef_cookbook
  end
end

#upload_cookbook(cookbooks) ⇒ Object



77
78
79
# File 'lib/chef/ladder.rb', line 77

def upload_cookbook(cookbooks)
  Chef::CookbookUploader.new(cookbooks, global_options[:directory]).upload_cookbooks
end