Class: KnifeSolo::Berkshelf

Inherits:
Object
  • Object
show all
Includes:
CookbookManager
Defined in:
lib/knife-solo/berkshelf.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CookbookManager

included

Class Method Details

.conf_file_nameObject



14
15
16
# File 'lib/knife-solo/berkshelf.rb', line 14

def self.conf_file_name
  'Berksfile'
end

.gem_librariesObject



10
11
12
# File 'lib/knife-solo/berkshelf.rb', line 10

def self.gem_libraries
  %w[berkshelf]
end

Instance Method Details

#berkshelf_pathObject



38
39
40
# File 'lib/knife-solo/berkshelf.rb', line 38

def berkshelf_path
  KnifeSolo::Tools.config_value(config, :berkshelf_path) || default_path
end

#default_pathObject



42
43
44
45
# File 'lib/knife-solo/berkshelf.rb', line 42

def default_path
  File.join(::Berkshelf.berkshelf_path, 'knife-solo',
    Digest::SHA1.hexdigest(File.expand_path('.')))
end

#initial_configObject



47
48
49
50
51
52
53
# File 'lib/knife-solo/berkshelf.rb', line 47

def initial_config
  if defined?(::Berkshelf) && Gem::Version.new(::Berkshelf::VERSION) >= Gem::Version.new("3.0.0")
    'source "https://api.berkshelf.com"'
  else
    'site :opscode'
  end
end

#install!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/knife-solo/berkshelf.rb', line 18

def install!
  path = berkshelf_path
  ui.msg "Installing Berkshelf cookbooks to '#{path}'..."

  if Gem::Version.new(::Berkshelf::VERSION) >= Gem::Version.new("3.0.0")
    berkshelf_options = KnifeSolo::Tools.config_value(config, :berkshelf_options) || {}
    berksfile = ::Berkshelf::Berksfile.from_file('Berksfile',berkshelf_options)
  else
    berksfile = ::Berkshelf::Berksfile.from_file('Berksfile')
  end
  if berksfile.respond_to?(:vendor)
    FileUtils.rm_rf(path)
    berksfile.vendor(path)
  else
    berksfile.install(:path => path)
  end

  path
end