lib/geny/registry.rb in geny-0.1.0 vs lib/geny/registry.rb in geny-1.0.0
- old
+ new
@@ -32,11 +32,11 @@
path.glob(glob).map do |file|
root = file.dirname
name = root.relative_path_from(path)
name = name.to_s.tr(File::SEPARATOR, ":")
- Command.new(name: name, root: root.to_s)
+ build(name, root.to_s)
end
end
commands.sort_by(&:name)
end
@@ -46,11 +46,11 @@
# @return [Command,nil]
def find(name)
load_path.each do |path|
file = File.join(path, *name.split(":"), Command::FILENAME)
root = File.dirname(file)
- return Command.new(name: name, root: root) if File.exist?(file)
+ return build(name, root) if File.exist?(file)
end
nil
end
@@ -61,9 +61,13 @@
def find!(name)
find(name) || command_not_found!(name)
end
private
+
+ def build(name, root)
+ Command.new(name: name, root: root, registry: self)
+ end
def command_not_found!(name)
raise NotFoundError, "There doesn't appear to be a generator named '#{name}'"
end
end