Class: Navo::Berksfile

Inherits:
Object
  • Object
show all
Defined in:
lib/navo/berksfile.rb

Overview

A global Berksfile to be shared amongst all threads.

This synchronizes access so we don’t have multiple threads doing the same work resolving cookbooks.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



11
12
13
# File 'lib/navo/berksfile.rb', line 11

def config
  @config
end

.pathObject

Returns the value of attribute path.



10
11
12
# File 'lib/navo/berksfile.rb', line 10

def path
  @path
end

Class Method Details

.cache_directoryObject



38
39
40
# File 'lib/navo/berksfile.rb', line 38

def cache_directory
  Berkshelf::CookbookStore.default_path
end

.install(logger: nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/navo/berksfile.rb', line 18

def install(logger: nil)
  if @installed
    logger.info 'Berksfile cookbooks already resolved'
    return
  end

  logger.info 'Installing Berksfile...'
  Berkshelf.logger = Celluloid.logger = logger
  Berkshelf.ui.mute { Berkshelf::Installer.new(berksfile).run }
  Celluloid.logger = nil # Ignore annoying shutdown messages

  @installed = true
end

.loadObject



13
14
15
16
# File 'lib/navo/berksfile.rb', line 13

def load
  require 'berkshelf' # Lazily require so we don't have to load for every command
  berksfile
end

.lockfile_pathObject



47
48
49
# File 'lib/navo/berksfile.rb', line 47

def lockfile_path
  berksfile.lockfile.filepath
end

.vendor(logger:) ⇒ Object



32
33
34
35
36
# File 'lib/navo/berksfile.rb', line 32

def vendor(logger:)
    Berkshelf.logger = Celluloid.logger = logger
    Berkshelf.ui.mute { berksfile.vendor(vendor_directory) }
    Celluloid.logger = nil # Ignore annoying shutdown messages
end

.vendor_directoryObject



42
43
44
45
# File 'lib/navo/berksfile.rb', line 42

def vendor_directory
  @vendor_directory ||=
    FileUtils.mkdir_p(File.join(config.repo_root, %w[.navo vendored-cookbooks])).first
end