mbleigh-seed-fu 0.0.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/seed-fu.gemspec +1 -1
- data/tasks/seed_fu_tasks.rake +39 -11
- metadata +2 -1
- data/lib/autotest/discover.rb +0 -6
data/seed-fu.gemspec
CHANGED
data/tasks/seed_fu_tasks.rake
CHANGED
@@ -1,16 +1,44 @@
|
|
1
1
|
namespace :db do
|
2
|
-
desc
|
2
|
+
desc <<-EOS
|
3
|
+
Loads seed data for the current environment. It will look for
|
4
|
+
ruby seed files in <RAILS_ROOT>/db/fixtures/ and
|
5
|
+
<RAILS_ROOT>/db/fixtures/<RAILS_ENV>/.
|
6
|
+
|
7
|
+
By default it will load any ruby files found. You can filter the files
|
8
|
+
loaded by passing in the SEED environment variable with a comma-delimited
|
9
|
+
list of patterns to include. Any files not matching the pattern will
|
10
|
+
not be loaded.
|
11
|
+
|
12
|
+
You can also change the directory where seed files are looked for
|
13
|
+
with the FIXTURE_PATH environment variable.
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
# default, to load all seed files for the current environment
|
17
|
+
rake db:seed
|
18
|
+
|
19
|
+
# to load seed files matching orders or customers
|
20
|
+
rake db:seed SEED=orders,customers
|
21
|
+
|
22
|
+
# to load files from RAILS_ROOT/features/fixtures
|
23
|
+
rake db:seed FIXTURE_PATH=features/fixtures
|
24
|
+
EOS
|
3
25
|
task :seed => :environment do
|
4
26
|
fixture_path = ENV["FIXTURE_PATH"] ? ENV["FIXTURE_PATH"] : "db/fixtures"
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
puts "
|
14
|
-
|
27
|
+
|
28
|
+
global_seed_files = Dir[File.join(RAILS_ROOT, fixture_path, '*.rb')].sort
|
29
|
+
env_specific_seed_files = Dir[File.join(RAILS_ROOT, fixture_path, RAILS_ENV, '*.rb')]
|
30
|
+
potential_seed_files = (global_seed_files + env_specific_seed_files).uniq
|
31
|
+
|
32
|
+
if ENV["SEED"]
|
33
|
+
filter = ENV["SEED"].gsub(/,/, "|")
|
34
|
+
potential_seed_files.reject!{ |file| true unless file =~ /#{filter}/ }
|
35
|
+
puts "\n == Filtering seed files against regexp: #{filter}"
|
36
|
+
end
|
37
|
+
|
38
|
+
potential_seed_files.each do |file|
|
39
|
+
pretty_name = file.sub("#{RAILS_ROOT}/", "")
|
40
|
+
puts "\n== Seed from #{pretty_name} " + ("=" * (60 - (17 + File.split(file).last.length)))
|
41
|
+
load file
|
42
|
+
end
|
15
43
|
end
|
16
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mbleigh-seed-fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -14,6 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|