database_cleaner-nobrainer 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +88 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +8 -0
- data/bin/console +19 -0
- data/bin/setup +7 -0
- data/database_cleaner-nobrainer.gemspec +31 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/nobrainer0.gemfile +14 -0
- data/lib/database_cleaner-nobrainer.rb +3 -0
- data/lib/database_cleaner/nobrainer.rb +7 -0
- data/lib/database_cleaner/nobrainer/deletion.rb +41 -0
- data/lib/database_cleaner/nobrainer/version.rb +7 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ffc70a387238a97f6ee167a44bde8bb60e5bfc79d0c2cfee8359b005e3d85d81
|
4
|
+
data.tar.gz: '08ad8900378e0d8c409beac82997afaf85f5c7fd4aa89516307320c132344ed6'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 947434d9de3d4384becf599b3fd544e34f1b9a3cf1db2f645e02b09af8c3c7515d8bae6aa7bcc103e39b6f734492699100caf1dfbcb310ae3dc13a9a1dfd9789
|
7
|
+
data.tar.gz: 263f018e5b51c4f5396dce94824edaac5a8f6fbd5f2094c513317531a111b8d4603bf324ff2252a55dd9e224c527b574d0f2f20cbd43792478338c7999145c37
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in database_cleaner-mongoid.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'database_cleaner-core', git: 'https://github.com/DatabaseCleaner/database_cleaner'
|
7
|
+
|
8
|
+
gem 'byebug'
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'codecov', require: false
|
12
|
+
gem 'simplecov', require: false
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/DatabaseCleaner/database_cleaner
|
3
|
+
revision: 855abc968d6ec1bf86b5c2a90687c53151794a0d
|
4
|
+
specs:
|
5
|
+
database_cleaner-core (2.0.0.beta2)
|
6
|
+
|
7
|
+
PATH
|
8
|
+
remote: .
|
9
|
+
specs:
|
10
|
+
database_cleaner-nobrainer (1.0.0)
|
11
|
+
database_cleaner-core (~> 2.0.0.beta2)
|
12
|
+
nobrainer (~> 0.30)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: https://rubygems.org/
|
16
|
+
specs:
|
17
|
+
activemodel (6.0.3.3)
|
18
|
+
activesupport (= 6.0.3.3)
|
19
|
+
activesupport (6.0.3.3)
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
|
+
i18n (>= 0.7, < 2)
|
22
|
+
minitest (~> 5.1)
|
23
|
+
tzinfo (~> 1.1)
|
24
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
25
|
+
appraisal (2.3.0)
|
26
|
+
bundler
|
27
|
+
rake
|
28
|
+
thor (>= 0.14.0)
|
29
|
+
byebug (11.1.3)
|
30
|
+
codecov (0.2.11)
|
31
|
+
json
|
32
|
+
simplecov
|
33
|
+
concurrent-ruby (1.1.7)
|
34
|
+
diff-lcs (1.4.4)
|
35
|
+
docile (1.3.2)
|
36
|
+
i18n (1.8.5)
|
37
|
+
concurrent-ruby (~> 1.0)
|
38
|
+
json (2.3.1)
|
39
|
+
middleware (0.1.0)
|
40
|
+
minitest (5.14.2)
|
41
|
+
nobrainer (0.34.0)
|
42
|
+
activemodel (>= 4.1.0)
|
43
|
+
activesupport (>= 4.1.0)
|
44
|
+
middleware (~> 0.1.0)
|
45
|
+
rethinkdb (>= 2.3.0)
|
46
|
+
symbol_decoration (~> 1.1)
|
47
|
+
rake (13.0.1)
|
48
|
+
rethinkdb (2.4.0.0)
|
49
|
+
rspec (3.9.0)
|
50
|
+
rspec-core (~> 3.9.0)
|
51
|
+
rspec-expectations (~> 3.9.0)
|
52
|
+
rspec-mocks (~> 3.9.0)
|
53
|
+
rspec-core (3.9.3)
|
54
|
+
rspec-support (~> 3.9.3)
|
55
|
+
rspec-expectations (3.9.2)
|
56
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
57
|
+
rspec-support (~> 3.9.0)
|
58
|
+
rspec-mocks (3.9.1)
|
59
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
60
|
+
rspec-support (~> 3.9.0)
|
61
|
+
rspec-support (3.9.3)
|
62
|
+
simplecov (0.19.0)
|
63
|
+
docile (~> 1.1)
|
64
|
+
simplecov-html (~> 0.11)
|
65
|
+
simplecov-html (0.12.3)
|
66
|
+
symbol_decoration (1.1.0)
|
67
|
+
thor (1.0.1)
|
68
|
+
thread_safe (0.3.6)
|
69
|
+
tzinfo (1.2.7)
|
70
|
+
thread_safe (~> 0.1)
|
71
|
+
zeitwerk (2.4.0)
|
72
|
+
|
73
|
+
PLATFORMS
|
74
|
+
ruby
|
75
|
+
|
76
|
+
DEPENDENCIES
|
77
|
+
appraisal (~> 2)
|
78
|
+
bundler (~> 2)
|
79
|
+
byebug
|
80
|
+
codecov
|
81
|
+
database_cleaner-core!
|
82
|
+
database_cleaner-nobrainer!
|
83
|
+
rake (~> 13)
|
84
|
+
rspec (~> 3)
|
85
|
+
simplecov
|
86
|
+
|
87
|
+
BUNDLED WITH
|
88
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Guillaume Hain
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Database Cleaner Adapter for Nobrainer
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.com/zedtux/database_cleaner-nobrainer.svg?branch=master)](https://travis-ci.com/zedtux/database_cleaner-nobrainer)
|
4
|
+
|
5
|
+
Clean your Nobrainer databases with Database Cleaner.
|
6
|
+
|
7
|
+
See https://github.com/DatabaseCleaner/database_cleaner for more information.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
# Gemfile
|
13
|
+
group :test do
|
14
|
+
gem 'database_cleaner-nobrainer'
|
15
|
+
end
|
16
|
+
```
|
17
|
+
|
18
|
+
## Supported Strategies
|
19
|
+
|
20
|
+
The nobrainer adapter only has one strategy: the deletion strategy.
|
21
|
+
|
22
|
+
## Strategy configuration options
|
23
|
+
|
24
|
+
`:only` and `:except` may take a list of collection names:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
# Only delete the "users" collection.
|
28
|
+
DatabaseCleaner[:nobrainer].strategy = :deletion, { only: ["users"] }
|
29
|
+
|
30
|
+
# Delete all collections except the "users" collection.
|
31
|
+
DatabaseCleaner[:nobrainer].strategy = :deletion, { except: ["users"] }
|
32
|
+
```
|
33
|
+
|
34
|
+
## Adapter configuration options
|
35
|
+
|
36
|
+
`#db` defaults to the Nobrainer database, but can be specified manually in a few ways:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
# Redis URI string:
|
40
|
+
DatabaseCleaner[:nobrainer].db = :logs
|
41
|
+
|
42
|
+
# Back to default:
|
43
|
+
DatabaseCleaner[:nobrainer].db = NoBrainer.current_db
|
44
|
+
|
45
|
+
# Multiple Nobrainer databases can be specified:
|
46
|
+
DatabaseCleaner[:nobrainer, connection: :default]
|
47
|
+
DatabaseCleaner[:nobrainer, connection: :shard_1]
|
48
|
+
DatabaseCleaner[:nobrainer, connection: :shard_2]
|
49
|
+
```
|
50
|
+
|
51
|
+
## COPYRIGHT
|
52
|
+
|
53
|
+
See [LICENSE](LICENSE) for details.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'nobrainer'
|
5
|
+
require 'database_cleaner/nobrainer'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
NoBrainer.configure do |config|
|
15
|
+
config.app_name = 'database_cleaner-nobrainer'
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'irb'
|
19
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './lib/database_cleaner/nobrainer/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'database_cleaner-nobrainer'
|
7
|
+
spec.version = DatabaseCleaner::Nobrainer::VERSION
|
8
|
+
spec.authors = ['Guillaume Hain']
|
9
|
+
spec.email = ['zedtux@zedroot.org']
|
10
|
+
|
11
|
+
spec.summary = 'Strategies for cleaning databases using Nobrainer.'
|
12
|
+
spec.description = 'Strategies for cleaning databases using Nobrainer. ' \
|
13
|
+
'Can be used to ensure a clean state for testing.'
|
14
|
+
spec.homepage = 'https://github.com/zedtux/database_cleaner-nobrainer'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^((test|spec|features)/|\.|[\w-]+.yml|Appraisals|(Docker|Earth)file)})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency 'database_cleaner-core', '~>2.0.0.beta2'
|
25
|
+
spec.add_dependency 'nobrainer', '~> 0.30'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'appraisal', '~> 2'
|
28
|
+
spec.add_development_dependency 'bundler', '~> 2'
|
29
|
+
spec.add_development_dependency 'rake', '~> 13'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3'
|
31
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gem 'byebug'
|
6
|
+
gem 'database_cleaner-core', git: 'https://github.com/DatabaseCleaner/database_cleaner'
|
7
|
+
gem 'nobrainer', '~> 0.34'
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem 'codecov', require: false
|
11
|
+
gem 'simplecov', require: false
|
12
|
+
end
|
13
|
+
|
14
|
+
gemspec path: '../'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'database_cleaner/strategy'
|
4
|
+
|
5
|
+
module DatabaseCleaner
|
6
|
+
module Nobrainer
|
7
|
+
class Deletion < Strategy
|
8
|
+
def initialize(only: [], except: [])
|
9
|
+
@only = only
|
10
|
+
@except = except
|
11
|
+
end
|
12
|
+
|
13
|
+
def clean
|
14
|
+
collections_to_delete.each do |table_name|
|
15
|
+
NoBrainer.run do |r|
|
16
|
+
if db == :default
|
17
|
+
r.table(table_name).delete
|
18
|
+
else
|
19
|
+
r.db(db).table(table_name).delete
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def collections
|
28
|
+
if db == :default
|
29
|
+
NoBrainer.run(&:table_list)
|
30
|
+
else
|
31
|
+
NoBrainer.run { |r| r.db(db).table_list }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def collections_to_delete
|
36
|
+
only = @only.any? ? @only : collections
|
37
|
+
only - @except
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: database_cleaner-nobrainer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guillaume Hain
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: database_cleaner-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.0.beta2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.0.beta2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nobrainer
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.30'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.30'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: appraisal
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '13'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '13'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3'
|
97
|
+
description: Strategies for cleaning databases using Nobrainer. Can be used to ensure
|
98
|
+
a clean state for testing.
|
99
|
+
email:
|
100
|
+
- zedtux@zedroot.org
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- Gemfile
|
106
|
+
- Gemfile.lock
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- bin/console
|
111
|
+
- bin/setup
|
112
|
+
- database_cleaner-nobrainer.gemspec
|
113
|
+
- gemfiles/.bundle/config
|
114
|
+
- gemfiles/nobrainer0.gemfile
|
115
|
+
- lib/database_cleaner-nobrainer.rb
|
116
|
+
- lib/database_cleaner/nobrainer.rb
|
117
|
+
- lib/database_cleaner/nobrainer/deletion.rb
|
118
|
+
- lib/database_cleaner/nobrainer/version.rb
|
119
|
+
homepage: https://github.com/zedtux/database_cleaner-nobrainer
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubygems_version: 3.1.4
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Strategies for cleaning databases using Nobrainer.
|
142
|
+
test_files: []
|