From 2ec9e53223650b97ac67937f527c7f2333eda423 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 20 Aug 2024 23:40:28 +1200 Subject: [PATCH] Tidy up code. --- lib/bake/registry.rb | 46 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/lib/bake/registry.rb b/lib/bake/registry.rb index 0de7536..c4c6a0f 100644 --- a/lib/bake/registry.rb +++ b/lib/bake/registry.rb @@ -49,22 +49,6 @@ def empty? @ordered.empty? end - def append_bakefile(path) - @ordered << Loader::FileLoader.new({ - [] => path - }) - end - - # Add registry according to the current working directory and loaded gems. - # @parameter working_directory [String] - 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 - # Enumerate the registry in order. def each(&block) @ordered.each(&block) @@ -83,6 +67,12 @@ def scopes_for(path) end end + def append_bakefile(path) + @ordered << Loader::FileLoader.new({ + [] => path + }) + end + # Append a specific project path to the search path for recipes. # The computed path will have `bake` appended to it. # @parameter current [String] The path to add. @@ -96,22 +86,14 @@ def append_path(current = Dir.pwd, **options) return false end - # Search from the current working directory until a suitable bakefile is found and add it. - # @parameter current [String] The path to start searching from. - def append_from_root(current = Dir.pwd, **options) - while current - Console.debug(self) {"Checking current #{current}..."} - - append_path(current, **options) - - parent = File.dirname(current) - - if current == parent - break - else - current = parent - end - end + # Add registry according to the current working directory and loaded gems. + # @parameter working_directory [String] + 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 # Enumerate all loaded gems and add them.