class Bake::Registry::Aggregate
def self.default(working_directory, bakefile_path = nil)
Create a loader using the specified working directory.
def self.default(working_directory, bakefile_path = nil) registry = self.new if bakefile_path registry.append_bakefile(bakefile_path) end registry.append_defaults(working_directory) return registry end
def append_bakefile(path)
def append_bakefile(path) @ordered << BakefileLoader.new(path) end
def append_defaults(working_directory)
Add registry according to the current working directory and loaded gems.
def append_defaults(working_directory) # Load recipes from working directory: self.append_path(working_directory) # Load recipes from loaded gems: self.append_from_gems end
def append_from_gems
def append_from_gems ::Gem.loaded_specs.each do |name, spec| Console.debug(self) {"Checking gem #{name}: #{spec.full_gem_path}..."} if path = spec.full_gem_path and File.directory?(path) append_path(path, name: spec.full_name) end end end
def append_path(current = Dir.pwd, **options)
The computed path will have `bake` appended to it.
Append a specific project path to the search path for recipes.
def append_path(current = Dir.pwd, **options) bake_path = File.join(current, "bake") if File.directory?(bake_path) return insert(bake_path, **options) end return false end
def each(&block)
def each(&block) @ordered.each(&block) end
def empty?
Whether any registry are defined.
def empty? @ordered.empty? end
def initialize
def initialize # Used to de-duplicated directories: @roots = {} # The ordered list of loaders: @ordered = Array.new end
def insert(directory, **options)
def insert(directory, **options) unless @roots.key?(directory) Console.debug(self) {"Adding #{directory.inspect}"} loader = DirectoryLoader.new(directory, **options) @roots[directory] = loader @ordered << loader return true end return false end
def scopes_for(path, &block)
def scopes_for(path, &block) @ordered.each do |registry| registry.scopes_for(path, &block) end end