module Berkshelf::Envs::Helpers
Public Instance Methods
company_cookbook(*args)
click to toggle source
Call berkshelf cookbook method using custom company repository. For *args see berkshelf cookbook method
# File lib/berkshelf/envs/helpers.rb, line 21 def company_cookbook(*args) options = args.last.is_a?(Hash) ? args.pop : Hash.new name, constraint = args id, repo = company_repo.to_a.first locations = Berkshelf.constants.map {|c| c.to_s}.select {|c| c.end_with?("Location") } # unless the location is explicitly specified use custom company repository if options.keys.none? {|k| lid = k.to_s.capitalize; locations.include?("#{lid}Location") } cookbook_name = options.delete(:cookbook_name) || name location_hash = {id => eval(%Q("#{repo}"))} else location_hash = {} end cookbook(name, constraint, options.merge(location_hash)) end
company_repo(repo_hash=nil)
click to toggle source
Set the default company repository
# File lib/berkshelf/envs/helpers.rb, line 8 def company_repo(repo_hash=nil) if repo_hash.nil? @company_repo ||= {} else if repo_hash.keys.count > 1 raise Berkshelf::ArgumentError, "company_repo expects hash with only one key value" end @company_repo = repo_hash end end
include_berks(filepath)
click to toggle source
Eval another berksfile in the current context
# File lib/berkshelf/envs/helpers.rb, line 38 def include_berks(filepath) raise BerksfileNotFound.new(filepath) unless File.exist?(filepath) filepath = filepath.to_s contents = File.read(filepath) eval(contents, binding, filepath, 1) end