lib/fabricators.rb in fabricators-0.0.4 vs lib/fabricators.rb in fabricators-0.1.0

- old
+ new

@@ -1,43 +1,57 @@ require 'fabricators/callbacks' require 'fabricators/definitions' +require 'fabricators/configuration' require 'fabricators/fabricator' -require 'fabricators/attribute' -require 'fabricators/reader' +require 'fabricators/sequence' +require 'fabricators/fetcher' require 'fabricators/proxy' require 'fabricators/methods' require 'fabricators/railtie' module Fabricators extend Methods class << self - def define(&block) - definitions.instance_eval &block + def reset + configuration.reset + definitions.reset end - def clean - records.pop.destroy until records.empty? + def configure(&block) + configuration.instance_eval &block end - def records - @records ||= [] + def configuration + @configuration ||= Configuration.new end + def define(&block) + definitions.instance_eval &block + end + def definitions @definitions ||= Definitions.new end - def path - @path ||= %w(test spec).map{ |dir| Rails.root.join(dir) }.find{ |path| Dir.exist?(path) }.try(:join, 'fabricators') + def clean + records.pop.destroy until records.empty? end - def load_files + def records + @records ||= [] + end + + def load if path Dir[path.join('**', '*.rb')].each do |file| - Fabricators.definitions.instance_eval File.read(file) + definitions.instance_eval File.read(file) end end + end + + def path + @path ||= %w(test spec).map{ |dir| Rails.root.join(dir) }.find{ |path| Dir.exist?(path) }.try(:join, 'fabricators') end end end