temping 3.4.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/temping.rb +18 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f92d92121487913bed32cd4671b17b4a0994e084
|
4
|
+
data.tar.gz: ef135c7c09c1c0a00392558cd6ba7af2eb60ac53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b92be9a6ec904abdb56adc5fd1f1060ee31f680ccd3d2c65152510c2631b16f5c1570722e163bd160a953a325a0d830a75eea36c2058d9d055a52341bd74b80b
|
7
|
+
data.tar.gz: 93f375e21e966c47e831448ecc4077975713cb09fa60f9aea9c5d40d591ed3e6ea76e05e020fc0439b9fab174a02a75af0d88166631f5c6cf4758775219097bc
|
data/lib/temping.rb
CHANGED
@@ -4,21 +4,27 @@ require "active_support/core_ext/string"
|
|
4
4
|
class Temping
|
5
5
|
@model_klasses = []
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
class << self
|
8
|
+
def create(model_name, options = {}, &block)
|
9
|
+
factory = ModelFactory.new(model_name.to_s.classify, options, &block)
|
10
|
+
klass = factory.klass
|
11
|
+
@model_klasses << klass
|
12
|
+
klass
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
def teardown
|
16
|
+
@model_klasses.each do |klass|
|
17
|
+
if Object.const_defined?(klass.name)
|
18
|
+
klass.connection.drop_table(klass.table_name)
|
19
|
+
Object.send(:remove_const, klass.name)
|
20
|
+
end
|
19
21
|
end
|
22
|
+
@model_klasses.clear
|
23
|
+
end
|
24
|
+
|
25
|
+
def cleanup
|
26
|
+
@model_klasses.each(&:destroy_all)
|
20
27
|
end
|
21
|
-
@model_klasses.clear
|
22
28
|
end
|
23
29
|
|
24
30
|
class ModelFactory
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: temping
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Pignata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|