seed_dump 0.2.1 → 0.2.2

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/README.rdoc CHANGED
@@ -24,15 +24,15 @@ Result:
24
24
  # Autogenerated by the db:seed:dump task
25
25
  # Do not hesitate to tweak this to your needs
26
26
 
27
- products = Product.create(
27
+ products = Product.create([
28
28
  { :category_id => 1, :description => "Long Sleeve Shirt", :name => "Long Sleeve Shirt" },
29
29
  { :category_id => 3, :description => "Plain White Tee Shirt", :name => "Plain T-Shirt" }
30
- )
30
+ ])
31
31
 
32
- users = User.create(
32
+ users = User.create([
33
33
  { :id => 1, :password => "123456", :username => "test_1" },
34
34
  { :id => 2, :password => "234567", :username => "tes2" }
35
- )
35
+ ])
36
36
 
37
37
  Append to db/seeds.rb instead of overwriting it:
38
38
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -17,11 +17,15 @@ namespace :db do
17
17
 
18
18
  new_line = "\n"
19
19
 
20
+ puts "Appending seeds to #{opts['file']}." if opts['append']
21
+
20
22
  seed_rb = ""
21
- Dir['app/models/*.rb'].each do |f|
23
+ Dir['app/models/*.rb'].sort.each do |f|
22
24
  model_name = File.basename(f, '.*')
23
25
  if models.include?(model_name) || models.empty?
24
26
 
27
+ puts "Adding #{model_name.camelize} seeds."
28
+
25
29
  create_hash = ""
26
30
 
27
31
  model = model_name.camelize.constantize
@@ -38,7 +42,6 @@ namespace :db do
38
42
  }
39
43
 
40
44
  create_hash << (i > 0 ? ",#{new_line}" : new_line) << indent << '{ ' << attr_s.join(', ') << ' }'
41
-
42
45
  }
43
46
 
44
47
  seed_rb << "#{new_line}#{model_name.pluralize} = #{model_name.camelize}.create([#{create_hash}#{new_line}])#{new_line}"
@@ -47,7 +50,9 @@ namespace :db do
47
50
 
48
51
  File.open(opts['file'], (opts['append'] ? "a" : "w")) { |f|
49
52
 
50
- unless opts['append']
53
+ puts "Writing #{opts['file']}."
54
+
55
+ unless opts['append']
51
56
  cont =<<HERE
52
57
  # Autogenerated by the db:seed:dump task
53
58
  # Do not hesitate to tweak this to your needs
@@ -60,6 +65,8 @@ HERE
60
65
  HERE
61
66
  f << cont
62
67
 
68
+ puts "Done."
69
+
63
70
  }
64
71
  end
65
72
  end
data/seed_dump.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{seed_dump}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rob Halff"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rob Halff