Module: Berkshelf
- Defined in:
- lib/berkshelf.rb,
lib/berkshelf/ui.rb,
lib/berkshelf/cli.rb,
lib/berkshelf/git.rb,
lib/berkshelf/config.rb,
lib/berkshelf/errors.rb,
lib/berkshelf/vagrant.rb,
lib/berkshelf/version.rb,
lib/berkshelf/location.rb,
lib/berkshelf/lockfile.rb,
lib/berkshelf/resolver.rb,
lib/berkshelf/uploader.rb,
lib/berkshelf/berksfile.rb,
lib/berkshelf/downloader.rb,
lib/berkshelf/formatters.rb,
lib/berkshelf/base_generator.rb,
lib/berkshelf/cookbook_store.rb,
lib/berkshelf/init_generator.rb,
lib/berkshelf/vagrant/config.rb,
lib/berkshelf/cached_cookbook.rb,
lib/berkshelf/cookbook_source.rb,
lib/berkshelf/formatters/json.rb,
lib/berkshelf/cookbook_generator.rb,
lib/berkshelf/vagrant/middleware.rb,
lib/berkshelf/vagrant/action/clean.rb,
lib/berkshelf/vagrant/action/set_ui.rb,
lib/berkshelf/vagrant/action/upload.rb,
lib/berkshelf/locations/git_location.rb,
lib/berkshelf/vagrant/action/install.rb,
lib/berkshelf/locations/path_location.rb,
lib/berkshelf/locations/site_location.rb,
lib/berkshelf/vagrant/action/validate.rb,
lib/berkshelf/formatters/human_readable.rb,
lib/berkshelf/locations/github_location.rb,
lib/berkshelf/locations/chef_api_location.rb
Defined Under Namespace
Modules: Formatters, Location, Vagrant Classes: AbstractFunction, AmbiguousCookbookName, ArgumentError, BaseGenerator, BerksConfigNotFound, Berksfile, BerksfileNotFound, BerksfileReadError, BerkshelfError, CachedCookbook, ChefAPILocation, Cli, CommandUnsuccessful, Config, ConfigExists, ConfigurationError, ConstraintNotSatisfied, CookbookGenerator, CookbookNotFound, CookbookSource, CookbookStore, CookbookSyntaxError, Downloader, DuplicateLocationDefined, DuplicateSourceDefined, Git, GitError, GitLocation, GitNotFound, GithubLocation, InitGenerator, InternalError, InvalidChefAPILocation, InvalidConfiguration, InvalidGitURI, Lockfile, NoSolution, NoVersionForConstraints, PathLocation, PrivateGitRepo, Resolver, SiteLocation, UI, UnknownGitHubProtocol, UploadFailure, Uploader, VagrantWrapperError
Constant Summary collapse
- DEFAULT_STORE_PATH =
File.("~/.berkshelf").freeze
- DEFAULT_FILENAME =
'Berksfile'.freeze
- VERSION =
"1.1.1"
Class Attribute Summary collapse
Class Method Summary collapse
-
.berkshelf_path ⇒ String
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.
- .cookbooks_dir ⇒ Object
-
.find_metadata(path = Dir.pwd) ⇒ Pathname
Ascend the directory structure from the given path to find a metadata.rb file of a Chef Cookbook.
-
.formatter ⇒ ~Formatter
Get the appropriate Formatter object based on the formatter classes that have been registered.
-
.mktmpdir ⇒ String
Creates a temporary directory within the Berkshelf path.
- .root ⇒ Pathname
-
.set_format(format_id) ⇒ ~Formatter
Specify the format for output.
- .tmp_dir ⇒ String
Class Attribute Details
.cookbook_store ⇒ Berkshelf::CookbookStore
95 96 97 |
# File 'lib/berkshelf.rb', line 95 def cookbook_store @cookbook_store ||= CookbookStore.new(cookbooks_dir) end |
Class Method Details
.berkshelf_path ⇒ String
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’.
72 73 74 |
# File 'lib/berkshelf.rb', line 72 def berkshelf_path ENV["BERKSHELF_PATH"] || DEFAULT_STORE_PATH end |
.cookbooks_dir ⇒ Object
90 91 92 |
# File 'lib/berkshelf.rb', line 90 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.
105 106 107 108 109 110 111 112 |
# File 'lib/berkshelf.rb', line 105 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.
118 119 120 |
# File 'lib/berkshelf.rb', line 118 def formatter @formatter ||= Formatters::HumanReadable.new end |
.mktmpdir ⇒ String
Creates a temporary directory within the Berkshelf path
85 86 87 88 |
# File 'lib/berkshelf.rb', line 85 def mktmpdir FileUtils.mkdir_p(tmp_dir) Dir.mktmpdir(nil, tmp_dir) end |
.root ⇒ Pathname
56 57 58 |
# File 'lib/berkshelf.rb', line 56 def root @root ||= Pathname.new(File.('../', File.dirname(__FILE__))) end |
.set_format(format_id) ⇒ ~Formatter
Specify the format for output
130 131 132 |
# File 'lib/berkshelf.rb', line 130 def set_format(format_id) @formatter = Formatters[format_id].new end |