Skip to content

Commit

Permalink
Try to distinguish a path from an identifier which can also be these …
Browse files Browse the repository at this point in the history
…symbol names
  • Loading branch information
kaspth committed Jan 9, 2025
1 parent b461834 commit c2cb239
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/oaken.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ module Stored
singleton_class.attr_reader :lookup_paths
@lookup_paths = ["db/seeds"]

def self.glob(path)
patterns = lookup_paths.map { File.join(_1, "#{path}{,/**/*}.rb") }
def self.glob(identifier)
patterns = lookup_paths.map { File.join(_1, "#{identifier}{,/**/*}.rb") }

Pathname.glob(patterns).tap do |found|
raise NoSeedsFoundError, "found no seed files for #{path.inspect}" if found.none?
raise NoSeedsFoundError, "found no seed files for #{identifier.inspect}" if found.none?
end
end
NoSeedsFoundError = Class.new ArgumentError

class Loader
def self.from(paths)
new paths.flat_map { Oaken.glob _1 }
def self.from(identifiers)
new identifiers.flat_map { Oaken.glob _1 }
end

def initialize(entries)
Expand Down
4 changes: 2 additions & 2 deletions lib/oaken/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class << self
# class PaginationTest < ActionDispatch::IntegrationTest
# setup { seed "cases/pagination" }
# end
def seed(*paths)
Oaken::Loader.from(paths).load_onto self
def seed(*identifiers)
Oaken::Loader.from(identifiers).load_onto self
end

# `section` is purely for decorative purposes to carve up `Oaken.prepare` and seed files.
Expand Down

0 comments on commit c2cb239

Please sign in to comment.