lib/geny/registry.rb in geny-2.1.1 vs lib/geny/registry.rb in geny-2.1.2

- old
+ new

@@ -2,18 +2,22 @@ require "geny/error" require "geny/command" module Geny class Registry - # The default load path. By default, Geny - # will search - LOAD_PATH = [ - File.join(Dir.pwd, ".geny"), - *ENV.fetch("CODE_HEN_PATH", "").split(":"), - File.expand_path("../generators", __dir__) - ] + # The load path for project-local generators + LOCAL_PATH = [File.join(Dir.pwd, ".geny")] + # The load path that is read from ENV vars + ENV_PATH = ENV.fetch("GENY_PATH", "").split(":") + + # The load path for Geny's own generators + GENY_PATH = [File.join(__dir__, "generators")] + + # The default load path. By default, Geny will search + LOAD_PATH = LOCAL_PATH + ENV_PATH + GENY_PATH + # The directories to search for commands in # @return [Array<String>] attr_reader :load_path # Create a new registry @@ -31,11 +35,11 @@ path = Pathname.new(path) path.glob(glob).map do |file| root = file.dirname name = root.relative_path_from(path) - name = name.to_s.tr(File::SEPARATOR, ":") + name = name.to_s.tr(File::SEPARATOR, Command::SEPARATOR) build(name, root.to_s) end end commands.sort_by(&:name) @@ -44,10 +48,11 @@ # Find a command by name # @param name [String] name of the command # @return [Command,nil] def find(name) load_path.each do |path| - file = File.join(path, *name.split(":"), Command::FILENAME) + parts = name.split(Command::SEPARATOR) + file = File.join(path, *parts, Command::FILENAME) root = File.dirname(file) return build(name, root) if File.exist?(file) end nil