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/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/chef/config.rb,
lib/berkshelf/mixin/config.rb,
lib/berkshelf/mixin/logging.rb,
lib/berkshelf/base_generator.rb,
lib/berkshelf/commands/shelf.rb,
lib/berkshelf/community_rest.rb,
lib/berkshelf/cookbook_store.rb,
lib/berkshelf/init_generator.rb,
lib/berkshelf/mixin/dsl_eval.rb,
lib/berkshelf/cached_cookbook.rb,
lib/berkshelf/cookbook_source.rb,
lib/berkshelf/formatters/json.rb,
lib/berkshelf/formatters/null.rb,
lib/berkshelf/cookbook_generator.rb,
lib/berkshelf/commands/test_command.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, Formatters, Location, Mixin, UI Classes: AbstractFunction, AmbiguousGitRef, ArgumentError, BaseGenerator, Berksfile, BerksfileNotFound, BerksfileReadError, BerkshelfError, CachedCookbook, ChefAPILocation, ChefConnectionError, Cli, ClientKeyFileNotFound, CommunityREST, CommunitySiteError, Config, ConfigExists, ConfigNotFound, ConfigurationError, ConstraintNotSatisfied, CookbookGenerator, CookbookNotFound, CookbookSource, CookbookStore, CookbookSyntaxError, CookbookValidationFailure, Downloader, DuplicateLocationDefined, DuplicateSourceDefined, EnvironmentNotFound, ExplicitCookbookNotFound, FrozenCookbook, Git, GitError, GitLocation, GitNotFound, GithubLocation, InitGenerator, InsufficientPrivledges, InternalError, InvalidChefAPILocation, InvalidConfiguration, InvalidCookbookFiles, InvalidGitRef, InvalidGitURI, InvalidSiteShortnameError, InvalidVersionConstraint, LicenseNotAllowed, LicenseNotFound, Lockfile, LockfileParserError, MismatchedCookbookName, Mocks, NoSolution, NoVersionForConstraints, OutdatedCookbookSource, PathLocation, Resolver, Shelf, SiteLocation, TestCommand, UnknownCompressionType, UnknownGitHubProtocol, UploadFailure, ValidationFailed

Constant Summary collapse

DEFAULT_FILENAME =
'Berksfile'.freeze
Logger =
Ridley.logger
VERSION =
"2.0.10"

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Mixin::Logging

log, log_exception

Class Attribute Details

.chef_configBerkshelf::Chef::Config

The Chef configuration file.



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

def chef_config
  @chef_config ||= Berkshelf::Chef::Config.load
end

.cookbook_storeBerkshelf::CookbookStore



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

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

.loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

.uiThor::Shell::Color, Thor::Shell::Basic

Returns A basic shell on Windows, colored everywhere else.

Returns:

  • (Thor::Shell::Color, Thor::Shell::Basic)

    A basic shell on Windows, colored everywhere else



41
42
43
# File 'lib/berkshelf.rb', line 41

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:



52
53
54
# File 'lib/berkshelf.rb', line 52

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

.cookbooks_dirObject



83
84
85
# File 'lib/berkshelf.rb', line 83

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

.formatter~Formatter

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

Returns:

  • (~Formatter)


96
97
98
# File 'lib/berkshelf.rb', line 96

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

.mktmpdirString

Creates a temporary directory within the Berkshelf path

Returns:

  • (String)

    path to the created temporary directory



78
79
80
81
# File 'lib/berkshelf.rb', line 78

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

.rootPathname

Returns:



35
36
37
# File 'lib/berkshelf.rb', line 35

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)


108
109
110
# File 'lib/berkshelf.rb', line 108

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

.tmp_dirString

Returns:



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

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