Permalink
Browse files

make path_prefix configurable

  • Loading branch information...
1 parent 52a7126 commit b279db8dc061e6fb4c9abed2f7f9b0f53a447c81 @michaelrigart michaelrigart committed Jul 16, 2012
Showing with 11 additions and 3 deletions.
  1. +10 −1 lib/fabrication/config.rb
  2. +1 −2 lib/fabrication/support.rb
View
@@ -16,6 +16,14 @@ def fabricator_path=(folders)
end
alias fabricator_dir= fabricator_path=
+ def path_prefix
+ OPTIONS[:path_prefix]
+ end
+
+ def path_prefix=(prefix)
+ OPTIONS[:path_prefix] = prefix
+ end
+
def reset_defaults
OPTIONS.replace(DEFAULTS)
end
@@ -36,7 +44,8 @@ def register_with_steps=(register)
DEFAULTS = {
fabricator_path: ['test/fabricators', 'spec/fabricators'],
- register_with_steps: false
+ register_with_steps: false,
+ path_prefix: defined?(Rails) ? Rails.root : "."
}
OPTIONS = {}.merge!(DEFAULTS)
end
@@ -28,9 +28,8 @@ def variable_name_to_class_name(name)
def find_definitions
Fabrication.schematics.preinitialize
- path_prefix = defined?(Rails) ? Rails.root : "."
Fabrication::Config.fabricator_dir.each do |folder|
- Dir.glob(File.join(path_prefix, folder, '**', '*.rb')).sort.each do |file|
+ Dir.glob(File.join(Fabrication::Config.path_prefix, folder, '**', '*.rb')).sort.each do |file|
load file
end
end

0 comments on commit b279db8

Please sign in to comment.