Module: Berkshelf

Extended by:
Mixin::Logging
Defined in:
lib/berkshelf.rb,
lib/berkshelf/ui.rb,
lib/berkshelf/cli.rb,
lib/berkshelf/git.rb,
lib/berkshelf/chef.rb,
lib/berkshelf/test.rb,
lib/berkshelf/mixin.rb,
lib/berkshelf/config.rb,
lib/berkshelf/errors.rb,
lib/berkshelf/logger.rb,
lib/berkshelf/command.rb,
lib/berkshelf/version.rb,
lib/berkshelf/location.rb,
lib/berkshelf/lockfile.rb,
lib/berkshelf/resolver.rb,
lib/berkshelf/berksfile.rb,
lib/berkshelf/downloader.rb,
lib/berkshelf/formatters.rb,
lib/berkshelf/mixin/logging.rb,
lib/berkshelf/base_generator.rb,
lib/berkshelf/community_rest.rb,
lib/berkshelf/cookbook_store.rb,
lib/berkshelf/init_generator.rb,
lib/berkshelf/cached_cookbook.rb,
lib/berkshelf/cookbook_source.rb,
lib/berkshelf/formatters/json.rb,
lib/berkshelf/cookbook_generator.rb,
lib/berkshelf/locations/git_location.rb,
lib/berkshelf/locations/path_location.rb,
lib/berkshelf/locations/site_location.rb,
lib/berkshelf/formatters/human_readable.rb,
lib/berkshelf/locations/github_location.rb,
lib/berkshelf/locations/chef_api_location.rb

Defined Under Namespace

Modules: Chef, Command, Formatters, Location, Mixin, UI Classes: AbstractFunction, AmbiguousCookbookName, AmbiguousGitRef, ArgumentError, BaseGenerator, BerksConfigNotFound, Berksfile, BerksfileNotFound, BerksfileReadError, BerkshelfError, CachedCookbook, ChefAPILocation, Cli, ClientKeyFileNotFound, CommandUnsuccessful, CommunityREST, CommunitySiteError, Config, ConfigExists, ConfigurationError, ConstraintNotSatisfied, CookbookGenerator, CookbookNotFound, CookbookSource, CookbookStore, CookbookSyntaxError, CookbookValidationFailure, Downloader, DuplicateLocationDefined, DuplicateSourceDefined, ExplicitCookbookNotFound, FrozenCookbook, Git, GitError, GitLocation, GitNotFound, GithubLocation, InitGenerator, InsufficientPrivledges, InternalError, InvalidChefAPILocation, InvalidConfiguration, InvalidGitRef, InvalidGitURI, InvalidSiteShortnameError, InvalidVersionConstraint, Lockfile, Mocks, NoSolution, NoVersionForConstraints, PathLocation, PrivateGitRepo, Resolver, SiteLocation, UnknownGitHubProtocol, UploadFailure, ValidationFailed

Constant Summary collapse

DEFAULT_FILENAME =
'Berksfile'.freeze
Logger =
Celluloid::Logger
VERSION =
"1.4.3"

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Mixin::Logging

log, log_exception

Class Attribute Details

.cookbook_storeBerkshelf::CookbookStore



99
100
101
# File 'lib/berkshelf.rb', line 99

def cookbook_store
  @cookbook_store ||= CookbookStore.new(cookbooks_dir)
end

.ui::Thor::Shell::Color



60
61
62
# File 'lib/berkshelf.rb', line 60

def ui
  @ui
end

Class Method Details

.berkshelf_pathString

Returns the filepath to the location Berskhelf will use for storage; temp files will go here, Cookbooks will be downloaded to or uploaded from here. By default this is ‘~/.berkshelf’ but can be overridden by specifying a value for the ENV variable ‘BERKSHELF_PATH’.

Returns:



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

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

.cookbooks_dirObject



94
95
96
# File 'lib/berkshelf.rb', line 94

def cookbooks_dir
  File.join(berkshelf_path, "cookbooks")
end

.find_metadata(path = Dir.pwd) ⇒ Pathname

Ascend the directory structure from the given path to find a metadata.rb file of a Chef Cookbook. If no metadata.rb file was found, nil is returned.

Returns:



109
110
111
112
113
114
115
116
# File 'lib/berkshelf.rb', line 109

def (path = Dir.pwd)
  path = Pathname.new(path)
  path.ascend do |potential_root|
    if potential_root.entries.collect(&:to_s).include?('metadata.rb')
      return potential_root.join('metadata.rb')
    end
  end
end

.formatter~Formatter

Get the appropriate Formatter object based on the formatter classes that have been registered.

Returns:

  • (~Formatter)


122
123
124
# File 'lib/berkshelf.rb', line 122

def formatter
  @formatter ||= Formatters::HumanReadable.new
end

.loggerLogger

Returns:



76
77
78
# File 'lib/berkshelf.rb', line 76

def logger
  Celluloid.logger
end

.mktmpdirString

Creates a temporary directory within the Berkshelf path

Returns:

  • (String)

    path to the created temporary directory



89
90
91
92
# File 'lib/berkshelf.rb', line 89

def mktmpdir
  FileUtils.mkdir_p(tmp_dir)
  Dir.mktmpdir(nil, tmp_dir)
end

.rootPathname

Returns:



55
56
57
# File 'lib/berkshelf.rb', line 55

def root
  @root ||= Pathname.new(File.expand_path('../', File.dirname(__FILE__)))
end

.set_format(format_id) ⇒ ~Formatter

Specify the format for output

Examples:

Berkshelf.set_format :json

Parameters:

  • format_id (#to_sym)

    the ID of the registered formatter to use

Returns:

  • (~Formatter)


134
135
136
# File 'lib/berkshelf.rb', line 134

def set_format(format_id)
  @formatter = Formatters[format_id].new
end

.tmp_dirString

Returns:



81
82
83
# File 'lib/berkshelf.rb', line 81

def tmp_dir
  File.join(berkshelf_path, "tmp")
end