class Builderator::Tasks::Berkshelf

Wrap Berkshelf commands

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/builderator/tasks/berkshelf.rb, line 17
def self.exit_on_failure?
  true
end

Public Instance Methods

clean() click to toggle source
# File lib/builderator/tasks/berkshelf.rb, line 76
def clean
  remove_dir Interface.berkshelf.vendor
  remove_file Interface.berkshelf.source
  remove_file Interface.berkshelf.lockfile
end
configure() click to toggle source
# File lib/builderator/tasks/berkshelf.rb, line 22
def configure
  Interface.berkshelf.write
end
metadata(cookbook) click to toggle source
# File lib/builderator/tasks/berkshelf.rb, line 27
def metadata(cookbook)
  fail "Cookbook #{ cookbook } does not have a path!" unless Config.cookbook.depends.has?(cookbook) &&
                                                             !Config.cookbook.depends[cookbook].path.nil?

  cookbook_path = Config.cookbook.depends[cookbook].path
  metadata_rb = Chef::Cookbook::Metadata.new

  metadata_rb.from_file(::File.join(cookbook_path, 'metadata.rb'))

  say_status :metadata, "for cookbook #{ metadata_rb.name }@#{ metadata_rb.version }"
  create_file ::File.join(cookbook_path, 'metadata.json'), metadata_rb.to_json, :force => true
end
uncache() click to toggle source
# File lib/builderator/tasks/berkshelf.rb, line 71
def uncache
  remove_dir File.join(ENV['HOME'], '.berkshelf/cookbooks')
end
upload() click to toggle source
# File lib/builderator/tasks/berkshelf.rb, line 57
def upload
  vendor

  command = "#{Interface.berkshelf.command} upload "
  command << "-d " if options[:debug]
  command << "-c #{Interface.berkshelf.berkshelf_config} " unless Interface.berkshelf.berkshelf_config.nil?
  command << "-b #{Interface.berkshelf.source}"

  inside Interface.berkshelf.directory do
    run command
  end
end
vendor() click to toggle source
# File lib/builderator/tasks/berkshelf.rb, line 41
def vendor
  invoke :configure, [], options
  empty_directory Interface.berkshelf.vendor

  command = "#{Interface.berkshelf.command} vendor #{Interface.berkshelf.vendor} "
  command << "-d " if options[:debug]
  command << "-c #{Interface.berkshelf.berkshelf_config} " unless Interface.berkshelf.berkshelf_config.nil?
  command << "-b #{Interface.berkshelf.source}"

  remove_file Interface.berkshelf.lockfile
  inside Interface.berkshelf.directory do
    run command
  end
end