mongoid-locker 2.0.2 → 2.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81cc5f3f7114bc807ad56afade38745fb74d2d4ed45eb007a12b0e61a0237450
4
- data.tar.gz: 81ba6e72064c31a302ffcbfd0a6df6c555051057d2b8890b696ef3b62d033baa
3
+ metadata.gz: 4b26398184af745151395ab8ed2a865222ef35772acfa0844d9b471c6221ffa4
4
+ data.tar.gz: e67a619634f8ec9c43f040d4cc5c91117ea26f577ff7654de2255a18672065b7
5
5
  SHA512:
6
- metadata.gz: 75b674da45761991d07da697139454f53864327d9b3f0a73b20e5d5a278f1faabce95430c3cfc7e06ff2597a5be4acccb4c714b66d2ec17b0b93ef270c934a5e
7
- data.tar.gz: 402ab3c14985c52c65b4440c7b763d8b59ccf1f9e33cd97b7324f237353443edd96e9134031ee15735213ed1d19cf8865151f05a0e32dd12d8ce43f3c3e4f04e
6
+ metadata.gz: 7e37f059d72651fd282665d1e23dce67d1e2a6a92873dbc5d51a1b47520368c1c63eeaec3d5230a931e206f81b8e3d979eda9ce912bcf0f16d40f2fc95c30891
7
+ data.tar.gz: e1afb2032299e1ddf2c00d2ea834cf1014d30959b1f6b58e71b8262687b33977204fd191c8baa551a352234b593146ae80978544cce5431e7775ece125cf3e37
@@ -0,0 +1,17 @@
1
+ name: Danger
2
+ on: [pull_request]
3
+ jobs:
4
+ danger:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v3
8
+ with:
9
+ fetch-depth: 0
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ ruby-version: 2.7
13
+ bundler-cache: true
14
+ - run: |
15
+ # Personal access token for dangerpr-bot - public, but base64 encoded to avoid tripping up GitHub
16
+ TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
17
+ DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
@@ -0,0 +1,13 @@
1
+ name: Rubocop
2
+ on: [push, pull_request]
3
+ jobs:
4
+ lint:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v3
8
+ - name: Set up Ruby
9
+ uses: ruby/setup-ruby@v1
10
+ with:
11
+ ruby-version: 2.7
12
+ bundler-cache: true
13
+ - run: bundle exec rubocop
@@ -10,22 +10,24 @@ jobs:
10
10
  matrix:
11
11
  entry:
12
12
  - { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '5' }
13
- - { ruby: 'jruby-9.1.17.0', mongo: 'mongo:4.4', mongoid: '5' }
14
- - { ruby: 'jruby-9.2.11.1', mongo: 'mongo:4.4', mongoid: '5' }
13
+ # - { ruby: 'jruby-9.1.17.0', mongo: 'mongo:4.4', mongoid: '5' }
14
+ - { ruby: 'jruby-9.4.13.0', mongo: 'mongo:4.4', mongoid: '5' }
15
15
  - { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '6' }
16
16
  - { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '6' }
17
17
  - { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '6' }
18
18
  - { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '6' }
19
- - { ruby: 'jruby-9.2.11.1', mongo: 'mongo:4.4', mongoid: '6' }
19
+ - { ruby: 'jruby-9.4.13.0', mongo: 'mongo:4.4', mongoid: '6' }
20
20
  - { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '7', coverage: 'true' }
21
21
  - { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '7' }
22
22
  - { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '7' }
23
23
  - { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '7' }
24
- - { ruby: 'jruby-9.2.11.1', mongo: 'mongo:4.4', mongoid: '7' }
25
- - { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '8' }
26
- - { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '8' }
27
- - { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '8' }
28
- - { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '8' }
24
+ # - { ruby: 'jruby-9.4.13.0', mongo: 'mongo:4.4', mongoid: '7' }
25
+ - { ruby: '2.6.6', mongo: 'mongo:6.0', mongoid: '8' }
26
+ - { ruby: '2.7.1', mongo: 'mongo:7.0', mongoid: '8' }
27
+ - { ruby: '3.0.5', mongo: 'mongo:6.0', mongoid: '8' }
28
+ - { ruby: '3.1.3', mongo: 'mongo:7.0', mongoid: '8' }
29
+ - { ruby: '3.1.3', mongo: 'mongo:8.0', mongoid: '9' }
30
+ # - { ruby: 'jruby-9.4.13.0', mongo: 'mongo:8.0', mongoid: '8' }
29
31
  experimental: [false]
30
32
 
31
33
  name: test (ruby=${{ matrix.entry.ruby }}, mongo=${{ matrix.entry.mongo }}, mongoid=${{ matrix.entry.mongoid }})
@@ -43,7 +45,7 @@ jobs:
43
45
  COVERAGE: ${{ matrix.entry.coverage }}
44
46
 
45
47
  steps:
46
- - uses: actions/checkout@v2
48
+ - uses: actions/checkout@v3
47
49
 
48
50
  - name: Set up Ruby
49
51
  uses: ruby/setup-ruby@v1
@@ -51,21 +53,11 @@ jobs:
51
53
  ruby-version: ${{ matrix.entry.ruby }}
52
54
  bundler-cache: true
53
55
 
54
- - name: Checks
55
- if: ${{ matrix.entry.coverage == 'true' }}
56
- run: |
57
- bundle exec rubocop
58
- # Disabled until mongoid-danger is updated to support Github Actions
59
- # bundle exec danger
60
-
61
56
  - name: Run tests
62
57
  run: bundle exec rspec
63
58
 
64
59
  - name: Code Climate
65
60
  if: ${{ env.CC_TEST_REPORTER_ID != '' && success() && matrix.entry.coverage == 'true' }}
66
- run: |
67
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter;
68
- chmod +x ./cc-test-reporter;
69
- ./cc-test-reporter before-build;
70
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.json coverage/.resultset.json;
71
- ./cc-test-reporter upload-coverage;
61
+ uses: paambaati/codeclimate-action@v3.2.0
62
+ env:
63
+ CC_TEST_REPORTER_ID: ${{ vars.CC_TEST_REPORTER_ID }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.2.0 (2025-06-22)
4
+
5
+ * [#107](https://github.com/mongoid/mongoid-locker/pull/107): Revert introduction of `forwardable` to ensure compatibility with mongoid-history - [@scpike](https://github.com/scpike).
6
+
7
+ ### 2.1.0 (2024-05-07)
8
+
9
+ * [#101](https://github.com/mongoid/mongoid-locker/pull/101): Replace the $where operator with the $expr operator - [@amanfrinati](https://github.com/amanfrinati).
10
+ * [#102](https://github.com/mongoid/mongoid-locker/pull/102): Re-added danger, removed Travis-CI config, extracted RuboCop - [@dblock](https://github.com/dblock).
11
+ * [#104](https://github.com/mongoid/mongoid-locker/pull/104): Fixed code coverage - [@dblock](https://github.com/dblock).
12
+ * [#105](https://github.com/mongoid/mongoid-locker/pull/105): Added support for Mongoid 9.0 - [@saisrinivasan](https://github.com/SairamSrinivasan).
13
+
3
14
  ### 2.0.2 (2023-01-24)
4
15
 
5
16
  * [#92](https://github.com/mongoid/mongoid-locker/pull/92): Removed TTL and updated unique index definitions - [@cesarizu](https://github.com/cesarizu).
data/Gemfile CHANGED
@@ -4,6 +4,8 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  case ENV['MONGOID_VERSION']
7
+ when /^9/
8
+ gem 'mongoid', '~> 9.0'
7
9
  when /^8/
8
10
  gem 'mongoid', '~> 8.0'
9
11
  when /^7/
@@ -26,7 +28,8 @@ group :development, :test do
26
28
  gem 'pry-byebug', platforms: :mri
27
29
 
28
30
  gem 'mongoid-compatibility'
29
- gem 'mongoid-danger', '~> 0.1.1'
31
+ gem 'mongoid-danger', '~> 0.2.0'
32
+ gem 'mongoid-history'
30
33
  gem 'rspec', '~> 3.9'
31
34
  gem 'rubocop', '0.81.0'
32
35
  gem 'rubocop-rspec', '1.38.1'
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Mongoid-Locker
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/mongoid-locker.svg)](https://badge.fury.io/rb/mongoid-locker)
4
- [![Test Status](https://github.com/mongoid/mongoid-locker/workflows/Test/badge.svg)](https://github.com/mongoid/mongoid-locker/actions)
5
- [![Build Status](https://travis-ci.org/mongoid/mongoid-locker.svg?branch=master)](https://travis-ci.org/mongoid/mongoid-locker)
4
+ [![Test](https://github.com/mongoid/mongoid-locker/actions/workflows/test.yml/badge.svg)](https://github.com/mongoid/mongoid-locker/actions/workflows/test.yml)
6
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/04ee4ee75ff54659300a/maintainability)](https://codeclimate.com/github/mongoid/mongoid-locker/maintainability)
7
6
  [![Test Coverage](https://api.codeclimate.com/v1/badges/04ee4ee75ff54659300a/test_coverage)](https://codeclimate.com/github/mongoid/mongoid-locker/test_coverage)
8
7
 
@@ -15,7 +14,7 @@ Document-level optimistic locking for MongoDB via Mongoid. Mongoid-Locker is an
15
14
  [Tested](https://github.com/mongoid/mongoid-locker/actions) against:
16
15
  - MRI: `2.3.8`, `2.4.7`, `2.5.7`, `2.6.6`, `2.7.1`, `3.0.5`, `3.1.3`
17
16
  - JRuby `9.1.17.0`, `9.2.11.1`
18
- - Mongoid: `5`, `6`, `7`, `8`
17
+ - Mongoid: `5`, `6`, `7`, `8`, `9`
19
18
 
20
19
  See [.github/workflows/test.yml](.github/workflows/test.yml) for the latest test matrix.
21
20
 
data/RELEASING.md CHANGED
@@ -48,17 +48,16 @@ Pushed mongoid-locker 0.4.0 to rubygems.org.
48
48
 
49
49
  ### Prepare for the Next Version
50
50
 
51
+ Increment the minor version, modify [lib/mongoid-locker/version.rb](lib/mongoid-locker/version.rb).
52
+
51
53
  Add the next release to [CHANGELOG.md](CHANGELOG.md).
52
54
 
53
55
  ```
54
- Next Release
55
- ============
56
+ ### 0.4.1 (Next)
56
57
 
57
58
  * Your contribution here.
58
59
  ```
59
60
 
60
- Increment the minor version, modify [lib/mongoid-locker/version.rb](lib/mongoid-locker/version.rb).
61
-
62
61
  Commit your changes.
63
62
 
64
63
  ```
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mongoid
4
4
  module Locker
5
- VERSION = '2.0.2'
5
+ VERSION = '2.2.0'
6
6
  end
7
7
  end
@@ -36,7 +36,7 @@ module Mongoid
36
36
  ]
37
37
  },
38
38
  {
39
- '$where': "new Date() - this.#{model.locked_at_field} >= #{model.lock_timeout * 1000}"
39
+ '$expr': { '$gte': ['$$NOW', { '$add': ["$#{model.locked_at_field}", model.lock_timeout * 1000] }] } # The expr means "Time.now.utc >= model.locked_at_field + model.lock_timeout * 1000"
40
40
  }
41
41
  ]
42
42
  }
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'forwardable'
4
3
  require 'securerandom'
5
4
 
6
5
  module Mongoid
@@ -104,8 +103,6 @@ module Mongoid
104
103
 
105
104
  # @api private
106
105
  def included(klass)
107
- klass.extend(Forwardable) unless klass.ancestors.include?(Forwardable)
108
-
109
106
  klass.extend ClassMethods
110
107
  klass.singleton_class.instance_eval { attr_accessor(*MODULE_METHODS) }
111
108
 
@@ -117,7 +114,7 @@ module Mongoid
117
114
  klass.backoff_algorithm = backoff_algorithm
118
115
  klass.locking_name_generator = locking_name_generator
119
116
 
120
- klass.def_delegators(klass, *MODULE_METHODS)
117
+ klass.delegate(*MODULE_METHODS, to: :class)
121
118
  klass.singleton_class.delegate(*(methods(false) - MODULE_METHODS.flat_map { |method| [method, "#{method}=".to_sym] } - %i[included reset! configure]), to: self)
122
119
  end
123
120
  end
@@ -18,5 +18,5 @@ Gem::Specification.new do |s|
18
18
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
19
19
  s.require_paths = ['lib']
20
20
 
21
- s.add_dependency 'mongoid', '>= 5.0', '< 9'
21
+ s.add_dependency 'mongoid', '>= 5.0', '< 10'
22
22
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-locker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aidan Feldman
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-01-24 00:00:00.000000000 Z
10
+ date: 2025-06-22 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: mongoid
@@ -19,7 +18,7 @@ dependencies:
19
18
  version: '5.0'
20
19
  - - "<"
21
20
  - !ruby/object:Gem::Version
22
- version: '9'
21
+ version: '10'
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +28,7 @@ dependencies:
29
28
  version: '5.0'
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
- version: '9'
31
+ version: '10'
33
32
  description: Allows multiple processes to operate on individual documents in MongoDB
34
33
  while ensuring that only one can act at a time.
35
34
  email:
@@ -38,12 +37,13 @@ executables: []
38
37
  extensions: []
39
38
  extra_rdoc_files: []
40
39
  files:
40
+ - ".github/workflows/danger.yml"
41
+ - ".github/workflows/rubocop.yml"
41
42
  - ".github/workflows/test.yml"
42
43
  - ".gitignore"
43
44
  - ".rspec"
44
45
  - ".rubocop.yml"
45
46
  - ".rubocop_todo.yml"
46
- - ".travis.yml"
47
47
  - CHANGELOG.md
48
48
  - CONTRIBUTING.md
49
49
  - Dangerfile
@@ -65,7 +65,6 @@ homepage: https://github.com/mongoid/mongoid-locker
65
65
  licenses:
66
66
  - MIT
67
67
  metadata: {}
68
- post_install_message:
69
68
  rdoc_options: []
70
69
  require_paths:
71
70
  - lib
@@ -80,8 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
79
  - !ruby/object:Gem::Version
81
80
  version: '0'
82
81
  requirements: []
83
- rubygems_version: 3.0.9
84
- signing_key:
82
+ rubygems_version: 3.6.2
85
83
  specification_version: 4
86
84
  summary: Document-level optimistic locking for MongoDB via Mongoid.
87
85
  test_files: []
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- language: ruby
2
-
3
- cache: bundler
4
-
5
- rvm:
6
- - 2.6.6
7
-
8
- env:
9
- - MONGOID_VERSION=7
10
-
11
- before_script:
12
- - bundle exec danger
13
-
14
- script:
15
- - echo SKIP
16
-