Module: MotherBrain::Berkshelf

Defined in:
lib/mb/berkshelf.rb

Overview

This module contains integration code for Berkshelf into motherbrain

Defined Under Namespace

Classes: Lockfile

Class Method Summary collapse

Class Method Details

.cookbooks(options = {}) ⇒ Array<Pathname>

An array of Pathnames representing cookbooks in the Berkshelf

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :with_plugin (Boolean)

    only return cookbooks that contain a plugin

Returns:

  • (Array<Pathname>)


11
12
13
14
15
16
17
18
19
# File 'lib/mb/berkshelf.rb', line 11

def cookbooks(options = {})
  cookbooks = cookbooks_path.children

  if options[:with_plugin]
    cookbooks.select! { |cb_path| Dir.has_mb_plugin?(cb_path) }
  end

  cookbooks
end

.cookbooks_pathPathname

Location of the cookbooks directory in the Berkshelf

Returns:

  • (Pathname)


24
25
26
# File 'lib/mb/berkshelf.rb', line 24

def cookbooks_path
  path.join('cookbooks')
end

.default_pathString

The default location of the Berkshelf. This is in your user directory unless explicitly specified by the environment variable ‘BERKSHELF_PATH’

Returns:

  • (String)


32
33
34
# File 'lib/mb/berkshelf.rb', line 32

def default_path
  ENV["BERKSHELF_PATH"] || File.expand_path("~/.berkshelf")
end

.initObject

Create the directory structure for the Berkshelf



37
38
39
40
# File 'lib/mb/berkshelf.rb', line 37

def init
  FileUtils.mkdir_p(path)
  FileUtils.mkdir_p(cookbooks_path)
end

.pathPathname

The location of the Berkshelf

Returns:

  • (Pathname)


45
46
47
# File 'lib/mb/berkshelf.rb', line 45

def path
  Pathname.new(Application.config.berkshelf.path || default_path)
end