database_rewinder 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/database_rewinder.gemspec +1 -1
- data/lib/database_rewinder/cleaner.rb +15 -1
- 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: 417842274697cd6d5616271d7c532fe3cf5a2801
|
4
|
+
data.tar.gz: 6f7bdafdf2c10fc2ad460be38d967ace506828ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13e3e31d2eb7794f48c4036a8edfdab939564d4adce4750dd30f1188a13e519e1bb9f735b24f35d3efb03dc484ef1fe4d8a2834b980258ca784c4a00b43d6853
|
7
|
+
data.tar.gz: 10106fb52e312a5e2254e2773f4f4415bcbf2729d144e4a4f8709ec1e2682053d26b16750e7a29f4f975e424123c4501404e16488fa4afa4b246c9b4788d916d
|
data/database_rewinder.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "database_rewinder"
|
7
|
-
spec.version = '0.
|
7
|
+
spec.version = '0.2.0'
|
8
8
|
spec.authors = ["Akira Matsuda"]
|
9
9
|
spec.email = ["ronnie@dio.jp"]
|
10
10
|
spec.description = "A minimalist's tiny and ultra-fast database cleaner"
|
@@ -10,7 +10,13 @@ module DatabaseRewinder
|
|
10
10
|
def clean
|
11
11
|
return if !pool || inserted_tables.empty?
|
12
12
|
|
13
|
-
|
13
|
+
# When the application uses multiple database connections, a connection
|
14
|
+
# pool used in test could be already removed (i.e., pool.connected? = false).
|
15
|
+
# In this case, we have to reconnect to the database to clean inserted
|
16
|
+
# tables.
|
17
|
+
with_automatic_reconnect(pool) do
|
18
|
+
delete_all (ar_conn = pool.connection), DatabaseRewinder.all_table_names(ar_conn) & inserted_tables
|
19
|
+
end
|
14
20
|
reset
|
15
21
|
end
|
16
22
|
|
@@ -50,5 +56,13 @@ module DatabaseRewinder
|
|
50
56
|
def reset
|
51
57
|
@inserted_tables = []
|
52
58
|
end
|
59
|
+
|
60
|
+
def with_automatic_reconnect(pool, &block)
|
61
|
+
reconnect = pool.automatic_reconnect
|
62
|
+
pool.automatic_reconnect = true
|
63
|
+
block.call
|
64
|
+
ensure
|
65
|
+
pool.automatic_reconnect = reconnect
|
66
|
+
end
|
53
67
|
end
|
54
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_rewinder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|