mongoid-collection-snapshot 1.3.2 → 1.3.3
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 +5 -5
- data/.github/workflows/test.yml +52 -0
- data/.rubocop_todo.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +6 -13
- data/README.md +7 -2
- data/RELEASING.md +32 -50
- data/lib/mongoid-collection-snapshot/version.rb +1 -1
- data/lib/mongoid-collection-snapshot.rb +4 -4
- data/spec/config/mongoid3.yml +2 -2
- data/spec/config/mongoid4.yml +2 -2
- data/spec/config/mongoid6.yml +2 -2
- data/spec/models/average_price.rb +2 -2
- data/spec/models/custom_connection_snapshot.rb +4 -4
- data/spec/models/multi_collection_snapshot.rb +1 -1
- data/spec/mongoid/collection_snapshot_spec.rb +8 -8
- data/spec/mongoid/multiple_databases_spec.rb +2 -2
- data/spec/spec_helper.rb +12 -3
- metadata +8 -9
- data/.travis.yml +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9456efe5e5e89a7ca629647b61ce24b9dda9973750e80f7b6cca89e6a5521351
|
|
4
|
+
data.tar.gz: 0643b4f5269d3ffc8ac3847bb01cb0fa8d45315c8aaebd7a97970d2c5fddc775
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 659f053c0fe149ad0c3f752559da9e5d592ae8949ac9d505209afe49030dc765278b281b4fcee360510a1d611438755a79b984d62bb01c6e59dcd0caa475cedf
|
|
7
|
+
data.tar.gz: b2e1d5175e0e8687381305550600e958b4afbb80f3b2e42a97ef439db27bac037e84efe6906c6330c27254885fdee6df995c4164a40308aa3c3cb41ff2aaaa05
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
permissions:
|
|
6
|
+
contents: read
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
name: Ruby ${{ matrix.ruby }} / Mongoid ${{ matrix.mongoid }} / MongoDB ${{ matrix.mongodb }}
|
|
11
|
+
runs-on: ubuntu-22.04
|
|
12
|
+
timeout-minutes: 15
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
include:
|
|
17
|
+
- { ruby: '2.1.9', mongoid: '3', mongodb: '2.6', bundler: '1.17.3' }
|
|
18
|
+
- { ruby: '2.3.8', mongoid: '4', mongodb: '2.6', bundler: '2.3.26' }
|
|
19
|
+
- { ruby: '2.3.8', mongoid: '5', mongodb: '4.0', bundler: '2.3.26' }
|
|
20
|
+
- { ruby: '2.5.9', mongoid: '6', mongodb: '4.0', bundler: '2.3.26' }
|
|
21
|
+
- { ruby: '2.7.8', mongoid: '7', mongodb: '4.4', bundler: '2.4.22' }
|
|
22
|
+
- { ruby: '3.2', mongoid: '8', mongodb: '6.0', bundler: default }
|
|
23
|
+
- { ruby: '3.3', mongoid: '9', mongodb: '7.0', bundler: default }
|
|
24
|
+
- { ruby: '3.4', mongoid: '9', mongodb: '8.0', bundler: default }
|
|
25
|
+
- { ruby: '4.0', mongoid: '9', mongodb: '8.0', bundler: default }
|
|
26
|
+
env:
|
|
27
|
+
MONGOID_VERSION: ${{ matrix.mongoid }}
|
|
28
|
+
COVERAGE: ${{ matrix.ruby == '4.0' && 'true' || 'false' }}
|
|
29
|
+
services:
|
|
30
|
+
mongodb:
|
|
31
|
+
image: mongo:${{ matrix.mongodb }}
|
|
32
|
+
ports: ['27017:27017']
|
|
33
|
+
options: >-
|
|
34
|
+
--health-cmd "bash -c 'echo > /dev/tcp/127.0.0.1/27017'"
|
|
35
|
+
--health-interval 5s --health-timeout 5s --health-retries 20
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v6
|
|
38
|
+
- uses: ruby/setup-ruby@v1
|
|
39
|
+
with:
|
|
40
|
+
ruby-version: ${{ matrix.ruby }}
|
|
41
|
+
bundler: ${{ matrix.bundler }}
|
|
42
|
+
bundler-cache: true
|
|
43
|
+
- run: bundle exec rake spec
|
|
44
|
+
- name: Report coverage to Coveralls
|
|
45
|
+
if: matrix.ruby == '4.0'
|
|
46
|
+
uses: coverallsapp/github-action@v2
|
|
47
|
+
with:
|
|
48
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
49
|
+
file: coverage/.resultset.json
|
|
50
|
+
format: simplecov
|
|
51
|
+
- if: matrix.mongoid == '6'
|
|
52
|
+
run: bundle exec rake rubocop
|
data/.rubocop_todo.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
### 1.3.3 (2026/10/14)
|
|
2
|
+
|
|
3
|
+
* [#17](https://github.com/mongoid/mongoid-collection-snapshot/pull/17): Generate real SimpleCov coverage in one modern CI job and report to Coveralls; scope CI and coverage badges to upstream master.
|
|
4
|
+
* [#17](https://github.com/mongoid/mongoid-collection-snapshot/pull/17): Modernize CI with GitHub Actions through Ruby 4.0, Mongoid 9, and MongoDB Server 8.0; use current Mongoid client and public snapshot storage APIs while retaining legacy coverage.
|
|
5
|
+
|
|
1
6
|
### 1.3.2 (6/4/2017)
|
|
2
7
|
|
|
3
8
|
* [#13](https://github.com/mongoid/mongoid-collection-snapshot/issues/13): Fix: use correct database on all threads - [@dblock](https://github.com/dblock).
|
data/Gemfile
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
source '
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
gem 'mongoid', '~> 5.0'
|
|
10
|
-
when /^4/
|
|
11
|
-
gem 'mongoid', '~> 4.0'
|
|
12
|
-
when /^3/
|
|
13
|
-
gem 'mongoid', '~> 3.1'
|
|
14
|
-
else
|
|
15
|
-
gem 'mongoid', version
|
|
16
|
-
end
|
|
5
|
+
version = ENV['MONGOID_VERSION'] || '9'
|
|
6
|
+
gem 'bigdecimal' if RUBY_VERSION >= '3.4'
|
|
7
|
+
gem 'logger' if RUBY_VERSION >= '3.4'
|
|
8
|
+
gem 'mongoid', version =~ /\A\d+\z/ ? "~> #{version}.0" : version
|
|
17
9
|
|
|
18
10
|
group :development, :test do
|
|
19
11
|
gem 'mongoid-danger', '~> 0.1.1'
|
|
20
12
|
gem 'rake'
|
|
21
13
|
gem 'rspec', '~> 3.1'
|
|
22
14
|
gem 'rubocop', '0.47.1'
|
|
15
|
+
gem 'simplecov', '~> 0.22' if ENV['COVERAGE'] == 'true'
|
|
23
16
|
gem 'timecop'
|
|
24
17
|
end
|
data/README.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
Mongoid Collection Snapshot
|
|
2
2
|
===========================
|
|
3
3
|
|
|
4
|
-
Easy maintenance of collections of processed data in MongoDB with Mongoid
|
|
4
|
+
Easy maintenance of collections of processed data in MongoDB with Mongoid.
|
|
5
5
|
|
|
6
6
|
This is a forked, renamed, maintained and supported version of [mongoid_collection_snapshot](https://github.com/aaw/mongoid_collection_snapshot).
|
|
7
7
|
|
|
8
8
|
[](https://badge.fury.io/rb/mongoid-collection-snapshot)
|
|
9
|
-
[](https://github.com/mongoid/mongoid-collection-snapshot/actions/workflows/test.yml?query=branch%3Amaster)
|
|
10
|
+
[](https://coveralls.io/github/mongoid/mongoid-collection-snapshot?branch=master)
|
|
11
|
+
|
|
12
|
+
The Ruby 4.0 CI job measures library line coverage with SimpleCov and submits `coverage/.resultset.json` to Coveralls using GitHub's automatic token. Other matrix jobs do not submit duplicate reports. Run `COVERAGE=true bundle install` followed by `COVERAGE=true bundle exec rake spec` for a local report. The default-branch badge requires Coveralls to accept an upstream `master` build; configuring this workflow does not activate the external service.
|
|
13
|
+
|
|
14
|
+
CI tests representative compatible combinations of Mongoid 3 through 9, Ruby 2.1 through 4.0, and MongoDB Server 2.6 through 8.0, including Ruby 4.0 / Mongoid 9 / MongoDB 8.0. See [the test matrix](.github/workflows/test.yml); this is not a Cartesian product of supported versions. Mongoid 3–4 use MongoDB 2.6 because their Moped driver enumerates collections via the removed `system.namespaces` collection. Set `MONGOID_VERSION` to select a Mongoid major version and `MONGODB_HOST` to override the default `localhost:27017` when running tests.
|
|
10
15
|
|
|
11
16
|
### Example
|
|
12
17
|
|
data/RELEASING.md
CHANGED
|
@@ -1,68 +1,50 @@
|
|
|
1
|
-
Releasing Mongoid
|
|
2
|
-
=====================================
|
|
1
|
+
# Releasing Mongoid Collection Snapshot
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Prepare
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Use the upstream checkout on clean `master`, verify `origin` points to `mongoid/mongoid-collection-snapshot`, and run `git pull --ff-only`. Check supported platforms in [GitHub Actions](https://github.com/mongoid/mongoid-collection-snapshot/actions). Choose a patch version for fixes, minor for backward-compatible features, or major for breaking changes.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Set `lib/mongoid-collection-snapshot/version.rb` to the release version. Date the matching changelog section using `YYYY/MM/DD` and remove its contribution placeholder.
|
|
9
8
|
|
|
10
|
-
```
|
|
9
|
+
```sh
|
|
11
10
|
bundle install
|
|
12
|
-
rake
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Check that the last build succeeded in [Travis CI](https://travis-ci.org/mongoid/mongoid-collection-snapshot) for all supported platforms.
|
|
16
|
-
|
|
17
|
-
Increment the version, modify [lib/mongoid/collection-snapshot/version.rb](lib/mongoid/collection-snapshot/version.rb).
|
|
18
|
-
|
|
19
|
-
* Increment the third number if the release has bug fixes and/or very minor features, only (eg. change `0.5.1` to `0.5.2`).
|
|
20
|
-
* Increment the second number if the release contains major features or breaking API changes (eg. change `0.5.1` to `0.4.0`).
|
|
21
|
-
|
|
22
|
-
Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
### 0.4.0 (2014-01-27)
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Remove the line with "Your contribution here.", since there will be no more contributions to this release.
|
|
29
|
-
|
|
30
|
-
Commit your changes.
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
git add CHANGELOG.md lib/mongoid-collection-snapshot/version.rb
|
|
34
|
-
git commit -m "Preparing for release, 0.4.0."
|
|
11
|
+
bundle exec rake
|
|
12
|
+
git add CHANGELOG.md lib/mongoid-collection-snapshot/version.rb RELEASING.md
|
|
13
|
+
git commit -m "Preparing for release, 1.3.3."
|
|
35
14
|
git push origin master
|
|
36
15
|
```
|
|
37
16
|
|
|
38
|
-
|
|
17
|
+
Wait for the preparation commit's CI checks to pass.
|
|
39
18
|
|
|
40
|
-
|
|
41
|
-
$ rake release
|
|
19
|
+
## Publish RubyGems and GitHub
|
|
42
20
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Pushed git commits and tags.
|
|
46
|
-
Pushed mongoid-collection-snapshot 0.4.0 to rubygems.org.
|
|
21
|
+
```sh
|
|
22
|
+
bundle exec rake release
|
|
47
23
|
```
|
|
48
24
|
|
|
49
|
-
|
|
25
|
+
Complete RubyGems MFA when prompted. This builds the package, pushes the tag, and publishes to RubyGems. If interrupted, inspect existing tags and the RubyGems version before retrying. Never move published tags; if only publication is missing, use `gem push pkg/mongoid-collection-snapshot-1.3.3.gem`.
|
|
50
26
|
|
|
51
|
-
|
|
27
|
+
A tag alone does not create a GitHub release. Once RubyGems publication is verified, publish a matching GitHub release with changelog notes:
|
|
52
28
|
|
|
29
|
+
```sh
|
|
30
|
+
version=1.3.3
|
|
31
|
+
notes="$(mktemp)"
|
|
32
|
+
awk -v version="$version" '
|
|
33
|
+
/^### / {
|
|
34
|
+
if (found) exit
|
|
35
|
+
if ($2 == version) found = 1
|
|
36
|
+
next
|
|
37
|
+
}
|
|
38
|
+
found { print }
|
|
39
|
+
' CHANGELOG.md > "$notes"
|
|
40
|
+
gh release create "v$version" --repo mongoid/mongoid-collection-snapshot --verify-tag --title "$version" --notes-file "$notes" --latest
|
|
41
|
+
rm "$notes"
|
|
42
|
+
curl --fail --silent --show-error "https://rubygems.org/api/v2/rubygems/mongoid-collection-snapshot/versions/$version.json"
|
|
43
|
+
gh release view "v$version" --repo mongoid/mongoid-collection-snapshot
|
|
53
44
|
```
|
|
54
|
-
Next Release
|
|
55
|
-
============
|
|
56
45
|
|
|
57
|
-
|
|
58
|
-
```
|
|
46
|
+
Verify both the published gem and non-draft GitHub release.
|
|
59
47
|
|
|
60
|
-
|
|
48
|
+
## Prepare the Next Version
|
|
61
49
|
|
|
62
|
-
Commit
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
git add CHANGELOG.md lib/mongoid-collection-snapshot/version.rb
|
|
66
|
-
git commit -m "Preparing for next release, 0.4.1."
|
|
67
|
-
git push origin master
|
|
68
|
-
```
|
|
50
|
+
Increment the development patch version in `lib/mongoid-collection-snapshot/version.rb` (for example, `1.3.4`). Add `### 1.3.4 (Next)` with a contribution placeholder above the released changelog section. Commit and push those changes to `master` without changing the release tag.
|
|
@@ -42,12 +42,12 @@ module Mongoid
|
|
|
42
42
|
end
|
|
43
43
|
instance_eval(&document_block) if document_block
|
|
44
44
|
end
|
|
45
|
-
if Mongoid::
|
|
45
|
+
if Mongoid::VERSION.to_i >= 6
|
|
46
46
|
# assign a name to the snapshot session
|
|
47
47
|
session_id = snapshot_session.object_id.to_s
|
|
48
48
|
Mongoid::Clients.set session_id, snapshot_session
|
|
49
49
|
# tell the class to use the client by name
|
|
50
|
-
klass.
|
|
50
|
+
klass.store_in client: session_id, collection: collection_name
|
|
51
51
|
elsif Mongoid::Compatibility::Version.mongoid5?
|
|
52
52
|
klass.store_in collection: collection_name
|
|
53
53
|
klass.mongo_client = snapshot_session
|
|
@@ -81,7 +81,7 @@ module Mongoid
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
def drop_snapshot_collections
|
|
84
|
-
collections = Mongoid::
|
|
84
|
+
collections = Mongoid::VERSION.to_i >= 5 ? snapshot_session.database.collections : snapshot_session.collections
|
|
85
85
|
collections.each do |collection|
|
|
86
86
|
collection.drop if collection.name =~ /^#{self.collection.name}\.([^\.]+\.)?#{slug}$/
|
|
87
87
|
end
|
|
@@ -100,7 +100,7 @@ module Mongoid
|
|
|
100
100
|
|
|
101
101
|
# Override to supply custom database connection for snapshots
|
|
102
102
|
def snapshot_session
|
|
103
|
-
Mongoid::
|
|
103
|
+
Mongoid::VERSION.to_i >= 5 ? Mongoid.default_client : Mongoid.default_session
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
end
|
data/spec/config/mongoid3.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
test:
|
|
2
2
|
sessions:
|
|
3
3
|
default:
|
|
4
|
-
uri: mongodb
|
|
4
|
+
uri: mongodb://<%= ENV.fetch('MONGODB_HOST', 'localhost:27017') %>/mongoid-collection-snapshot_test
|
|
5
5
|
imports:
|
|
6
|
-
uri: mongodb
|
|
6
|
+
uri: mongodb://<%= ENV.fetch('MONGODB_HOST', 'localhost:27017') %>/mongoid-collection-snapshot_test-imports
|
data/spec/config/mongoid4.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
test:
|
|
2
2
|
sessions:
|
|
3
3
|
default:
|
|
4
|
-
uri: mongodb
|
|
4
|
+
uri: mongodb://<%= ENV.fetch('MONGODB_HOST', 'localhost:27017') %>/mongoid-collection-snapshot_test
|
|
5
5
|
imports:
|
|
6
|
-
uri: mongodb
|
|
6
|
+
uri: mongodb://<%= ENV.fetch('MONGODB_HOST', 'localhost:27017') %>/mongoid-collection-snapshot_test-imports
|
data/spec/config/mongoid6.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
test:
|
|
2
2
|
clients:
|
|
3
3
|
default:
|
|
4
|
-
uri: mongodb
|
|
4
|
+
uri: mongodb://<%= ENV.fetch('MONGODB_HOST', 'localhost:27017') %>/mongoid-collection-snapshot_test
|
|
5
5
|
imports:
|
|
6
|
-
uri: mongodb
|
|
6
|
+
uri: mongodb://<%= ENV.fetch('MONGODB_HOST', 'localhost:27017') %>/mongoid-collection-snapshot_test-imports
|
|
@@ -29,7 +29,7 @@ class AverageArtistPrice < AveragePrice
|
|
|
29
29
|
EOS
|
|
30
30
|
|
|
31
31
|
Artwork.map_reduce(map, reduce).out(inline: 1).each do |doc|
|
|
32
|
-
if Mongoid::
|
|
32
|
+
if Mongoid::VERSION.to_i >= 5
|
|
33
33
|
collection_snapshot.insert_one(
|
|
34
34
|
artist_id: doc['_id']['artist_id'],
|
|
35
35
|
count: doc['value']['count'],
|
|
@@ -81,7 +81,7 @@ class AveragePartnerPrice < AveragePrice
|
|
|
81
81
|
EOS
|
|
82
82
|
|
|
83
83
|
Artwork.map_reduce(map, reduce).out(inline: 1).each do |doc|
|
|
84
|
-
if Mongoid::
|
|
84
|
+
if Mongoid::VERSION.to_i >= 5
|
|
85
85
|
collection_snapshot.insert_one(
|
|
86
86
|
partner_id: doc['_id']['partner_id'],
|
|
87
87
|
count: doc['value']['count'],
|
|
@@ -10,7 +10,7 @@ class CustomConnectionSnapshot
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def build
|
|
13
|
-
if Mongoid::
|
|
13
|
+
if Mongoid::VERSION.to_i >= 5
|
|
14
14
|
collection_snapshot.insert_one('name' => 'foo')
|
|
15
15
|
collection_snapshot('foo').insert_one('name' => 'bar')
|
|
16
16
|
else
|
|
@@ -22,10 +22,10 @@ class CustomConnectionSnapshot
|
|
|
22
22
|
private
|
|
23
23
|
|
|
24
24
|
def self.new_snapshot_session
|
|
25
|
-
if Mongoid::
|
|
26
|
-
Mongo::Client.new('
|
|
25
|
+
if Mongoid::VERSION.to_i >= 5
|
|
26
|
+
Mongo::Client.new("mongodb://#{ENV.fetch('MONGODB_HOST', 'localhost:27017')}/snapshot_test")
|
|
27
27
|
else
|
|
28
|
-
Moped::Session.new(['127.0.0.1:27017']).tap do |session|
|
|
28
|
+
Moped::Session.new([ENV.fetch('MONGODB_HOST', '127.0.0.1:27017')]).tap do |session|
|
|
29
29
|
session.use :snapshot_test
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -17,7 +17,7 @@ class MultiCollectionSnapshot
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def build
|
|
20
|
-
if Mongoid::
|
|
20
|
+
if Mongoid::VERSION.to_i >= 5
|
|
21
21
|
collection_snapshot('foo').insert_one('name' => 'foo!', count: 1)
|
|
22
22
|
collection_snapshot('bar').insert_one('name' => 'bar!', number: 2)
|
|
23
23
|
collection_snapshot('baz').insert_one('name' => 'baz!', digit: 3)
|
|
@@ -104,7 +104,7 @@ module Mongoid
|
|
|
104
104
|
|
|
105
105
|
it 'safely cleans up all collections used by the snapshot' do
|
|
106
106
|
# Create some collections with names close to the snapshots we'll create
|
|
107
|
-
if Mongoid::
|
|
107
|
+
if Mongoid::VERSION.to_i >= 5
|
|
108
108
|
Mongoid.default_client["#{MultiCollectionSnapshot.collection.name}.do.not_delete"].insert_one('a' => 1)
|
|
109
109
|
Mongoid.default_client["#{MultiCollectionSnapshot.collection.name}.snapshorty"].insert_one('a' => 1)
|
|
110
110
|
Mongoid.default_client["#{MultiCollectionSnapshot.collection.name}.hello.1"].insert_one('a' => 1)
|
|
@@ -115,19 +115,19 @@ module Mongoid
|
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
MultiCollectionSnapshot.create
|
|
118
|
-
collections = Mongoid::
|
|
118
|
+
collections = Mongoid::VERSION.to_i >= 5 ? Mongoid.default_client.database.collections : Mongoid.default_session.collections
|
|
119
119
|
before_create = collections.map(&:name)
|
|
120
120
|
expect(before_create.length).to be > 0
|
|
121
121
|
|
|
122
122
|
Timecop.travel(1.second.from_now)
|
|
123
123
|
MultiCollectionSnapshot.create
|
|
124
|
-
collections = Mongoid::
|
|
124
|
+
collections = Mongoid::VERSION.to_i >= 5 ? Mongoid.default_client.database.collections : Mongoid.default_session.collections
|
|
125
125
|
after_create = collections.map(&:name)
|
|
126
126
|
collections_created = (after_create - before_create).sort
|
|
127
127
|
expect(collections_created.length).to eq(3)
|
|
128
128
|
|
|
129
129
|
MultiCollectionSnapshot.latest.destroy
|
|
130
|
-
collections = Mongoid::
|
|
130
|
+
collections = Mongoid::VERSION.to_i >= 5 ? Mongoid.default_client.database.collections : Mongoid.default_session.collections
|
|
131
131
|
after_destroy = collections.map(&:name)
|
|
132
132
|
collections_destroyed = (after_create - after_destroy).sort
|
|
133
133
|
expect(collections_created).to eq(collections_destroyed)
|
|
@@ -136,13 +136,13 @@ module Mongoid
|
|
|
136
136
|
|
|
137
137
|
context 'with a custom snapshot connection' do
|
|
138
138
|
around(:each) do |example|
|
|
139
|
-
if Mongoid::
|
|
139
|
+
if Mongoid::VERSION.to_i >= 5
|
|
140
140
|
CustomConnectionSnapshot.snapshot_session.database.drop
|
|
141
141
|
else
|
|
142
142
|
CustomConnectionSnapshot.snapshot_session.drop
|
|
143
143
|
end
|
|
144
144
|
example.run
|
|
145
|
-
if Mongoid::
|
|
145
|
+
if Mongoid::VERSION.to_i >= 5
|
|
146
146
|
CustomConnectionSnapshot.snapshot_session.database.drop
|
|
147
147
|
else
|
|
148
148
|
CustomConnectionSnapshot.snapshot_session.drop
|
|
@@ -155,7 +155,7 @@ module Mongoid
|
|
|
155
155
|
"#{CustomConnectionSnapshot.collection.name}.foo.#{snapshot.slug}",
|
|
156
156
|
"#{CustomConnectionSnapshot.collection.name}.#{snapshot.slug}"
|
|
157
157
|
].each do |collection_name|
|
|
158
|
-
session = Mongoid::
|
|
158
|
+
session = Mongoid::VERSION.to_i >= 5 ? Mongoid.default_client : Mongoid.default_session
|
|
159
159
|
expect(session[collection_name].find.count).to eq(0)
|
|
160
160
|
expect(CustomConnectionSnapshot.snapshot_session[collection_name].find.count).to eq(1)
|
|
161
161
|
end
|
|
@@ -163,7 +163,7 @@ module Mongoid
|
|
|
163
163
|
|
|
164
164
|
context '#documents' do
|
|
165
165
|
it 'uses the custom session' do
|
|
166
|
-
if Mongoid::
|
|
166
|
+
if Mongoid::VERSION.to_i >= 5
|
|
167
167
|
expect(CustomConnectionSnapshot.new.documents.mongo_client).to eq CustomConnectionSnapshot.snapshot_session
|
|
168
168
|
else
|
|
169
169
|
expect(CustomConnectionSnapshot.new.documents.mongo_session).to eq CustomConnectionSnapshot.snapshot_session
|
|
@@ -20,7 +20,7 @@ class WidgetsAndGadgets
|
|
|
20
20
|
collection_snapshot.drop
|
|
21
21
|
Widget.all.each do |widget|
|
|
22
22
|
Gadget.all.each do |gadget|
|
|
23
|
-
if Mongoid::
|
|
23
|
+
if Mongoid::VERSION.to_i >= 5
|
|
24
24
|
collection_snapshot.insert_one(widget_id: widget.id, gadget_id: gadget.id)
|
|
25
25
|
else
|
|
26
26
|
collection_snapshot.insert(widget_id: widget.id, gadget_id: gadget.id)
|
|
@@ -30,7 +30,7 @@ class WidgetsAndGadgets
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def snapshot_session
|
|
33
|
-
if Mongoid::
|
|
33
|
+
if Mongoid::VERSION.to_i >= 5
|
|
34
34
|
Mongoid.client('imports')
|
|
35
35
|
else
|
|
36
36
|
Mongoid.session('imports')
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
if ENV['COVERAGE'] == 'true'
|
|
2
|
+
require 'simplecov'
|
|
3
|
+
SimpleCov.start do
|
|
4
|
+
track_files 'lib/**/*.rb'
|
|
5
|
+
add_filter '/spec/'
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
1
9
|
require 'rubygems'
|
|
2
10
|
require 'bundler/setup'
|
|
3
11
|
require 'rspec'
|
|
@@ -5,7 +13,8 @@ require 'rspec'
|
|
|
5
13
|
require 'mongoid'
|
|
6
14
|
require 'timecop'
|
|
7
15
|
|
|
8
|
-
Mongoid.
|
|
16
|
+
config_version = [Mongoid::VERSION.to_i, 6].min
|
|
17
|
+
Mongoid.load!("#{File.dirname(__FILE__)}/config/mongoid#{config_version}.yml", :test)
|
|
9
18
|
|
|
10
19
|
require File.expand_path('../../lib/mongoid-collection-snapshot', __FILE__)
|
|
11
20
|
Dir["#{File.dirname(__FILE__)}/models/**/*.rb"].each { |f| require f }
|
|
@@ -15,13 +24,13 @@ require 'mongoid-compatibility'
|
|
|
15
24
|
RSpec.configure do |c|
|
|
16
25
|
c.before(:all) do
|
|
17
26
|
Mongoid.logger.level = Logger::INFO
|
|
18
|
-
Mongo::Logger.logger.level = Logger::INFO if Mongoid::
|
|
27
|
+
Mongo::Logger.logger.level = Logger::INFO if Mongoid::VERSION.to_i >= 5
|
|
19
28
|
end
|
|
20
29
|
c.before(:each) do
|
|
21
30
|
Mongoid.purge!
|
|
22
31
|
end
|
|
23
32
|
c.after(:all) do
|
|
24
|
-
if Mongoid::
|
|
33
|
+
if Mongoid::VERSION.to_i >= 5
|
|
25
34
|
Mongoid.default_client.database.drop
|
|
26
35
|
else
|
|
27
36
|
Mongoid.default_session.drop
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongoid-collection-snapshot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aaron Windsor
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-10-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mongoid
|
|
@@ -52,17 +52,17 @@ dependencies:
|
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
|
-
description:
|
|
55
|
+
description:
|
|
56
56
|
email: aaron.windsor@gmail.com
|
|
57
57
|
executables: []
|
|
58
58
|
extensions: []
|
|
59
59
|
extra_rdoc_files: []
|
|
60
60
|
files:
|
|
61
|
+
- ".github/workflows/test.yml"
|
|
61
62
|
- ".gitignore"
|
|
62
63
|
- ".rspec"
|
|
63
64
|
- ".rubocop.yml"
|
|
64
65
|
- ".rubocop_todo.yml"
|
|
65
|
-
- ".travis.yml"
|
|
66
66
|
- CHANGELOG.md
|
|
67
67
|
- Dangerfile
|
|
68
68
|
- Gemfile
|
|
@@ -97,7 +97,7 @@ homepage: http://github.com/mongoid/mongoid-collection-snapshot
|
|
|
97
97
|
licenses:
|
|
98
98
|
- MIT
|
|
99
99
|
metadata: {}
|
|
100
|
-
post_install_message:
|
|
100
|
+
post_install_message:
|
|
101
101
|
rdoc_options: []
|
|
102
102
|
require_paths:
|
|
103
103
|
- lib
|
|
@@ -112,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
112
112
|
- !ruby/object:Gem::Version
|
|
113
113
|
version: 1.3.6
|
|
114
114
|
requirements: []
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
signing_key:
|
|
115
|
+
rubygems_version: 3.5.16
|
|
116
|
+
signing_key:
|
|
118
117
|
specification_version: 4
|
|
119
118
|
summary: Easy maintenence of collections of processed data in MongoDB with the Mongoid
|
|
120
119
|
ODM.
|
data/.travis.yml
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
sudo: false
|
|
2
|
-
|
|
3
|
-
matrix:
|
|
4
|
-
include:
|
|
5
|
-
- rvm: 2.3.1
|
|
6
|
-
env:
|
|
7
|
-
- MONGOID_VERSION=6
|
|
8
|
-
before_script:
|
|
9
|
-
- bundle exec danger
|
|
10
|
-
- rvm: 2.3.1
|
|
11
|
-
env:
|
|
12
|
-
- MONGOID_VERSION=5
|
|
13
|
-
- rvm: 2.2
|
|
14
|
-
env:
|
|
15
|
-
- MONGOID_VERSION=4
|
|
16
|
-
- rvm: 2.1
|
|
17
|
-
env:
|
|
18
|
-
- MONGOID_VERSION=3
|
|
19
|
-
|
|
20
|
-
services: mongodb
|
|
21
|
-
|
|
22
|
-
addons:
|
|
23
|
-
apt:
|
|
24
|
-
sources:
|
|
25
|
-
- mongodb-3.2-precise
|
|
26
|
-
packages:
|
|
27
|
-
- mongodb-org-server
|