Class: Builderator::Tasks::Berkshelf

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/builderator/tasks/berkshelf.rb

Overview

Wrap Berkshelf commands

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Thor::Actions

#run, #run_with_input, #run_without_bundler, #template, #thor_run

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/builderator/tasks/berkshelf.rb', line 17

def self.exit_on_failure?
  true
end

Instance Method Details

#cleanObject



76
77
78
79
80
# 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

#configureObject



22
23
24
# File 'lib/builderator/tasks/berkshelf.rb', line 22

def configure
  Interface.berkshelf.write
end

#metadata(cookbook) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/builderator/tasks/berkshelf.rb', line 27

def (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
   = Chef::Cookbook::Metadata.new

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

  say_status :metadata, "for cookbook #{ .name }@#{ .version }"
  create_file ::File.join(cookbook_path, 'metadata.json'), .to_json, :force => true
end

#uncacheObject



71
72
73
# File 'lib/builderator/tasks/berkshelf.rb', line 71

def uncache
  remove_dir File.join(ENV['HOME'], '.berkshelf/cookbooks')
end

#uploadObject



57
58
59
60
61
62
63
64
65
66
67
68
# 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

#vendorObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 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