seed_dump 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/VERSION +1 -1
- data/lib/seed_dump/perform.rb +12 -4
- data/seed_dump.gemspec +1 -1
- metadata +1 -1
data/CHANGELOG.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/seed_dump/perform.rb
CHANGED
@@ -38,22 +38,30 @@ module SeedDump
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.dumpModel(model)
|
41
|
+
@id_set_string = ''
|
41
42
|
create_hash = ""
|
42
|
-
|
43
|
+
rows = []
|
43
44
|
arr = model.find(:all, @ar_options) unless @opts['no-data']
|
44
45
|
arr = arr.empty? ? [model.new] : arr
|
45
46
|
arr.each_with_index { |r,i|
|
46
47
|
attr_s = [];
|
47
48
|
r.attributes.each { |k,v| dumpAttribute(attr_s,r,k,v) }
|
48
|
-
|
49
|
+
if @id_set_string.empty?
|
50
|
+
rows.push "#{@indent}{ " << attr_s.join(', ') << " }"
|
51
|
+
else
|
52
|
+
create_hash << "\n#{model}.create" << '( ' << attr_s.join(', ') << ' )' << @id_set_string
|
53
|
+
end
|
49
54
|
}
|
50
|
-
|
55
|
+
if @id_set_string.empty?
|
56
|
+
"\n#{model}.create([\n" << rows.join(",\n") << "\n])\n"
|
57
|
+
else
|
58
|
+
create_hash
|
59
|
+
end
|
51
60
|
end
|
52
61
|
|
53
62
|
def self.dumpModels
|
54
63
|
@seed_rb = ""
|
55
64
|
@models.sort.each do |model|
|
56
|
-
@id_set_string = ''
|
57
65
|
puts "Adding #{model} seeds." if @verbose
|
58
66
|
@seed_rb << dumpModel(model) << "\n\n"
|
59
67
|
end
|
data/seed_dump.gemspec
CHANGED