database_flusher 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90cac9582ff73ebe0151abb8ea901bdae8280dc4
4
- data.tar.gz: 99ebfe15fbf6de3c1ac4d479f7bda06ec6c89995
3
+ metadata.gz: 20a81343383744be91dbda01a0a476b136c05cba
4
+ data.tar.gz: c060ed34325bee77a009ff4f41c15979bcd3bf18
5
5
  SHA512:
6
- metadata.gz: 1b30f3618eff2f27ecb506c79ee2d80df941ac008ddbbed8c505f82b6df9bd31344ef6cecaa9534987450b49c7e80f2390b815dbb910ba56f2b256f7e9c9d56c
7
- data.tar.gz: a5b2ce6762f219a3172c4db6eb229a2a1a0ee5344b9956690ebbc6bda4e41fa9152c9adc4a76bdd1ec28dc1e01b26ff4572a5106c811a430e5c5b9ef0ecc5635
6
+ metadata.gz: e5d99764bdebeb9203adcadbd50db85b7ce3ea1293fd00af78b743e79f068b47a98249bddb7ad22a84b8809e11d6f8d633c2fc8a93bd3af0ffe8cb9bc3ffee51
7
+ data.tar.gz: 69b22da932aee52dce7c4fb7935b87255570f4b84960bf6c1d9426ddb47c0898b1df436dd8f76b96c820864b549dd1edd3971ee8c824f6ae86c060bc3f51ed9b
data/README.md CHANGED
@@ -105,14 +105,23 @@ end
105
105
  DatabaseFlusher[:active_record].strategy = :transaction
106
106
  DatabaseFlusher[:mongoid].strategy = :deletion
107
107
 
108
- # Use Around hook to make sure it runs after capybara session reset.
109
- Around do |scenario, block|
108
+ # Use Before hook to make sure it runs after capybara driver is set.
109
+ Before do
110
110
  if Capybara.current_driver == :rack_test
111
111
  DatabaseFlusher[:active_record].strategy = :transaction
112
112
  else
113
113
  DatabaseFlusher[:active_record].strategy = :deletion
114
114
  end
115
- DatabaseFlusher.cleaning(&block)
115
+ DatabaseFlusher.start
116
+ end
117
+
118
+ # Use Around hook to make sure it runs after capybara session reset.
119
+ Around do |scenario, block|
120
+ begin
121
+ block.call
122
+ ensure
123
+ DatabaseFlusher.clean
124
+ end
116
125
  end
117
126
  ```
118
127
 
@@ -10,16 +10,31 @@ module DatabaseFlusher
10
10
  attr_reader :tables
11
11
 
12
12
  class Subscriber
13
+ # INSERT [IGNORE] [INTO] schema_name.table_name
14
+ PATTERN = %r{
15
+ \A\s*
16
+ INSERT
17
+ (?:\s+IGNORE)?
18
+ (?:\s+INTO)?
19
+ \s+
20
+ (?:[`"]?([^.\s`"]+)[`"]?\.)? # schema
21
+ (?:[`"]?([^.\s`"]+)[`"]?) # table
22
+ }xi
23
+
13
24
  def initialize(strategy)
14
25
  @strategy = strategy
15
26
  end
16
27
 
17
28
  def call(_, _, _, _, payload)
18
29
  sql = payload[:sql]
19
- match = sql.match(/\A\s*INSERT(?:\s+IGNORE)?(?:\s+INTO)?\s+(?:\.*[`"]?([^.\s`"]+)[`"]?)*/i)
30
+ match = sql.match(PATTERN)
20
31
  return unless match
21
- table = match[1]
32
+ table = match[2]
22
33
  if table
34
+ schema = match[1]
35
+ if schema
36
+ table = "#{schema}.#{table}"
37
+ end
23
38
  @strategy.tables << table
24
39
  end
25
40
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module DatabaseFlusher
3
- VERSION = '0.3.2'.freeze
3
+ VERSION = '0.3.3'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_flusher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgars Beigarts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-04 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.5.2
188
+ rubygems_version: 2.6.10
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: super-fast database cleaner