database_flusher 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +12 -0
- data/README.md +69 -14
- data/database_flusher.gemspec +19 -9
- data/lib/database_flusher/active_record/adapters/abstract_adapter.rb +40 -0
- data/lib/database_flusher/active_record/adapters/mysql2_adapter.rb +25 -0
- data/lib/database_flusher/active_record/adapters/postgresql_adapter.rb +22 -0
- data/lib/database_flusher/active_record/adapters/sqlite_adapter.rb +11 -0
- data/lib/database_flusher/active_record/deletion_strategy.rb +59 -0
- data/lib/database_flusher/active_record/transaction_strategy.rb +24 -0
- data/lib/database_flusher/cleaner.rb +57 -0
- data/lib/database_flusher/mongoid/deletion_strategy.rb +52 -0
- data/lib/database_flusher/null_strategy.rb +7 -0
- data/lib/database_flusher/version.rb +1 -1
- data/lib/database_flusher.rb +16 -86
- metadata +96 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ae582039a16a7f6b25c12b09683663d3061c9fb
|
4
|
+
data.tar.gz: ee031d973bf006c2640d8bae58b8aee97457c617
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 489db40d248249811e8f16420dfda4c02a2e3b42bd2c709028061b371c8efcc3b2ab4c8e584a9f0c0f687396ce3aeb881fb5195933c9954409fb3d72f2774e5c
|
7
|
+
data.tar.gz: 9b039b7933fa803c298719792e74f5255c4b4f13e6310207777fe35c32dcd7580b833430e13763b3a5891673abee6fd4fe603219e4ed6ec90a90c12949fcf73a
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,23 @@
|
|
1
1
|
# DatabaseFlusher
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/ebeigarts/database_flusher.svg?branch=master)](https://travis-ci.org/ebeigarts/database_flusher)
|
4
|
+
|
5
|
+
database_flusher is a tiny and fast database cleaner inspired by [database_cleaner](https://github.com/DatabaseCleaner/database_cleaner) and [database_rewinder](https://github.com/amatsuda/database_rewinder).
|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
* No monkey patching - uses `ActiveSupport::Notifications` and `Mongo::Monitoring::Global` to catch `INSERT` statements
|
10
|
+
* Fast `:deletion` strategy that cleans only tables/collections where `INSERT` statements were performed
|
11
|
+
* Faster `disable_referential_integrity` for PostgreSQL
|
12
|
+
* Executes multiple `DELETE` statements as one query with ActiveRecord
|
13
|
+
|
14
|
+
## Supported ORMs and strategies
|
15
|
+
|
16
|
+
| ORM | Deletion | Transaction |
|
17
|
+
|:-------------|:---------|:------------|
|
18
|
+
| ActiveRecord | Yes | Yes |
|
19
|
+
| Mongoid | Yes | No |
|
4
20
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
21
|
|
7
22
|
## Installation
|
8
23
|
|
@@ -14,28 +29,68 @@ gem 'database_flusher'
|
|
14
29
|
|
15
30
|
And then execute:
|
16
31
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
$ gem install database_flusher
|
32
|
+
```bash
|
33
|
+
$ bundle
|
34
|
+
```
|
22
35
|
|
23
36
|
## Usage
|
24
37
|
|
25
|
-
|
38
|
+
RSpec:
|
26
39
|
|
27
|
-
|
40
|
+
```ruby
|
41
|
+
RSpec.configure do |config|
|
42
|
+
config.use_transactional_fixtures = false
|
43
|
+
|
44
|
+
config.before :suite do
|
45
|
+
DatabaseFlusher[:active_record].strategy = :transaction
|
46
|
+
DatabaseFlusher[:mongoid].strategy = :deletion
|
47
|
+
end
|
48
|
+
|
49
|
+
config.before :each do
|
50
|
+
DatabaseFlusher[:active_record].strategy = :transaction
|
51
|
+
end
|
52
|
+
|
53
|
+
config.before :each, type: :feature do
|
54
|
+
if Capybara.current_driver != :rack_test
|
55
|
+
DatabaseFlusher[:active_record].strategy = :deletion
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
config.before :each do
|
60
|
+
DatabaseFlusher.start
|
61
|
+
end
|
62
|
+
|
63
|
+
config.append_after :each do
|
64
|
+
DatabaseFlusher.clean
|
65
|
+
end
|
66
|
+
end
|
67
|
+
```
|
28
68
|
|
29
|
-
|
69
|
+
Cucumber:
|
30
70
|
|
31
|
-
|
71
|
+
```ruby
|
72
|
+
DatabaseFlusher[:active_record].strategy = :transaction
|
73
|
+
DatabaseFlusher[:mongoid].strategy = :deletion
|
74
|
+
|
75
|
+
Before('~@javascript') do
|
76
|
+
DatabaseFlusher[:active_record].strategy = :transaction
|
77
|
+
DatabaseFlusher.start
|
78
|
+
end
|
79
|
+
|
80
|
+
Before('@javascript') do
|
81
|
+
DatabaseFlusher[:active_record].strategy = :deletion
|
82
|
+
DatabaseFlusher.start
|
83
|
+
end
|
84
|
+
|
85
|
+
After do
|
86
|
+
DatabaseFlusher.clean
|
87
|
+
end
|
88
|
+
```
|
32
89
|
|
33
90
|
## Contributing
|
34
91
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
36
|
-
|
92
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ebeigarts/database_flusher. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
37
93
|
|
38
94
|
## License
|
39
95
|
|
40
96
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/database_flusher.gemspec
CHANGED
@@ -4,22 +4,32 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'database_flusher/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'database_flusher'
|
8
8
|
spec.version = DatabaseFlusher::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Edgars Beigarts']
|
10
|
+
spec.email = ['edgars.beigarts@gmail.com']
|
11
11
|
|
12
12
|
spec.summary = %q{super-fast database cleaner}
|
13
13
|
spec.description = spec.summary
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
14
|
+
spec.homepage = 'https://github.com/ebeigarts/database_flusher'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
18
|
f.match(%r{^(test|spec|features)/})
|
19
19
|
end
|
20
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ['lib']
|
21
21
|
|
22
|
-
spec.
|
23
|
-
|
24
|
-
spec.add_development_dependency
|
22
|
+
spec.required_ruby_version = '>= 2.2.1'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'byebug'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'activerecord'
|
30
|
+
spec.add_development_dependency 'sqlite3'
|
31
|
+
spec.add_development_dependency 'mysql2'
|
32
|
+
spec.add_development_dependency 'pg'
|
33
|
+
|
34
|
+
spec.add_development_dependency 'mongoid'
|
25
35
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module DatabaseFlusher
|
2
|
+
module ActiveRecord
|
3
|
+
class AbstractAdapter
|
4
|
+
attr_reader :connection, :raw_connection
|
5
|
+
|
6
|
+
def initialize(connection)
|
7
|
+
@connection = connection
|
8
|
+
@raw_connection = connection.raw_connection
|
9
|
+
end
|
10
|
+
|
11
|
+
def delete(*tables)
|
12
|
+
disable_referential_integrity(*tables) do
|
13
|
+
stmts = tables.map do |name|
|
14
|
+
"DELETE FROM #{quote_table_name(name)}"
|
15
|
+
end
|
16
|
+
sql = stmts.join(';')
|
17
|
+
execute_multi sql
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def execute_multi(sql)
|
24
|
+
connection.execute sql
|
25
|
+
end
|
26
|
+
|
27
|
+
def execute(sql)
|
28
|
+
connection.execute sql
|
29
|
+
end
|
30
|
+
|
31
|
+
def quote_table_name(name)
|
32
|
+
connection.quote_table_name(name)
|
33
|
+
end
|
34
|
+
|
35
|
+
def disable_referential_integrity(*tables, &block)
|
36
|
+
connection.disable_referential_integrity(&block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module DatabaseFlusher
|
2
|
+
module ActiveRecord
|
3
|
+
class Mysql2Adapter < AbstractAdapter
|
4
|
+
def initialize(connection)
|
5
|
+
super
|
6
|
+
flags = raw_connection.query_options[:flags]
|
7
|
+
unless flags.include?('MULTI_STATEMENTS'.freeze)
|
8
|
+
raise 'MULTI_STATEMENTS flag is not enabled'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def execute_multi(sql)
|
15
|
+
connection.disable_referential_integrity do
|
16
|
+
_result = raw_connection.query sql
|
17
|
+
while raw_connection.next_result
|
18
|
+
# just to make sure that all queries are finished
|
19
|
+
_result = raw_connection.store_result
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module DatabaseFlusher
|
2
|
+
module ActiveRecord
|
3
|
+
class PostgreSQLAdapter < AbstractAdapter
|
4
|
+
private
|
5
|
+
|
6
|
+
def disable_referential_integrity(*tables, &block)
|
7
|
+
begin
|
8
|
+
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";"))
|
9
|
+
rescue
|
10
|
+
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER USER" }.join(";"))
|
11
|
+
end
|
12
|
+
yield
|
13
|
+
ensure
|
14
|
+
begin
|
15
|
+
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";"))
|
16
|
+
rescue
|
17
|
+
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER USER" }.join(";"))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'database_flusher/active_record/adapters/abstract_adapter'
|
2
|
+
require 'database_flusher/active_record/adapters/mysql2_adapter'
|
3
|
+
require 'database_flusher/active_record/adapters/postgresql_adapter'
|
4
|
+
require 'database_flusher/active_record/adapters/sqlite_adapter'
|
5
|
+
|
6
|
+
module DatabaseFlusher
|
7
|
+
module ActiveRecord
|
8
|
+
class DeletionStrategy
|
9
|
+
attr_reader :tables, :adapter
|
10
|
+
|
11
|
+
class Subscriber
|
12
|
+
def initialize(strategy)
|
13
|
+
@strategy = strategy
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(_, _, _, _, payload)
|
17
|
+
sql = payload[:sql]
|
18
|
+
match = sql.match(/\A\s*INSERT(?:\s+IGNORE)?(?:\s+INTO)?\s+(?:\.*[`"]?([^.\s`"]+)[`"]?)*/i)
|
19
|
+
return unless match
|
20
|
+
table = match[1]
|
21
|
+
if table
|
22
|
+
@strategy.tables << table
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@tables = Set.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def start
|
32
|
+
@subscriber ||= ActiveSupport::Notifications.subscribe(
|
33
|
+
'sql.active_record',
|
34
|
+
Subscriber.new(self)
|
35
|
+
)
|
36
|
+
connection = ::ActiveRecord::Base.connection
|
37
|
+
@adapter = DatabaseFlusher::ActiveRecord.
|
38
|
+
const_get("#{connection.adapter_name}Adapter").
|
39
|
+
new(connection)
|
40
|
+
end
|
41
|
+
|
42
|
+
def stop
|
43
|
+
if @subscriber
|
44
|
+
ActiveSupport::Notifications.unsubscribe(@subscriber)
|
45
|
+
@subscriber = nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def clean
|
50
|
+
return if tables.empty?
|
51
|
+
|
52
|
+
# puts "Cleaning #{tables.inspect}"
|
53
|
+
adapter.delete(*tables)
|
54
|
+
|
55
|
+
tables.clear
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DatabaseFlusher
|
2
|
+
module ActiveRecord
|
3
|
+
class TransactionStrategy
|
4
|
+
def start
|
5
|
+
# Hack to make sure that the connection is properly setup for
|
6
|
+
# the clean code.
|
7
|
+
::ActiveRecord::Base.connection.transaction{ }
|
8
|
+
|
9
|
+
::ActiveRecord::Base.connection.begin_transaction joinable: false
|
10
|
+
end
|
11
|
+
|
12
|
+
def stop
|
13
|
+
::ActiveRecord::Base.connection_pool.connections.each do |connection|
|
14
|
+
next unless connection.open_transactions > 0
|
15
|
+
connection.rollback_transaction
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def clean
|
20
|
+
stop
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module DatabaseFlusher
|
2
|
+
class Cleaner
|
3
|
+
attr_reader :strategy
|
4
|
+
|
5
|
+
def initialize(orm)
|
6
|
+
@orm = orm
|
7
|
+
reset_strategy
|
8
|
+
end
|
9
|
+
|
10
|
+
def strategy=(name)
|
11
|
+
strategy_changed = name != @strategy_name
|
12
|
+
|
13
|
+
stop if strategy_changed
|
14
|
+
|
15
|
+
if name
|
16
|
+
create_strategy(name) if strategy_changed
|
17
|
+
else
|
18
|
+
reset_strategy
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def clean_with(name)
|
23
|
+
self.strategy = name
|
24
|
+
strategy.clean
|
25
|
+
end
|
26
|
+
|
27
|
+
def start
|
28
|
+
strategy.start
|
29
|
+
end
|
30
|
+
|
31
|
+
def stop
|
32
|
+
strategy.stop
|
33
|
+
end
|
34
|
+
|
35
|
+
def clean
|
36
|
+
strategy.clean
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def create_strategy(name)
|
42
|
+
@strategy_name = name
|
43
|
+
@strategy = DatabaseFlusher.
|
44
|
+
const_get(classify(@orm)).
|
45
|
+
const_get("#{classify(name)}Strategy").new
|
46
|
+
end
|
47
|
+
|
48
|
+
def reset_strategy
|
49
|
+
@strategy_name = nil
|
50
|
+
@strategy = DatabaseFlusher::NullStrategy.new
|
51
|
+
end
|
52
|
+
|
53
|
+
def classify(name)
|
54
|
+
name.to_s.split('_').collect(&:capitalize).join
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module DatabaseFlusher
|
2
|
+
module Mongoid
|
3
|
+
class DeletionStrategy
|
4
|
+
attr_reader :collections
|
5
|
+
|
6
|
+
class Subscriber
|
7
|
+
def initialize(strategy)
|
8
|
+
@strategy = strategy
|
9
|
+
end
|
10
|
+
|
11
|
+
def started(event)
|
12
|
+
if event.command_name == :insert || event.command_name == 'insert'.freeze
|
13
|
+
collection = event.command['insert'.freeze]
|
14
|
+
if collection
|
15
|
+
@strategy.collections << collection
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def method_missing(*args, &block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@collections = Set.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def start
|
31
|
+
@subscriber ||= Mongo::Monitoring::Global.subscribe(
|
32
|
+
Mongo::Monitoring::COMMAND,
|
33
|
+
Subscriber.new(self)
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def stop
|
38
|
+
raise NotImplementedError, "Mongo doesn't provide unsubscribe"
|
39
|
+
end
|
40
|
+
|
41
|
+
def clean
|
42
|
+
return if collections.empty?
|
43
|
+
# puts "Cleaning #{collections.inspect}"
|
44
|
+
collections.each do |name|
|
45
|
+
client = ::Mongoid::Clients.default
|
46
|
+
client[name].delete_many
|
47
|
+
end
|
48
|
+
collections.clear
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/database_flusher.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
require 'database_flusher/version'
|
4
|
+
require 'database_flusher/null_strategy'
|
5
|
+
require 'database_flusher/cleaner'
|
6
|
+
|
7
|
+
require 'database_flusher/active_record/deletion_strategy'
|
8
|
+
require 'database_flusher/active_record/transaction_strategy'
|
9
|
+
require 'database_flusher/mongoid/deletion_strategy'
|
3
10
|
|
4
11
|
module DatabaseFlusher
|
5
12
|
extend self
|
@@ -8,96 +15,19 @@ module DatabaseFlusher
|
|
8
15
|
@cleaners ||= {}
|
9
16
|
end
|
10
17
|
|
11
|
-
# TODO: classify
|
12
18
|
def [](name)
|
13
|
-
cleaners[name] ||= DatabaseFlusher.
|
14
|
-
end
|
15
|
-
|
16
|
-
def clean
|
17
|
-
cleaners.values.each { |cleaner| cleaner.clean }
|
18
|
-
end
|
19
|
-
|
20
|
-
class MongoSubscriber
|
21
|
-
def initialize(cleaner)
|
22
|
-
@cleaner = cleaner
|
23
|
-
end
|
24
|
-
|
25
|
-
def started(event)
|
26
|
-
if event.command_name == :insert || event.command_name == 'insert'.freeze
|
27
|
-
collection = event.command['insert'.freeze]
|
28
|
-
if collection
|
29
|
-
@cleaner.collections << collection
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def method_missing(*args, &block)
|
37
|
-
# puts args.inspect
|
38
|
-
end
|
19
|
+
cleaners[name] ||= DatabaseFlusher::Cleaner.new(name)
|
39
20
|
end
|
40
21
|
|
41
|
-
|
42
|
-
|
43
|
-
attr_reader :collections
|
44
|
-
|
45
|
-
def initialize
|
46
|
-
@collections = Set.new
|
47
|
-
Mongo::Monitoring::Global.subscribe(
|
48
|
-
Mongo::Monitoring::COMMAND,
|
49
|
-
MongoSubscriber.new(self)
|
50
|
-
)
|
51
|
-
end
|
52
|
-
|
53
|
-
def clean
|
54
|
-
return unless strategy
|
55
|
-
client = Mongoid::Clients.default
|
56
|
-
# puts "Cleaning #{collections.inspect}"
|
57
|
-
collections.each do |name|
|
58
|
-
client[name].delete_many
|
59
|
-
end
|
60
|
-
collections.clear
|
61
|
-
end
|
22
|
+
def start
|
23
|
+
cleaners.values.each(&:start)
|
62
24
|
end
|
63
25
|
|
64
|
-
|
65
|
-
|
66
|
-
@cleaner = cleaner
|
67
|
-
end
|
68
|
-
|
69
|
-
def call(_, _, _, _, payload)
|
70
|
-
sql = payload[:sql]
|
71
|
-
match = sql.match(/\A\s*INSERT(?:\s+IGNORE)?(?:\s+INTO)?\s+(?:\.*[`"]?([^.\s`"]+)[`"]?)*/i)
|
72
|
-
return unless match
|
73
|
-
table = match[1]
|
74
|
-
if table
|
75
|
-
@cleaner.tables << table
|
76
|
-
end
|
77
|
-
end
|
26
|
+
def stop
|
27
|
+
cleaners.values.each(&:stop)
|
78
28
|
end
|
79
29
|
|
80
|
-
|
81
|
-
|
82
|
-
attr_reader :tables
|
83
|
-
|
84
|
-
def initialize
|
85
|
-
@tables = Set.new
|
86
|
-
ActiveSupport::Notifications.subscribe(
|
87
|
-
'sql.active_record',
|
88
|
-
ActiveRecordSubscriber.new(self)
|
89
|
-
)
|
90
|
-
end
|
91
|
-
|
92
|
-
def clean
|
93
|
-
return unless strategy
|
94
|
-
connection = ActiveRecord::Base.connection
|
95
|
-
# puts "Cleaning #{tables.inspect}"
|
96
|
-
connection.disable_referential_integrity do
|
97
|
-
stmts = tables.map { |t| "DELETE FROM #{connection.quote_table_name(t)}" }
|
98
|
-
connection.execute stmts.join('; ')
|
99
|
-
end
|
100
|
-
tables.clear
|
101
|
-
end
|
30
|
+
def clean
|
31
|
+
cleaners.values.each(&:clean)
|
102
32
|
end
|
103
33
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgars Beigarts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,90 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activerecord
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: mysql2
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pg
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: mongoid
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
55
139
|
description: super-fast database cleaner
|
56
140
|
email:
|
57
141
|
- edgars.beigarts@gmail.com
|
@@ -71,6 +155,15 @@ files:
|
|
71
155
|
- bin/setup
|
72
156
|
- database_flusher.gemspec
|
73
157
|
- lib/database_flusher.rb
|
158
|
+
- lib/database_flusher/active_record/adapters/abstract_adapter.rb
|
159
|
+
- lib/database_flusher/active_record/adapters/mysql2_adapter.rb
|
160
|
+
- lib/database_flusher/active_record/adapters/postgresql_adapter.rb
|
161
|
+
- lib/database_flusher/active_record/adapters/sqlite_adapter.rb
|
162
|
+
- lib/database_flusher/active_record/deletion_strategy.rb
|
163
|
+
- lib/database_flusher/active_record/transaction_strategy.rb
|
164
|
+
- lib/database_flusher/cleaner.rb
|
165
|
+
- lib/database_flusher/mongoid/deletion_strategy.rb
|
166
|
+
- lib/database_flusher/null_strategy.rb
|
74
167
|
- lib/database_flusher/version.rb
|
75
168
|
homepage: https://github.com/ebeigarts/database_flusher
|
76
169
|
licenses:
|
@@ -84,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
177
|
requirements:
|
85
178
|
- - ">="
|
86
179
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
180
|
+
version: 2.2.1
|
88
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
182
|
requirements:
|
90
183
|
- - ">="
|