mongoid_orderable 6.0.7 → 6.0.8

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: c7c9edf55be552b8dfa6fdfa8a11df19801f66696361d567fda9e645d8736674
4
- data.tar.gz: 579bfbee824451e8d58ca9bddde51bd95b2cb103571c22a9dc6beb045da3af14
3
+ metadata.gz: 426b10ca2d6e73ff7502ef65ec4c4370d58fc82e695f3b6d12a9468185b54ab7
4
+ data.tar.gz: 0def8544900272000caf8a1e7c99aee9805a0963a885b4940e5c94a1164d2460
5
5
  SHA512:
6
- metadata.gz: 1a8f4c43964e53a772900978f5a0155ea53bfeffc0cf2775bc10a6db086073adbe855b0bced555abbf4b2a5808c1a92753acaed853783b67ece7f8b2d1520802
7
- data.tar.gz: d6cb3996dd6577d5cf52eb8fb487fbcb9fffbd5f708074cf1e0e2185e0a44394eb8c23260f019a30802ad79d0d4623c8fa7a30ec82781d6e378d2810e1d5135e
6
+ metadata.gz: 541b75725c985f24d4ac168306a2f4f8fd2e295a3e471860df2295500414cfbb1441da94f794e5544fc11e4342cdc3ed6afa1cc7080e4575cad89f7da0742695
7
+ data.tar.gz: 22ad56900543a8b8b83381e265359e99bd75c276c66340ad53640eaaad63df080f4a83ca797b3cc562476a5d181887cbfc2daa77935b4f7a95ac180d5a2f86ff
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 6.0.8 (2026/11/24)
2
+
3
+ * [#94](https://github.com/mongoid/mongoid_orderable/pull/94): Lint Markdown, YAML, and spelling with rubocop-md, rubocop-prose, rubocop-spellcheck, and rubocop-yaml in a separate Lint workflow, and clean up documentation - [@dblock](https://github.com/dblock).
4
+ * [#95](https://github.com/mongoid/mongoid_orderable/pull/95): Run CI pushes only on the default branch, cancel superseded pull request runs, skip duplicate lint in the test matrix, and bound job times - [@dblock](https://github.com/dblock).
5
+ * [#96](https://github.com/mongoid/mongoid_orderable/pull/96): Release with ruby-gem-release from a manually dispatched GitHub Actions workflow using RubyGems Trusted Publishing, with dry runs - [@dblock](https://github.com/dblock).
6
+
1
7
  ### 6.0.7 (2026/10/18)
2
8
 
3
9
  * [#92](https://github.com/mongoid/mongoid_orderable/pull/92): Fix direct position assignment for embedded documents while retaining the movement API, based on regression tests by [@johnnyshields](https://github.com/johnnyshields) - [@dblock](https://github.com/dblock).
data/README.md CHANGED
@@ -1,14 +1,10 @@
1
- [![Gem Version](https://badge.fury.io/rb/mongoid_orderable.svg)](https://badge.fury.io/rb/mongoid_orderable)
2
- [![Test](https://github.com/mongoid/mongoid_orderable/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/mongoid/mongoid_orderable/actions/workflows/test.yml?query=branch%3Amaster)
3
- [![Coverage Status](https://coveralls.io/repos/github/mongoid/mongoid_orderable/badge.svg?branch=master)](https://coveralls.io/github/mongoid/mongoid_orderable?branch=master)
4
-
5
1
  # Mongoid Orderable
6
2
 
7
- The Ruby 4.0 CI job measures all library files with SimpleCov and submits `coverage/.resultset.json` through the official Coveralls action using GitHub's automatic token. Other matrix jobs do not upload duplicate reports. Run `COVERAGE=true bundle install` and `COVERAGE=true bundle exec rake spec` to measure coverage locally. An accepted upstream default-branch build is required for the badge; this workflow alone does not activate the external service.
3
+ [![Gem Version](https://badge.fury.io/rb/mongoid_orderable.svg)](https://badge.fury.io/rb/mongoid_orderable) [![Test](https://github.com/mongoid/mongoid_orderable/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/mongoid/mongoid_orderable/actions/workflows/test.yml?query=branch%3Amaster) [![Coverage Status](https://coveralls.io/repos/github/mongoid/mongoid_orderable/badge.svg?branch=master)](https://coveralls.io/github/mongoid/mongoid_orderable?branch=master)
8
4
 
9
- Mongoid::Orderable is a ordered list implementation for your Mongoid 7+ projects.
5
+ Mongoid::Orderable is an ordered list implementation for your Mongoid 7+ projects.
10
6
 
11
- ### Core Features
7
+ ## Core Features
12
8
 
13
9
  * Sets a position index field on your documents which allows you to sort them in order.
14
10
  * Uses MongoDB's `$inc` operator to batch-update position.
@@ -28,6 +24,14 @@ For older versions, please use Mongoid::Orderable 5.x and earlier.
28
24
 
29
25
  Transaction support requires MongoDB 4.2+ (4.4+ recommended.)
30
26
 
27
+ ## Installation
28
+
29
+ Add the gem to your Gemfile and run `bundle install`.
30
+
31
+ ```ruby
32
+ gem 'mongoid_orderable'
33
+ ```
34
+
31
35
  ## Usage
32
36
 
33
37
  See [UPGRADING](UPGRADING.md) for migration notes, including embedded position assignment changes in 6.0.7.
@@ -38,8 +42,7 @@ See [UPGRADING](UPGRADING.md) for migration notes, including embedded position a
38
42
  gem 'mongoid_orderable'
39
43
  ```
40
44
 
41
- Include `Mongoid::Orderable` into your model and call `orderable` method.
42
- Embedded objects are automatically scoped to their parent.
45
+ Include `Mongoid::Orderable` into your model and call `orderable` method. Embedded objects are automatically scoped to their parent.
43
46
 
44
47
  ```ruby
45
48
  class MyModel
@@ -47,8 +50,8 @@ class MyModel
47
50
  include Mongoid::Orderable
48
51
 
49
52
  belongs_to :group
50
- belongs_to :drawer, class_name: "Office::Drawer",
51
- foreign_key: "legacy_drawer_key_id"
53
+ belongs_to :drawer, class_name: 'Office::Drawer',
54
+ foreign_key: 'legacy_drawer_key_id'
52
55
 
53
56
  orderable
54
57
 
@@ -62,15 +65,14 @@ class MyModel
62
65
  orderable scope: ->(doc) { where(group_id: doc.group_id) }
63
66
 
64
67
  # this one if you want specify indexes manually
65
- orderable index: false
68
+ orderable index: false
66
69
 
67
70
  # count position from zero as the top-most value (1 is the default value)
68
71
  orderable base: 0
69
72
  end
70
73
  ```
71
74
 
72
- You can also set default config values in an initializer, which will be
73
- applied when calling the `orderable` macro in a model.
75
+ You can also set default config values in an initializer, which will be applied when calling the `orderable` macro in a model.
74
76
 
75
77
  ```ruby
76
78
  # configs/initializers/mongoid_orderable.rb
@@ -121,43 +123,41 @@ class Book
121
123
  end
122
124
  ```
123
125
 
124
- The above defines two different orderable_fields on Book - *position* and *serial_no*.
125
- The following helpers are generated in this case:
126
+ The above defines two different orderable_fields on Book - *position* and *serial_no*. The following helpers are generated in this case:
126
127
 
127
128
  ```ruby
128
- book.move_#{field}_to
129
- book.move_#{field}_to=
130
- book.move_#{field}_to!
129
+ book.move_ #{field}_to
130
+ book.move_ #{field}_to=
131
+ book.move_ #{field}_to!
131
132
 
132
- book.move_#{field}_to_top
133
- book.move_#{field}_to_bottom
134
- book.move_#{field}_higher
135
- book.move_#{field}_lower
133
+ book.move_ #{field}_to_top
134
+ book.move_ #{field}_to_bottom
135
+ book.move_ #{field}_higher
136
+ book.move_ #{field}_lower
136
137
 
137
- book.next_#{field}_items
138
- book.previous_#{field}_items
138
+ book.next_ #{field}_items
139
+ book.previous_ #{field}_items
139
140
 
140
- book.next_#{field}_item
141
- book.previous_#{field}_item
141
+ book.next_ #{field}_item
142
+ book.previous_ #{field}_item
142
143
  ```
143
144
 
144
145
  where `#{field}` is either `position` or `serial_no`.
145
146
 
146
- When a model defines multiple orderable fields, the original helpers are also available and work
147
- on the first orderable field.
147
+ When a model defines multiple orderable fields, the original helpers are also available and work on the first orderable field.
148
148
 
149
149
  ```ruby
150
- @book1 = Book.create!
151
- @book2 = Book.create!
152
- @book2 # => <Book _id: 53a16a2ba1bde4f746000001, serial_no: 1, position: 1>
153
- @book2.move_to! :top # this will change the :position of the book to 0 (not serial_no)
154
- @book2 # => <Book _id: 53a16a2ba1bde4f746000001, serial_no: 1, position: 0>
150
+ @book1 = Book.create!
151
+ @book2 = Book.create!
152
+ @book2 # => <Book _id: 53a16a2ba1bde4f746000001, serial_no: 1, position: 1>
153
+ @book2.move_to! :top # this will change the :position of the book to 0 (not serial_no)
154
+ @book2 # => <Book _id: 53a16a2ba1bde4f746000001, serial_no: 1, position: 0>
155
155
  ```
156
156
 
157
157
  To specify any other orderable field as default pass the **default: true** option with orderable.
158
158
 
159
159
  ```ruby
160
- orderable field: sno, as: :serial_no, default: true
160
+ orderable field: sno, as: :serial_no, default: true
161
161
  ```
162
162
 
163
163
  ### Embedded Documents
@@ -173,8 +173,7 @@ class Question
173
173
  end
174
174
  ```
175
175
 
176
- If you bulk import embedded documents without specifying their position,
177
- no field `position` will be written.
176
+ If you bulk import embedded documents without specifying their position, no field `position` will be written.
178
177
 
179
178
  ```ruby
180
179
  class Survey
@@ -184,8 +183,7 @@ class Survey
184
183
  end
185
184
  ```
186
185
 
187
- To ensure the position is written correctly, you will need to set
188
- `cascade_callbacks: true` on the relation.
186
+ To ensure the position is written correctly, you will need to set `cascade_callbacks: true` on the relation.
189
187
 
190
188
  Assigning an embedded document's position reorders its siblings when either the child or its parent is saved:
191
189
 
@@ -205,10 +203,7 @@ This changes the previous behavior where assigning an existing embedded child's
205
203
 
206
204
  ### Disable Ordering
207
205
 
208
- You can disable position tracking for specific documents using the `:if` and `:unless` options.
209
- This is in advanced scenarios where you want to control position manually for certain documents.
210
- In general, the disable condition should match a specific scope.
211
- **Warning:** If used improperly, this will cause your documents to become out-of-order.
206
+ You can disable position tracking for specific documents using the `:if` and `:unless` options. This is in advanced scenarios where you want to control position manually for certain documents. In general, the disable condition should match a specific scope. **Warning:** If used improperly, this will cause your documents to become out-of-order.
212
207
 
213
208
  ```ruby
214
209
  class Book
@@ -216,19 +211,14 @@ class Book
216
211
  include Mongoid::Orderable
217
212
 
218
213
  field :track_position, type: Boolean
219
-
214
+
220
215
  orderable if: :track_position, unless: -> { created_at < Date.parse('2020-01-01') }
221
216
  end
222
217
  ```
223
218
 
224
219
  ## Transaction Support
225
220
 
226
- By default, Mongoid Orderable does not guarantee ordering consistency
227
- when doing multiple concurrent updates on documents. This means that
228
- instead of having positions `1, 2, 3, 4, 5`, after running your system
229
- in production at scale your position data will become corrupted, e.g.
230
- `1, 1, 4, 4, 6`. To remedy this, this Mongoid Orderable can use
231
- [MongoDB transactions](https://docs.mongodb.com/manual/core/transactions/)
221
+ By default, Mongoid Orderable does not guarantee ordering consistency when doing multiple concurrent updates on documents. This means that instead of having positions `1, 2, 3, 4, 5`, after running your system in production at scale your position data will become corrupted, e.g. `1, 1, 4, 4, 6`. To remedy this, this Mongoid Orderable can use [MongoDB transactions](https://docs.mongodb.com/manual/core/transactions/)
232
222
 
233
223
  ### Prerequisites
234
224
 
@@ -250,34 +240,27 @@ class MyModel
250
240
  end
251
241
  ```
252
242
 
253
- When two transactions are attempted at the same time, database-level
254
- `WriteConflict` failures may result and retries will be attempted.
255
- After `transaction_max_retries` has been exceeded, a
256
- `Mongoid::Orderable::Errors::TransactionFailed` error will be raised.
243
+ When two transactions are attempted at the same time, database-level `WriteConflict` failures may result and retries will be attempted. After `transaction_max_retries` has been exceeded, a `Mongoid::Orderable::Errors::TransactionFailed` error will be raised.
257
244
 
258
245
  ### Locks
259
246
 
260
- When using transactions, Mongoid Orderable creates a collection
261
- `mongoid_orderable_locks` which is used to store temporary lock objects.
262
- Lock collections use a TTL index which auto-deletes objects older than 1 day.
247
+ When using transactions, Mongoid Orderable creates a collection `mongoid_orderable_locks` which is used to store temporary lock objects. Lock collections use a TTL index which auto-deletes objects older than 1 day.
263
248
 
264
249
  You can change the lock collection name globally or per model:
265
250
 
266
251
  ```ruby
267
252
  Mongoid::Orderable.configure do |config|
268
- config.lock_collection = "my_locks" # default: "mongoid_orderable_locks"
253
+ config.lock_collection = 'my_locks' # default: "mongoid_orderable_locks"
269
254
  end
270
255
 
271
256
  class MyModel
272
- orderable :position, lock_collection: "my_model_locks"
257
+ orderable :position, lock_collection: 'my_model_locks'
273
258
  end
274
259
  ```
275
260
 
276
261
  ### MongoDB 4.2 Support
277
262
 
278
- In MongoDB 4.2, collections cannot be created within transactions.
279
- Therefore, you will need to manually run the following command once
280
- to initialize the lock collection:
263
+ In MongoDB 4.2, collections cannot be created within transactions. Therefore, you will need to manually run the following command once to initialize the lock collection:
281
264
 
282
265
  ```ruby
283
266
  Mongoid::Orderable::Models::Lock.create!
@@ -285,12 +268,12 @@ Mongoid::Orderable::Models::Lock.create!
285
268
 
286
269
  This step is not necessary when using MongoDB 4.4+.
287
270
 
288
- ### Contributing
271
+ ## Contributing
289
272
 
290
- Please fork the project on Github and raise a pull request including passing specs.
273
+ See [CONTRIBUTING.md](CONTRIBUTING.md), [CHANGELOG.md](CHANGELOG.md), [UPGRADING.md](UPGRADING.md), and [RELEASING.md](RELEASING.md).
291
274
 
292
- ### Copyright & License
275
+ ## Copyright & License
293
276
 
294
277
  Copyright (c) 2011 Arkadiy Zabazhanov, Johnny Shields, and contributors.
295
278
 
296
- MIT license, see [LICENSE](LICENSE.txt) for details.
279
+ MIT license, see [LICENSE.txt](LICENSE.txt) for details.
data/Rakefile CHANGED
@@ -12,13 +12,32 @@ end
12
12
 
13
13
  Bundler::GemHelper.install_tasks
14
14
 
15
+ if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
16
+ Gem.loaded_specs.key?('ruby-gem-release')
17
+ require_relative 'script/release'
18
+ MongoidOrderableRelease.workflow.install_tasks
19
+
20
+ %w[release release:rubygem_push release:source_control_push].each do |name|
21
+ Rake::Task[name].clear
22
+ desc 'Disabled; releases run through GitHub Actions, see RELEASING.md'
23
+ task(name) { abort "#{name} is disabled; releases run through GitHub Actions, see RELEASING.md" }
24
+ end
25
+ end
26
+
15
27
  require 'rspec/core'
16
28
  require 'rspec/core/rake_task'
17
29
  RSpec::Core::RakeTask.new(:spec) do |spec|
18
30
  spec.pattern = FileList['spec/**/*_spec.rb']
19
31
  end
20
32
 
21
- require 'rubocop/rake_task'
22
- RuboCop::RakeTask.new(:rubocop)
33
+ lint = RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
34
+ Gem.loaded_specs.key?('rubocop')
35
+ if lint
36
+ require 'rubocop/rake_task'
37
+ RuboCop::RakeTask.new(:rubocop)
38
+
39
+ desc 'Lint Ruby, Markdown, YAML, and spelling'
40
+ task lint: :rubocop
41
+ end
23
42
 
24
- task default: %i[rubocop spec]
43
+ task default: lint ? %i[rubocop spec] : %i[spec]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mongoid
4
4
  module Orderable
5
- VERSION = '6.0.7'
5
+ VERSION = '6.0.8'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_orderable
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.7
4
+ version: 6.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - pyromaniac
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-18 00:00:00.000000000 Z
11
+ date: 2026-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubygems_version: 3.5.16
84
+ rubygems_version: 3.5.22
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Mongoid orderable list implementation