fixturease 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/fixturease.rb +4 -2
- metadata +1 -1
data/Rakefile
CHANGED
data/bin/fixturease.rb
CHANGED
@@ -30,10 +30,12 @@ else
|
|
30
30
|
unless ActiveRecord::Base.fixturease_fixtures.keys.empty?
|
31
31
|
puts
|
32
32
|
puts "Saving fixtures:"
|
33
|
-
ActiveRecord::Base.fixturease_fixtures.each_pair do |k,
|
33
|
+
ActiveRecord::Base.fixturease_fixtures.each_pair do |k,val|
|
34
34
|
filename = "#{ENV['RAILS_ROOT']}/#{ENV['FIXTURES_ROOT']}/#{k.table_name}.yml"
|
35
35
|
print "#{k} [#{filename}]: "
|
36
|
-
|
36
|
+
v = {}
|
37
|
+
val.each_pair {|rec_id,obj| v[rec_id] = obj if k.exists?(rec_id) }
|
38
|
+
puts v.keys.collect{|rec_id| o = k.find(rec_id) ; vars[o] ? vars[o] : rec_id}.to_sentence
|
37
39
|
f = File.new("#{filename}","a")
|
38
40
|
f.write "\n\n# Fixturease (#{Time.now}):\n\n"
|
39
41
|
f.write v.values.inject({}) { |hsh, record| hsh.merge(vars[record] || "#{k.table_name}_#{record.id}" => record.attributes) }.to_yaml(:SortKeys => true).gsub(/^---.*\n/,"")
|