deep_freezer 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/deep_freezer/defrost.rb +40 -0
- data/lib/deep_freezer/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49debc6776b32159d953f0488f6ec752f6e85279
|
4
|
+
data.tar.gz: cbc17697c8c9ba97d44eceb730bf60b7284fa8f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee0466cb67e5dc42ae5afd0bc6afec72298165133eec5018a9e720dec9a45dd36e4eb098cc446c0d08b09a5494635f650eb3c53e8fa652c87a3d9fb66545b43f
|
7
|
+
data.tar.gz: 2ed1a8af8d99c6d4c243ee15d157590a14c86d693ef4477d6dda29ecaceed98a0ee29e4165ddc04a345dfcf20517b52318ae825cd4a09d5fc8a1c30b5a375cf4
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
class DeepFreezer::Defrost
|
2
|
+
|
3
|
+
def self.load!
|
4
|
+
|
5
|
+
path = DeepFreezer::Base.fixture_path.join("**/*.yml")
|
6
|
+
Dir.glob(path).each do |file|
|
7
|
+
objects = YAML.load(File.read(file))
|
8
|
+
puts "Loading #{objects.first.keys.first}"
|
9
|
+
objects.each do |o|
|
10
|
+
|
11
|
+
klass = o.keys.first
|
12
|
+
attrs = o[klass]
|
13
|
+
obj = klass.constantize.new
|
14
|
+
|
15
|
+
attrs.keys.each do |a|
|
16
|
+
obj.send("#{a}=", attrs[a])
|
17
|
+
end
|
18
|
+
|
19
|
+
sql = self.sql_for(obj)
|
20
|
+
ActiveRecord::Base.connection.execute sql
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.sql_for(record)
|
27
|
+
values = record.send(:arel_attributes_with_values_for_create, record.attribute_names)
|
28
|
+
|
29
|
+
model = record.class
|
30
|
+
scope = model.unscoped
|
31
|
+
|
32
|
+
im = scope.arel.create_insert
|
33
|
+
im.into model.arel_table
|
34
|
+
|
35
|
+
substitutes, binds = scope.substitute_values(values)
|
36
|
+
im.insert substitutes
|
37
|
+
|
38
|
+
record.class.connection.to_sql(im, binds)
|
39
|
+
end
|
40
|
+
end
|
data/lib/deep_freezer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deep_freezer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Provan
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- deep_freezer.gemspec
|
76
76
|
- lib/deep_freezer.rb
|
77
77
|
- lib/deep_freezer/base.rb
|
78
|
+
- lib/deep_freezer/defrost.rb
|
78
79
|
- lib/deep_freezer/version.rb
|
79
80
|
homepage: https://github.com/itison/deep_freezer
|
80
81
|
licenses:
|