database_cleaner-mongoid 1.8.0.beta

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 42f573b6d1ad54dad4747857410039caf173a9826c77a949ea61a47d48ba76ae
4
+ data.tar.gz: d0e8eef92565dad0954b0b114d961331fa5d77130022af5e0f028a21ef563546
5
+ SHA512:
6
+ metadata.gz: c84e375598cd092541bce2e6ee774062ff35200789edd072efbbcebb52a9f85944b387b2360d01570c3463b0a2952177b9c7838c10622159744a0e703c250223
7
+ data.tar.gz: 787fb4e84d3ced0897d0c6d85674025065d73a84c032e72ccf295e75fd8f790da500af4f3587d727b4a87d8303dc2d2273247795e91b77dbdb5b786a42b60241
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.9
5
+ before_install: gem install bundler -v 1.17.2
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in database_cleaner-mongoid.gemspec
6
+ gemspec
7
+
8
+ gem "database_cleaner", path: "../.."
9
+ gem "database_cleaner-mongo", path: ".."
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ database_cleaner (1.8.0.beta)
5
+
6
+ PATH
7
+ remote: ..
8
+ specs:
9
+ database_cleaner-mongo (1.8.0.beta)
10
+ database_cleaner (~> 1.8.0.beta)
11
+ mongo
12
+
13
+ PATH
14
+ remote: .
15
+ specs:
16
+ database_cleaner-mongoid (1.8.0.beta)
17
+ database_cleaner (~> 1.8.0.beta)
18
+ database_cleaner-mongo (~> 1.8.0.beta)
19
+ mongoid
20
+
21
+ GEM
22
+ remote: https://rubygems.org/
23
+ specs:
24
+ activemodel (5.2.4.1)
25
+ activesupport (= 5.2.4.1)
26
+ activesupport (5.2.4.1)
27
+ concurrent-ruby (~> 1.0, >= 1.0.2)
28
+ i18n (>= 0.7, < 2)
29
+ minitest (~> 5.1)
30
+ tzinfo (~> 1.1)
31
+ bson (4.5.0)
32
+ concurrent-ruby (1.1.5)
33
+ diff-lcs (1.3)
34
+ i18n (1.5.1)
35
+ concurrent-ruby (~> 1.0)
36
+ minitest (5.14.0)
37
+ mongo (2.10.2)
38
+ bson (>= 4.4.2, < 5.0.0)
39
+ mongoid (7.0.5)
40
+ activemodel (>= 5.1, < 6.1)
41
+ mongo (>= 2.5.1, < 3.0.0)
42
+ rake (10.4.2)
43
+ rspec (3.7.0)
44
+ rspec-core (~> 3.7.0)
45
+ rspec-expectations (~> 3.7.0)
46
+ rspec-mocks (~> 3.7.0)
47
+ rspec-core (3.7.1)
48
+ rspec-support (~> 3.7.0)
49
+ rspec-expectations (3.7.0)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.7.0)
52
+ rspec-mocks (3.7.0)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.7.0)
55
+ rspec-support (3.7.1)
56
+ thread_safe (0.3.6)
57
+ tzinfo (1.2.6)
58
+ thread_safe (~> 0.1)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ bundler (~> 1.16)
65
+ database_cleaner!
66
+ database_cleaner-mongo!
67
+ database_cleaner-mongoid!
68
+ rake (~> 10.0)
69
+ rspec (~> 3.0)
70
+
71
+ BUNDLED WITH
72
+ 1.17.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2009 Ben Mabey
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.
@@ -0,0 +1,57 @@
1
+ # Database Cleaner Adapter for Mongoid
2
+
3
+ [![Build Status](https://travis-ci.org/DatabaseCleaner/database_cleaner-mongoid.svg?branch=master)](https://travis-ci.org/DatabaseCleaner/database_cleaner-mongoid)
4
+ [![Code Climate](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-mongoid/badges/gpa.svg)](https://codeclimate.com/github/DatabaseCleaner/database_cleaner-mongoid)
5
+
6
+ Clean your Mongoid databases with Database Cleaner.
7
+
8
+ See https://github.com/DatabaseCleaner/database_cleaner for more information.
9
+
10
+ ## Installation
11
+
12
+ ```ruby
13
+ # Gemfile
14
+ group :test do
15
+ gem 'database_cleaner-mongoid'
16
+ end
17
+ ```
18
+
19
+ ## Supported Strategies
20
+
21
+ <table>
22
+ <tbody>
23
+ <tr>
24
+ <th>Truncation</th>
25
+ <th>Transaction</th>
26
+ <th>Deletion</th>
27
+ </tr>
28
+ <tr>
29
+ <td> <b>Yes</b></td>
30
+ <td> No</td>
31
+ <td> No</td>
32
+ </tr>
33
+ </tbody>
34
+ </table>
35
+
36
+ (Default strategy is denoted in bold)
37
+
38
+ ## Configuration options
39
+
40
+ <table>
41
+ <tbody>
42
+ <tr>
43
+ <th>ORM</th>
44
+ <th>How to access</th>
45
+ <th>Notes</th>
46
+ </tr>
47
+ <tr>
48
+ <td> Mongoid</td>
49
+ <td> <code>DatabaseCleaner[:mongoid]</code></td>
50
+ <td> Multiple databases supported for Mongoid 3. Specify <code>DatabaseCleaner[:mongoid, {:connection =&gt; :db_name}]</code> </td>
51
+ </tr>
52
+ </tbody>
53
+ </table>
54
+
55
+ ## COPYRIGHT
56
+
57
+ See [LICENSE] for details.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "database_cleaner/mongoid"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle check || bundle install
7
+
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "database_cleaner/mongoid/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "database_cleaner-mongoid"
8
+ spec.version = DatabaseCleaner::Mongoid::VERSION
9
+ spec.authors = ["Ernesto Tagwerker"]
10
+ spec.email = ["ernesto@ombulabs.com"]
11
+
12
+ spec.summary = "Strategies for cleaning databases using Mongoid. Can be used to ensure a clean state for testing."
13
+ spec.description = "Strategies for cleaning databases using Mongoid. Can be used to ensure a clean state for testing."
14
+ spec.homepage = "https://github.com/DatabaseCleaner/database_cleaner-mongoid"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
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", "~> 1.8.0.beta"
25
+ spec.add_dependency "database_cleaner-mongo", "~> 1.8.0.beta"
26
+ spec.add_dependency "mongoid"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.16"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ end
@@ -0,0 +1 @@
1
+ require "database_cleaner/mongoid"
@@ -0,0 +1,39 @@
1
+ module DatabaseCleaner
2
+ module Mongo2
3
+ module TruncationMixin
4
+
5
+ def clean
6
+ if @only
7
+ collections.each { |c| database[c].find.delete_many if @only.include?(c) }
8
+ else
9
+ collections.each { |c| database[c].find.delete_many unless @tables_to_exclude.include?(c) }
10
+ end
11
+ true
12
+ end
13
+
14
+ private
15
+
16
+ def database
17
+ if @db.nil? || @db == :default
18
+ ::Mongoid::Clients.default
19
+ else
20
+ ::Mongoid::Clients.with_name(@db)
21
+ end
22
+ end
23
+
24
+ def collections
25
+ if db != :default
26
+ database.use(db)
27
+ end
28
+
29
+ database.collections.collect { |c| c.namespace.split('.',2)[1] }
30
+
31
+ # database['system.namespaces'].find(:name => { '$not' => /\.system\.|\$/ }).to_a.map do |collection|
32
+ # _, name = collection['name'].split('.', 2)
33
+ # name
34
+ # end
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,10 @@
1
+ require "database_cleaner/mongoid/version"
2
+ require "database_cleaner"
3
+ require "database_cleaner/mongoid/truncation"
4
+
5
+ module DatabaseCleaner::Mongoid
6
+ def self.default_strategy
7
+ :truncation
8
+ end
9
+ end
10
+
@@ -0,0 +1,20 @@
1
+ require 'database_cleaner/generic/base'
2
+ module DatabaseCleaner
3
+ module Mongoid
4
+ def self.available_strategies
5
+ %w[truncation]
6
+ end
7
+
8
+ module Base
9
+ include ::DatabaseCleaner::Generic::Base
10
+
11
+ def db=(desired_db)
12
+ @db = desired_db
13
+ end
14
+
15
+ def db
16
+ @db || :default
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,49 @@
1
+ require 'database_cleaner/mongoid/base'
2
+ require 'database_cleaner/generic/truncation'
3
+ require 'database_cleaner/mongo/truncation_mixin'
4
+ require 'database_cleaner/mongo2/truncation_mixin'
5
+ require 'database_cleaner/moped/truncation_base'
6
+ require 'mongoid/version'
7
+
8
+ module DatabaseCleaner
9
+ module Mongoid
10
+ class Truncation
11
+ include ::DatabaseCleaner::Mongoid::Base
12
+ include ::DatabaseCleaner::Generic::Truncation
13
+
14
+ if ::Mongoid::VERSION < '3'
15
+
16
+ include ::DatabaseCleaner::Mongo::TruncationMixin
17
+
18
+ private
19
+
20
+ def database
21
+ ::Mongoid.database
22
+ end
23
+
24
+ elsif ::Mongoid::VERSION < '5'
25
+
26
+ include ::DatabaseCleaner::Moped::TruncationBase
27
+
28
+ private
29
+
30
+ def session
31
+ ::Mongoid::VERSION > "5.0.0" ? ::Mongoid.default_client : ::Mongoid.default_session
32
+ end
33
+
34
+ def database
35
+ if not(@db.nil? or @db == :default)
36
+ ::Mongoid.databases[@db]
37
+ else
38
+ ::Mongoid.database
39
+ end
40
+ end
41
+
42
+ else
43
+
44
+ include ::DatabaseCleaner::Mongo2::TruncationMixin
45
+
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ module DatabaseCleaner
2
+ module Mongoid
3
+ VERSION = "1.8.0.beta"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: database_cleaner-mongoid
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.8.0.beta
5
+ platform: ruby
6
+ authors:
7
+ - Ernesto Tagwerker
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: database_cleaner
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.0.beta
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.0.beta
27
+ - !ruby/object:Gem::Dependency
28
+ name: database_cleaner-mongo
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.0.beta
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.8.0.beta
41
+ - !ruby/object:Gem::Dependency
42
+ name: mongoid
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
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.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description: Strategies for cleaning databases using Mongoid. Can be used to ensure
98
+ a clean state for testing.
99
+ email:
100
+ - ernesto@ombulabs.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - Gemfile.lock
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - database_cleaner-mongoid.gemspec
116
+ - lib/database_cleaner-mongoid.rb
117
+ - lib/database_cleaner/mongo2/truncation_mixin.rb
118
+ - lib/database_cleaner/mongoid.rb
119
+ - lib/database_cleaner/mongoid/base.rb
120
+ - lib/database_cleaner/mongoid/truncation.rb
121
+ - lib/database_cleaner/mongoid/version.rb
122
+ homepage: https://github.com/DatabaseCleaner/database_cleaner-mongoid
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">"
138
+ - !ruby/object:Gem::Version
139
+ version: 1.3.1
140
+ requirements: []
141
+ rubygems_version: 3.0.4
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Strategies for cleaning databases using Mongoid. Can be used to ensure a
145
+ clean state for testing.
146
+ test_files: []