module Berksfiler
Berksfiler
programmatically generates Berksfiles with correct dependencies
Berksfiler
programmatically generates Berksfiles with correct dependencies
Constants
- CONFIG_DEFAULTS
- CONFIG_FILE
- EXCLUDED_DIRS_REGEX
- VERSION
Public Class Methods
common_cookbooks()
click to toggle source
# File lib/berksfiler.rb, line 28 def self::common_cookbooks config.common_cookbooks end
config()
click to toggle source
Get the loaded config (a Configurability::Config object)
# File lib/berksfiler.rb, line 37 def self::config Configurability.loaded_config end
cookbook_options()
click to toggle source
# File lib/berksfiler.rb, line 24 def self::cookbook_options config.cookbook_options end
cookbooks_root()
click to toggle source
# File lib/berksfiler.rb, line 20 def self::cookbooks_root Pathname(config.cookbooks_root).expand_path end
emplace_berksfile(cookbook)
click to toggle source
Generate a berksfile and place it in a cookbook
# File lib/berksfiler.rb, line 62 def self::emplace_berksfile(cookbook) puts "Generating Berksfile for local cookbook '#{cookbook}'" content = Generator.generate_berksfile(cookbook) open(File.join(cookbooks_root, cookbook, 'Berksfile'), 'w') do |f| f << content end end
excluded_cookbooks()
click to toggle source
# File lib/berksfiler.rb, line 32 def self::excluded_cookbooks config.excluded_cookbooks end
load_config(config_file = nil)
click to toggle source
Load the specified config_file
and install the config
# File lib/berksfiler.rb, line 42 def self::load_config(config_file = nil) config_file ||= CONFIG_FILE config = Configurability::Config.load(config_file, CONFIG_DEFAULTS) config.install end
local_cookbooks()
click to toggle source
returns an array of all local cookbooks (basically a directory listing of the cookbook_root)
# File lib/berksfiler.rb, line 50 def self::local_cookbooks @local_cookbooks ||= Dir.entries(cookbooks_root).reject do |dir| dir =~ EXCLUDED_DIRS_REGEX end end
run()
click to toggle source
for all local cookbooks, excluding ‘excluded_cookbooks`, calculate all dependencies and programmatically generate a Berksfile for that cookbook which takes into account the correct sources for all dependencies.
# File lib/berksfiler.rb, line 73 def self::run (local_cookbooks - excluded_cookbooks).each do |cb| emplace_berksfile(cb) end end
specific_cookbooks()
click to toggle source
returns an array of all cookbooks that have non-default options
# File lib/berksfiler.rb, line 57 def self::specific_cookbooks local_cookbooks + cookbook_options.map { |cb| cb['name'] } end