mongoid-scroll 2.0.1 → 2.0.2

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: d9e2af0b05c25202ce0f2c1e87b760a0d41c7f534c0675f90a513e249949b503
4
- data.tar.gz: 83b648b0c1c8073ef6cf3dccdaa071051784f95b6db85ecddc079e30706e512a
3
+ metadata.gz: e6197cf4a7430e02680d6ea821c851567c3ee5b9c29f6f18eb1d684ac56cc41d
4
+ data.tar.gz: e60dd59aff6fe452a9e145fc923a251fc3a9225606bda945d555bda3ca5612c8
5
5
  SHA512:
6
- metadata.gz: 9582fb4fb8da92db5d65fbb076578bb0ff732e2073c7e0f1c095deee6fe399939712917752ac4f656ea81937f986d0475d622f3193fbeef56f35a1e4b306cc53
7
- data.tar.gz: a245b4f08c1546e92b9ed1bc8d260391a935ad3d2079f5d7eaa8effe0954da187b1cf6f12846bc9aefe05a4e2475aeda4fc952ef611e209e3a637ce99d0bf908
6
+ metadata.gz: e9902bab49e9e7da556679dd112d5d0ab4eddc36b6cb7dc199cdcba9c11f5dfd04047d6ede773a6c2765b9c5ab4eef22dc3db7edf2d1cdd2df8aef1f72b3da86
7
+ data.tar.gz: 160fca2875437d4c2dda8d440b0c31edd70b1a401bdfa29c3326c2dd7ea636245bbb5bf5428c7c9ff211ba1e936d1d7e7fa5aadebdfde2c94eebe1d1761e719c
@@ -1,9 +1,16 @@
1
1
  name: CI
2
- on: [push, pull_request]
2
+ on:
3
+ push:
4
+ branches: [master]
5
+ pull_request:
6
+ concurrency:
7
+ group: ${{ github.workflow }}-${{ github.ref }}
8
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
3
9
 
4
10
  jobs:
5
11
  test:
6
12
  runs-on: ubuntu-latest
13
+ timeout-minutes: 20
7
14
  strategy:
8
15
  fail-fast: false
9
16
  matrix:
@@ -22,7 +29,7 @@ jobs:
22
29
  - { ruby: '3.3', mongodb: '7.0', mongoid: '9' }
23
30
  - { ruby: '3.4', mongodb: '8.0', mongoid: '9' }
24
31
  - { ruby: '4.0', mongodb: '8.0', mongoid: '9', coverage: 'true' }
25
- name: test (ruby=${{ matrix.entry.ruby }}, mongodb=${{ matrix.entry.mongodb }}), mongoid=${{ matrix.entry.mongoid }})
32
+ name: test (ruby=${{ matrix.entry.ruby }}, mongodb=${{ matrix.entry.mongodb }}, mongoid=${{ matrix.entry.mongoid }})
26
33
  env:
27
34
  MONGOID_VERSION: ${{ matrix.entry.mongoid }}
28
35
  COVERAGE: ${{ matrix.entry.coverage }}
@@ -31,7 +38,8 @@ jobs:
31
38
  image: mongo:${{ matrix.entry.mongodb }}
32
39
  ports: ['27017:27017']
33
40
  options: >-
34
- --health-cmd "mongosh --quiet --eval 'db.adminCommand({ping: 1})' || mongo --quiet --eval 'db.adminCommand({ping: 1})'"
41
+ --health-cmd "mongosh --quiet --eval 'db.adminCommand({ping: 1})' ||
42
+ mongo --quiet --eval 'db.adminCommand({ping: 1})'"
35
43
  --health-interval 10s
36
44
  --health-timeout 5s
37
45
  --health-retries 10
@@ -1,9 +1,20 @@
1
1
  name: Danger Comment
2
+
2
3
  on:
3
4
  workflow_run:
4
5
  workflows: [Danger]
5
6
  types: [completed]
7
+
8
+ permissions:
9
+ actions: read
10
+ issues: write
11
+ pull-requests: write
12
+
6
13
  jobs:
7
14
  comment:
8
- uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.0
9
- secrets: inherit
15
+ name: Post Review Comment
16
+ # danger/danger-pr-comment v0.3.0
17
+ uses: danger/danger-pr-comment/.github/workflows/danger-comment.yml@645e89bcc7be89ee7e8362166110b05cbced8e59
18
+ with:
19
+ base-branch: '*'
20
+ comment-empty: false
@@ -1,11 +1,21 @@
1
1
  name: Danger
2
+
2
3
  on:
3
4
  pull_request:
4
5
  types: [opened, reopened, edited, synchronize]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
5
14
  jobs:
6
15
  danger:
7
- uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.1.0
16
+ name: Review Pull Request
17
+ # danger/danger-pr-comment v0.3.0
18
+ uses: danger/danger-pr-comment/.github/workflows/danger-run.yml@645e89bcc7be89ee7e8362166110b05cbced8e59
8
19
  with:
9
20
  ruby-version: '3.4'
10
21
  bundler-cache: true
11
- secrets: inherit
@@ -0,0 +1,29 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: ${{ github.workflow }}-${{ github.ref }}
10
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ lint:
17
+ name: Lint Code and Documentation
18
+ runs-on: ubuntu-latest
19
+ timeout-minutes: 10
20
+ steps:
21
+ - name: Check Out Code
22
+ uses: actions/checkout@v7
23
+ - name: Set Up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: '4.0'
27
+ bundler-cache: true
28
+ - name: Run Lint
29
+ run: bundle exec rake lint
@@ -0,0 +1,30 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: Optional release version overriding the checked-in version.
8
+ type: string
9
+ required: false
10
+ dry-run:
11
+ description: Check release prerequisites, such as RubyGems Trusted Publishing, without releasing.
12
+ type: boolean
13
+ default: false
14
+
15
+ permissions:
16
+ contents: write
17
+ id-token: write
18
+
19
+ jobs:
20
+ release:
21
+ if: github.repository == 'mongoid/mongoid-scroll' && github.ref == 'refs/heads/master'
22
+ uses: dblock/ruby-gem-release/.github/workflows/release.yml@v0.9.0
23
+ with:
24
+ ruby-version: '3.3'
25
+ version: ${{ inputs.version }}
26
+ dry-run: ${{ inputs.dry-run }}
27
+ test: |
28
+ docker run --detach --name mongodb --publish 27017:27017 mongo:8.0
29
+ until docker exec mongodb mongosh --quiet --eval 'db.adminCommand({ping: 1})'; do sleep 1; done
30
+ bundle exec rake
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  coverage
6
+ /vendor/bundle
data/.rubocop.yml CHANGED
@@ -1,11 +1,127 @@
1
- inherit_from: .rubocop_todo.yml
1
+ plugins:
2
+ - rubocop-md
3
+ - rubocop-prose
4
+ - rubocop-rake
5
+ - rubocop-rspec
6
+ - rubocop-spellcheck
7
+ - rubocop-yaml
2
8
 
3
- require:
4
- - rubocop-rake
5
- - rubocop-rspec
9
+ inherit_from: ".rubocop_todo.yml"
6
10
 
7
11
  AllCops:
8
12
  NewCops: enable
9
13
  Exclude:
10
- - vendor/**/*
11
- - gemfiles/vendor/**/*
14
+ - vendor/**/*
15
+ - gemfiles/vendor/**/*
16
+ - coverage/**/*
17
+ - pkg/**/*
18
+ SuggestExtensions: false
19
+ inherit_mode:
20
+ merge:
21
+ - Include
22
+ Include:
23
+ - ".github/**/*.yml"
24
+ - ".rubocop.yml"
25
+
26
+ YAML/Lint/InvalidSyntax:
27
+ Include:
28
+ - "**/*.yml"
29
+ - "**/*.yaml"
30
+
31
+ YAML/Lint/DuplicateKey:
32
+ Include:
33
+ - "**/*.yml"
34
+ - "**/*.yaml"
35
+
36
+ Naming/FileName:
37
+ inherit_mode:
38
+ merge:
39
+ - Exclude
40
+ Exclude:
41
+ - "**/*.md"
42
+ - ".github/workflows/*.yml"
43
+ - lib/mongoid-scroll.rb
44
+
45
+ Style/OneClassPerFile:
46
+ inherit_mode:
47
+ merge:
48
+ - Exclude
49
+ Exclude:
50
+ - "**/*.md"
51
+
52
+ Markdown/HeadingCapitalization:
53
+ Enabled: true
54
+ Style: title_case
55
+
56
+ Prose/MaxLength:
57
+ Max: false
58
+ Exclude:
59
+ - LICENSE.md
60
+
61
+ Spellcheck:
62
+ DictionaryFiles:
63
+ en:
64
+ - gem:rubocop-spellcheck/data/en/en.dic
65
+ - ".spellcheck.txt"
66
+
67
+ Spellcheck/Spelling:
68
+ Exclude:
69
+ - LICENSE.md
70
+
71
+ Style/Documentation:
72
+ inherit_mode:
73
+ merge:
74
+ - Exclude
75
+ Exclude:
76
+ - "**/*.md"
77
+
78
+ Lint/UselessAssignment:
79
+ inherit_mode:
80
+ merge:
81
+ - Exclude
82
+ Exclude:
83
+ - "**/*.md"
84
+
85
+ Style/MultilineBlockChain:
86
+ inherit_mode:
87
+ merge:
88
+ - Exclude
89
+ Exclude:
90
+ - "**/*.md"
91
+
92
+ Style/SymbolProc:
93
+ inherit_mode:
94
+ merge:
95
+ - Exclude
96
+ Exclude:
97
+ - "**/*.md"
98
+
99
+ Lint/Void:
100
+ inherit_mode:
101
+ merge:
102
+ - Exclude
103
+ Exclude:
104
+ - "**/*.md"
105
+
106
+ # One release example verifies the tag, the next development commit, and their files together.
107
+ RSpec/MultipleExpectations:
108
+ inherit_mode:
109
+ merge:
110
+ - Exclude
111
+ Exclude:
112
+ - spec/release/release_spec.rb
113
+
114
+ RSpec/ExampleLength:
115
+ inherit_mode:
116
+ merge:
117
+ - Exclude
118
+ Exclude:
119
+ - spec/release/release_spec.rb
120
+
121
+ # Gemfile groups are declarative and grow with the dependency list.
122
+ Metrics/BlockLength:
123
+ inherit_mode:
124
+ merge:
125
+ - Exclude
126
+ Exclude:
127
+ - Gemfile
data/.rubocop_todo.yml CHANGED
@@ -1,67 +1,74 @@
1
1
  # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2024-09-07 13:11:15 UTC using RuboCop version 1.66.1.
2
+ # `rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
3
+ # using RuboCop version 1.92.3.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
10
- # Configuration parameters: Severity, Include.
11
- # Include: **/*.gemspec
12
9
  Gemspec/RequiredRubyVersion:
13
10
  Exclude:
14
11
  - 'mongoid-scroll.gemspec'
15
12
 
16
- # Offense count: 1
13
+ # This cop supports safe autocorrection (--autocorrect).
14
+ Layout/EmptyLinesAfterModuleInclusion:
15
+ Exclude:
16
+ - 'examples/feed.rb'
17
+
17
18
  # This cop supports unsafe autocorrection (--autocorrect-all).
18
19
  Lint/NonDeterministicRequireOrder:
19
20
  Exclude:
20
21
  - 'spec/spec_helper.rb'
21
22
 
22
- # Offense count: 7
23
- # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
23
+ # This cop supports safe autocorrection (--autocorrect).
24
+ Lint/UselessAssignment:
25
+ Exclude:
26
+ - 'spec/mongoid/criteria_spec.rb'
27
+
28
+ Lint/UselessConstantScoping:
29
+ Exclude:
30
+ - 'lib/mongoid/scroll/errors/base.rb'
31
+
32
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
24
33
  Metrics/AbcSize:
25
- Max: 28
34
+ Exclude:
35
+ - 'lib/mongoid/criteria/scrollable.rb'
36
+ - 'lib/mongoid/scroll/base64_encoded_cursor.rb'
37
+ - 'lib/mongoid/scroll/base_cursor.rb'
38
+ - 'lib/mongoid/scroll/cursor.rb'
26
39
 
27
- # Offense count: 1
28
- # Configuration parameters: CountComments, CountAsOne.
40
+ # Configuration parameters: CountComments, Max, CountAsOne.
29
41
  Metrics/ClassLength:
30
- Max: 108
42
+ Exclude:
43
+ - 'lib/mongoid/scroll/base_cursor.rb'
31
44
 
32
- # Offense count: 5
33
- # Configuration parameters: AllowedMethods, AllowedPatterns.
45
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
34
46
  Metrics/CyclomaticComplexity:
35
- Max: 13
47
+ Exclude:
48
+ - 'lib/mongoid/criteria/scrollable.rb'
49
+ - 'lib/mongoid/scroll/base_cursor.rb'
36
50
 
37
- # Offense count: 7
38
- # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
51
+ # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
39
52
  Metrics/MethodLength:
40
- Max: 24
53
+ Exclude:
54
+ - 'lib/mongoid/criteria/scrollable.rb'
55
+ - 'lib/mongoid/scroll/base64_encoded_cursor.rb'
56
+ - 'lib/mongoid/scroll/base_cursor.rb'
57
+ - 'lib/mongoid/scroll/cursor.rb'
41
58
 
42
- # Offense count: 3
43
- # Configuration parameters: AllowedMethods, AllowedPatterns.
59
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
44
60
  Metrics/PerceivedComplexity:
45
- Max: 13
46
-
47
- # Offense count: 1
48
- # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
49
- # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
50
- # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
51
- Naming/FileName:
52
61
  Exclude:
53
- - 'Rakefile.rb'
54
- - 'lib/mongoid-scroll.rb'
62
+ - 'lib/mongoid/criteria/scrollable.rb'
63
+ - 'lib/mongoid/scroll/base_cursor.rb'
55
64
 
56
- # Offense count: 3
57
65
  # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
58
66
  # SupportedStyles: snake_case, normalcase, non_integer
59
- # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
67
+ # AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
60
68
  Naming/VariableNumber:
61
69
  Exclude:
62
70
  - 'spec/mongoid/criteria_spec.rb'
63
71
 
64
- # Offense count: 34
65
72
  # Configuration parameters: Prefixes, AllowedPatterns.
66
73
  # Prefixes: when, with, without
67
74
  RSpec/ContextWording:
@@ -70,7 +77,6 @@ RSpec/ContextWording:
70
77
  - 'spec/mongoid/criteria_spec.rb'
71
78
  - 'spec/mongoid/cursor_spec.rb'
72
79
 
73
- # Offense count: 34
74
80
  # This cop supports unsafe autocorrection (--autocorrect-all).
75
81
  # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
76
82
  # SupportedStyles: described_class, explicit
@@ -79,78 +85,65 @@ RSpec/DescribedClass:
79
85
  - 'spec/mongoid/base64_encoded_cursor_spec.rb'
80
86
  - 'spec/mongoid/cursor_spec.rb'
81
87
 
82
- # Offense count: 17
83
- # Configuration parameters: CountAsOne.
88
+ # Configuration parameters: Max, CountAsOne.
84
89
  RSpec/ExampleLength:
85
- Max: 18
90
+ Exclude:
91
+ - 'spec/mongoid/criteria_spec.rb'
92
+ - 'spec/mongoid/cursor_spec.rb'
93
+ - 'spec/mongoid/scroll/base_cursor_spec.rb'
86
94
 
87
- # Offense count: 3
88
95
  # Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
89
96
  RSpec/IndexedLet:
90
97
  Exclude:
91
98
  - 'spec/mongoid/criteria_spec.rb'
92
99
 
93
- # Offense count: 2
94
100
  # Configuration parameters: AssignmentOnly.
95
101
  RSpec/InstanceVariable:
96
102
  Exclude:
97
103
  - 'spec/mongoid/criteria_spec.rb'
98
104
 
99
- # Offense count: 11
105
+ # Configuration parameters: Max.
100
106
  RSpec/MultipleExpectations:
101
- Max: 4
107
+ Exclude:
108
+ - 'spec/mongoid/criteria_spec.rb'
109
+ - 'spec/mongoid/scroll/base_cursor_spec.rb'
102
110
 
103
- # Offense count: 4
104
111
  # Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
105
112
  # SupportedStyles: always, named_only
106
113
  RSpec/NamedSubject:
107
114
  Exclude:
108
115
  - 'spec/mongoid/criteria_spec.rb'
109
116
 
110
- # Offense count: 3
111
- # Configuration parameters: AllowedGroups.
117
+ # Configuration parameters: Max, AllowedGroups.
112
118
  RSpec/NestedGroups:
113
- Max: 4
119
+ Exclude:
120
+ - 'spec/mongoid/criteria_spec.rb'
114
121
 
115
- # Offense count: 3
116
122
  # Configuration parameters: AllowedPatterns.
117
123
  # AllowedPatterns: ^expect_, ^assert_
118
124
  RSpec/NoExpectationExample:
119
125
  Exclude:
120
126
  - 'spec/mongoid/base64_encoded_cursor_spec.rb'
121
127
 
122
- # Offense count: 4
123
128
  RSpec/RepeatedDescription:
124
129
  Exclude:
125
130
  - 'spec/mongoid/base64_encoded_cursor_spec.rb'
126
131
 
127
- # Offense count: 4
128
132
  RSpec/RepeatedExample:
129
133
  Exclude:
130
134
  - 'spec/mongoid/base64_encoded_cursor_spec.rb'
131
135
 
132
- # Offense count: 3
133
- # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
134
- # Include: **/*_spec.rb
136
+ # Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
137
+ # SupportedInflectors: default, active_support
135
138
  RSpec/SpecFilePathFormat:
136
139
  Exclude:
137
- - '**/spec/routing/**/*'
138
140
  - 'spec/mongoid/base64_encoded_cursor_spec.rb'
139
141
  - 'spec/mongoid/cursor_spec.rb'
140
142
  - 'spec/mongoid/scroll_spec.rb'
141
143
 
142
- # Offense count: 1
143
- # This cop supports safe autocorrection (--autocorrect).
144
- Rake/Desc:
145
- Exclude:
146
- - 'Rakefile'
147
-
148
- # Offense count: 12
149
144
  # Configuration parameters: AllowedConstants.
150
145
  Style/Documentation:
151
146
  Exclude:
152
- - 'spec/**/*'
153
- - 'test/**/*'
154
147
  - 'examples/feed.rb'
155
148
  - 'lib/mongoid/criteria/scrollable.rb'
156
149
  - 'lib/mongoid/criteria/scrollable/iterator.rb'
@@ -164,27 +157,67 @@ Style/Documentation:
164
157
  - 'lib/mongoid/scroll/errors/unsupported_field_type_error.rb'
165
158
  - 'lib/mongoid/scroll/errors/unsupported_type_error.rb'
166
159
 
167
- # Offense count: 34
168
160
  # This cop supports unsafe autocorrection (--autocorrect-all).
169
161
  # Configuration parameters: EnforcedStyle.
170
162
  # SupportedStyles: always, always_true, never
171
163
  Style/FrozenStringLiteralComment:
172
- Enabled: false
164
+ Exclude:
165
+ - 'Gemfile'
166
+ - 'Rakefile'
167
+ - 'examples/feed.rb'
168
+ - 'lib/mongoid-scroll.rb'
169
+ - 'lib/mongoid/criteria/scrollable.rb'
170
+ - 'lib/mongoid/criteria/scrollable/cursors.rb'
171
+ - 'lib/mongoid/criteria/scrollable/fields.rb'
172
+ - 'lib/mongoid/criteria/scrollable/iterator.rb'
173
+ - 'lib/mongoid/scroll/base64_encoded_cursor.rb'
174
+ - 'lib/mongoid/scroll/base_cursor.rb'
175
+ - 'lib/mongoid/scroll/cursor.rb'
176
+ - 'lib/mongoid/scroll/errors.rb'
177
+ - 'lib/mongoid/scroll/errors/base.rb'
178
+ - 'lib/mongoid/scroll/errors/invalid_base64_cursor_error.rb'
179
+ - 'lib/mongoid/scroll/errors/invalid_base_cursor_error.rb'
180
+ - 'lib/mongoid/scroll/errors/invalid_cursor_error.rb'
181
+ - 'lib/mongoid/scroll/errors/mismatched_sort_fields_error.rb'
182
+ - 'lib/mongoid/scroll/errors/multiple_sort_fields_error.rb'
183
+ - 'lib/mongoid/scroll/errors/no_such_field_error.rb'
184
+ - 'lib/mongoid/scroll/errors/unsupported_field_type_error.rb'
185
+ - 'lib/mongoid/scroll/errors/unsupported_type_error.rb'
186
+ - 'lib/mongoid/scroll/version.rb'
187
+ - 'lib/mongoid_scroll.rb'
188
+ - 'mongoid-scroll.gemspec'
189
+ - 'spec/mongoid/base64_encoded_cursor_spec.rb'
190
+ - 'spec/mongoid/criteria_spec.rb'
191
+ - 'spec/mongoid/cursor_spec.rb'
192
+ - 'spec/mongoid/scroll/base_cursor_spec.rb'
193
+ - 'spec/mongoid/scroll_spec.rb'
194
+ - 'spec/mongoid/scroll_version_spec.rb'
195
+ - 'spec/spec_helper.rb'
196
+ - 'spec/support/feed/embedded_item.rb'
197
+ - 'spec/support/feed/item.rb'
198
+ - 'spec/support/feed/publisher.rb'
199
+ - 'spec/support/mongodb.rb'
200
+
201
+ # This cop supports safe autocorrection (--autocorrect).
202
+ Style/IfUnlessModifier:
203
+ Exclude:
204
+ - 'lib/mongoid/scroll/base_cursor.rb'
205
+
206
+ Style/ItAssignment:
207
+ Exclude:
208
+ - 'spec/mongoid/criteria_spec.rb'
173
209
 
174
- # Offense count: 1
175
210
  # This cop supports safe autocorrection (--autocorrect).
176
211
  Style/MultilineTernaryOperator:
177
212
  Exclude:
178
213
  - 'lib/mongoid/scroll/cursor.rb'
179
214
 
180
- # Offense count: 3
181
215
  # This cop supports unsafe autocorrection (--autocorrect-all).
182
216
  # Configuration parameters: AllowedCompactTypes.
183
217
  # SupportedStyles: compact, exploded
184
218
  Style/RaiseArgs:
185
219
  EnforcedStyle: compact
186
220
 
187
- # Offense count: 2
188
221
  # This cop supports unsafe autocorrection (--autocorrect-all).
189
222
  # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
190
223
  # AllowedMethods: present?, blank?, presence, try, try!
@@ -193,9 +226,16 @@ Style/SafeNavigation:
193
226
  - 'lib/mongoid/scroll/errors/mismatched_sort_fields_error.rb'
194
227
  - 'lib/mongoid/scroll/errors/multiple_sort_fields_error.rb'
195
228
 
196
- # Offense count: 36
197
229
  # This cop supports safe autocorrection (--autocorrect).
198
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
230
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
199
231
  # URISchemes: http, https
232
+ # AllowedPatterns: (?-mix:^\#)
200
233
  Layout/LineLength:
201
- Max: 252
234
+ Exclude:
235
+ - 'lib/config/locales/en.yml'
236
+ - 'lib/mongoid/scroll/base64_encoded_cursor.rb'
237
+ - 'lib/mongoid/scroll/base_cursor.rb'
238
+ - 'spec/mongoid/base64_encoded_cursor_spec.rb'
239
+ - 'spec/mongoid/criteria_spec.rb'
240
+ - 'spec/mongoid/cursor_spec.rb'
241
+ - 'spec/mongoid/scroll/base_cursor_spec.rb'
data/.spellcheck.txt ADDED
@@ -0,0 +1,59 @@
1
+ ActiveSupport
2
+ ArgumentError
3
+ asgerb
4
+ astring
5
+ BSON
6
+ Bundler
7
+ CHANGELOG
8
+ changelog
9
+ config
10
+ DateTime
11
+ dblock
12
+ deserialize
13
+ Doubrovkine
14
+ embeddable
15
+ EmbeddedItem
16
+ FabienChaynes
17
+ GCorbel
18
+ Gemfile
19
+ gemspec
20
+ GHA
21
+ gte
22
+ Implemenet
23
+ InvalidCursorError
24
+ joeyAghion
25
+ JRuby
26
+ JSON
27
+ leamotta
28
+ linter
29
+ lt
30
+ lte
31
+ Macreery
32
+ md
33
+ MismatchedSortFieldsError
34
+ Mogoid
35
+ Mongo
36
+ mongo
37
+ mongodb
38
+ Mongoid
39
+ mongoid
40
+ MongoidScrollRelease
41
+ MultipleSortFieldsError
42
+ ObjectId
43
+ params
44
+ pre
45
+ Rakefile
46
+ rb
47
+ README
48
+ RSpec
49
+ RuboCop
50
+ RubyGems
51
+ Scrollable
52
+ serializer
53
+ SimpleCov
54
+ storageEngine
55
+ subclasses
56
+ UnsupportedTypeError
57
+ WiredTiger
58
+ YAML
59
+ yml
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 2.0.2 (2026/11/24)
2
+
3
+ * [#53](https://github.com/mongoid/mongoid-scroll/pull/53): Cover float cursor round trips, serialization errors, abstract contracts and descending tiebreaker inclusion - [@dblock](https://github.com/dblock).
4
+ * [#54](https://github.com/mongoid/mongoid-scroll/pull/54): 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).
5
+ * [#55](https://github.com/mongoid/mongoid-scroll/pull/55): 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).
6
+ * [#56](https://github.com/mongoid/mongoid-scroll/pull/56): Release with ruby-gem-release from a manually dispatched GitHub Actions workflow using RubyGems Trusted Publishing, with dry runs - [@dblock](https://github.com/dblock).
7
+ * [#58](https://github.com/mongoid/mongoid-scroll/pull/58): Upgrade danger-pr-comment to 0.3.0 from the `danger` organization and skip empty Danger report comments - [@dblock](https://github.com/dblock).
8
+
1
9
  ### 2.0.1 (2026/10/15)
2
10
 
3
11
  * [#48](https://github.com/mongoid/mongoid-scroll/issues/48): Raise `NoSuchFieldError` when a sort or cursor refers to a field no longer defined on the model - [@dblock](https://github.com/dblock).
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ gemspec
4
4
 
5
5
  case version = ENV['MONGOID_VERSION'] || '9'
6
6
  when 'HEAD' then gem 'mongoid', github: 'mongodb/mongoid'
7
- when /^9/ then gem 'mongoid', '~> 9.0'
7
+ when /^9/ then gem 'mongoid', '~> 9.0'
8
8
  when /8/ then gem 'mongoid', '~> 8.0'
9
9
  when /7/ then gem 'mongoid', '~> 7.0'
10
10
  when /6/ then gem 'mongoid', '~> 6.0'
@@ -21,13 +21,22 @@ group :development, :test do
21
21
  gem 'danger-pr-comment', require: false
22
22
  gem 'database_cleaner-mongoid', '~> 2.0'
23
23
  gem 'faker'
24
+ gem 'json', '< 3' # Older ActiveSupport passes the quirks_mode option that json 3 removed.
24
25
  gem 'logger'
25
26
  gem 'mutex_m'
26
27
  gem 'rake'
27
28
  gem 'rspec', '~> 3.0'
28
29
  gem 'rspec-its'
29
30
  gem 'simplecov', '>= 0.22', require: false
30
- gem 'rubocop', '1.66.1'
31
- gem 'rubocop-rake'
32
- gem 'rubocop-rspec'
31
+ if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3')
32
+ gem 'commonmarker', '~> 2.10', require: false
33
+ gem 'rubocop', '~> 1.92'
34
+ gem 'rubocop-md', '~> 3.0', require: false
35
+ gem 'rubocop-prose', '~> 0.2', require: false
36
+ gem 'rubocop-rake', '~> 0.7', require: false
37
+ gem 'rubocop-rspec', '~> 3.10', require: false
38
+ gem 'rubocop-spellcheck', '~> 0.2', require: false
39
+ gem 'rubocop-yaml', '~> 0.1.0', require: false
40
+ gem 'ruby-gem-release', '0.9.0', require: false
41
+ end
33
42
  end
data/README.md CHANGED
@@ -1,21 +1,18 @@
1
- - [Mongoid::Scroll](#mongoidscroll)
2
- - [Compatibility](#compatibility)
3
- - [Demo](#demo)
4
- - [The Problem](#the-problem)
5
- - [Installation](#installation)
6
- - [Usage](#usage)
7
- - [Indexes and Performance](#indexes-and-performance)
8
- - [Cursors](#cursors)
9
- - [Standard Cursor](#standard-cursor)
10
- - [Base64 Encoded Cursor](#base64-encoded-cursor)
11
- - [Contributing](#contributing)
12
- - [Copyright and License](#copyright-and-license)
13
-
14
1
  # Mongoid::Scroll
15
2
 
16
- [![Gem Version](https://badge.fury.io/rb/mongoid-scroll.svg)](https://badge.fury.io/rb/mongoid-scroll)
17
- [![CI](https://github.com/mongoid/mongoid-scroll/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mongoid/mongoid-scroll/actions/workflows/ci.yml?query=branch%3Amaster)
18
- [![Coverage Status](https://coveralls.io/repos/github/mongoid/mongoid-scroll/badge.svg?branch=master)](https://coveralls.io/github/mongoid/mongoid-scroll?branch=master)
3
+ [![Gem Version](https://badge.fury.io/rb/mongoid-scroll.svg)](https://badge.fury.io/rb/mongoid-scroll) [![CI](https://github.com/mongoid/mongoid-scroll/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/mongoid/mongoid-scroll/actions/workflows/ci.yml?query=branch%3Amaster) [![Coverage Status](https://coveralls.io/repos/github/mongoid/mongoid-scroll/badge.svg?branch=master)](https://coveralls.io/github/mongoid/mongoid-scroll?branch=master)
4
+
5
+ - [Compatibility](#compatibility)
6
+ - [Demo](#demo)
7
+ - [The Problem](#the-problem)
8
+ - [Installation](#installation)
9
+ - [Usage](#usage)
10
+ - [Indexes and Performance](#indexes-and-performance)
11
+ - [Cursors](#cursors)
12
+ - [Standard Cursor](#standard-cursor)
13
+ - [Base64 Encoded Cursor](#base64-encoded-cursor)
14
+ - [Contributing](#contributing)
15
+ - [Copyright and License](#copyright-and-license)
19
16
 
20
17
  Mongoid extension that enables infinite scrolling for `Mongoid::Criteria` and `Mongo::Collection::View`.
21
18
 
@@ -31,8 +28,8 @@ Take a look at [this example](examples/feed.rb). Try with with `bundle exec ruby
31
28
 
32
29
  Traditional pagination does not work when data changes between paginated requests, which makes it unsuitable for infinite scroll behaviors.
33
30
 
34
- * If a record is inserted before the current page limit, items will shift right, and the next page will include a duplicate.
35
- * If a record is removed before the current page limit, items will shift left, and the next page will be missing a record.
31
+ - If a record is inserted before the current page limit, items will shift right, and the next page will include a duplicate.
32
+ - If a record is removed before the current page limit, items will shift left, and the next page will be missing a record.
36
33
 
37
34
  The solution implemented by the `scroll` extension paginates data using a cursor, giving you the ability to restart pagination where you left it off. This is a non-trivial problem when combined with sorting over non-unique record fields, such as timestamps.
38
35
 
@@ -107,24 +104,24 @@ end
107
104
 
108
105
  A query without a cursor is identical to a query without a scroll.
109
106
 
110
- ``` ruby
107
+ ```ruby
111
108
  # db.feed_items.find().sort({ position: 1 }).limit(7)
112
109
  Feed::Item.desc(:position).limit(7).scroll
113
110
  ```
114
111
 
115
112
  Subsequent queries use an `$or` to avoid skipping items with the same value as the one at the current cursor position.
116
113
 
117
- ``` ruby
114
+ ```ruby
118
115
  # db.feed_items.find({ "$or" : [
119
116
  # { "position" : { "$gt" : 13 }},
120
117
  # { "position" : 13, "_id": { "$gt" : ObjectId("511d7c7c3b5552c92400000e") }}
121
118
  # ]}).sort({ position: 1 }).limit(7)
122
- Feed:Item.desc(:position).limit(7).scroll(cursor)
119
+ Feed :Item.desc(:position).limit(7).scroll(cursor)
123
120
  ```
124
121
 
125
122
  This means you need to hit an index on `position` and `_id`.
126
123
 
127
- ``` ruby
124
+ ```ruby
128
125
  # db.feed_items.ensureIndex({ position: 1, _id: 1 })
129
126
 
130
127
  module Feed
@@ -141,28 +138,28 @@ You can use `Mongoid::Scroll::Cursor.from_record` to generate a cursor. A cursor
141
138
 
142
139
  ```ruby
143
140
  record = Feed::Item.desc(:position).limit(3).last
144
- cursor = Mongoid::Scroll::Cursor.from_record(record, { field: Feed::Item.fields["position"] })
141
+ cursor = Mongoid::Scroll::Cursor.from_record(record, { field: Feed::Item.fields['position'] })
145
142
  # cursor or cursor.to_s can be returned to a client and passed into .scroll(cursor)
146
143
  ```
147
144
 
148
145
  You can also a `field_name` and `field_type` instead of a Mongoid field.
149
146
 
150
147
  ```ruby
151
- cursor = Mongoid::Scroll::Cursor.from_record(record, { field_type: DateTime, field_name: "position" })
148
+ cursor = Mongoid::Scroll::Cursor.from_record(record, { field_type: DateTime, field_name: 'position' })
152
149
  ```
153
150
 
154
151
  When the `include_current` option is set to `true`, the cursor will include the record it points to:
155
152
 
156
153
  ```ruby
157
154
  record = Feed::Item.desc(:position).limit(3).last
158
- cursor = Mongoid::Scroll::Cursor.from_record(record, { field: Feed::Item.fields["position"], include_current: true })
155
+ cursor = Mongoid::Scroll::Cursor.from_record(record, { field: Feed::Item.fields['position'], include_current: true })
159
156
  Feed::Item.asc(:position).limit(1).scroll(cursor).first # record
160
157
  ```
161
158
 
162
159
  If the `field_name`, `field_type` or `direction` options you specify when creating the cursor are different from the original criteria, a `Mongoid::Scroll::Errors::MismatchedSortFieldsError` will be raised.
163
160
 
164
161
  ```ruby
165
- cursor = Mongoid::Scroll::Cursor.from_record(record, { field_type: DateTime, field_name: "position" })
162
+ cursor = Mongoid::Scroll::Cursor.from_record(record, { field_type: DateTime, field_name: 'position' })
166
163
  Feed::Item.desc(:created_at).scroll(cursor) # Raises a Mongoid::Scroll::Errors::MismatchedSortFieldsError
167
164
  ```
168
165
 
@@ -182,10 +179,10 @@ end
182
179
 
183
180
  ## Contributing
184
181
 
185
- Fork the project. Make your feature addition or bug fix with tests. Send a pull request. Bonus points for topic branches.
182
+ See [CHANGELOG.md](CHANGELOG.md), [UPGRADING.md](UPGRADING.md), and [RELEASING.md](RELEASING.md).
186
183
 
187
184
  ## Copyright and License
188
185
 
189
- MIT License, see [LICENSE](http://github.com/mongoid/mongoid-scroll/raw/master/LICENSE.md) for details.
186
+ MIT License, see [LICENSE.md](LICENSE.md) for details.
190
187
 
191
- (c) 2013-2024 [Daniel Doubrovkine](http://github.com/dblock), based on code by [Frank Macreery](http://github.com/macreery), [Artsy Inc.](http://artsy.net)
188
+ (c) 2013-2024 [Daniel Doubrovkine](https://github.com/dblock), based on code by [Frank Macreery](https://github.com/macreery), [Artsy Inc.](https://www.artsy.net)
data/RELEASING.md CHANGED
@@ -1,48 +1,35 @@
1
1
  # Releasing Mongoid::Scroll
2
2
 
3
- Use the upstream checkout on clean `master`, verify `origin` is `mongoid/mongoid-scroll`, and run `git pull --ff-only`. Follow semantic versioning: patch for fixes, minor for backward-compatible features, major for breaking changes.
3
+ Releases use [ruby-gem-release](https://github.com/dblock/ruby-gem-release) 0.9.0 through a manually dispatched [Release workflow](.github/workflows/release.yml). Keep the `ruby-gem-release` gem in [Gemfile](Gemfile) and the reusable workflow in `release.yml` pinned to the same version. The workflow publishes through RubyGems Trusted Publishing, so no RubyGems API key or one-time password is needed. It only runs from `master` in `mongoid/mongoid-scroll`. The local Bundler `rake release`, `release:rubygem_push`, and `release:source_control_push` tasks are disabled.
4
4
 
5
- ## Prepare
5
+ ## One-Time Setup
6
6
 
7
- Set `lib/mongoid/scroll/version.rb` to the release version, date its `CHANGELOG.md` section using `YYYY/MM/DD`, and remove the contribution placeholder.
7
+ Before the first automated release, a maintainer must:
8
8
 
9
- ```sh
10
- bundle install
11
- bundle exec rake
12
- git add CHANGELOG.md lib/mongoid/scroll/version.rb RELEASING.md
13
- git commit -m "Preparing for release, 2.0.1."
14
- git push origin master
15
- ```
9
+ 1. Create the GitHub environment `release` in `mongoid/mongoid-scroll`, for example with `gh api --method PUT repos/mongoid/mongoid-scroll/environments/release`, and restrict its deployment branches to `master`. Add required reviewers to require maintainer approval before publication.
10
+ 2. At [mongoid-scroll's trusted publishers](https://rubygems.org/gems/mongoid-scroll/trusted_publishers), add a GitHub Actions publisher with repository owner `mongoid`, repository `mongoid-scroll`, workflow filename `release.yml`, environment `release`, and the separate workflow repository owner `dblock` and repository `ruby-gem-release`.
11
+ 3. Allow GitHub Actions to push release commits and `v*` tags to `master`. See the upstream [setup and permissions guidance](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/RELEASING.md#one-time-setup).
16
12
 
17
- ## Publish RubyGems and GitHub
13
+ Verify the setup without publishing with a [dry run](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#dry-run), which never edits files, builds, pushes, or publishes:
18
14
 
19
15
  ```sh
20
- bundle exec rake release
16
+ gh workflow run release.yml --repo mongoid/mongoid-scroll --ref master -f dry-run=true
21
17
  ```
22
18
 
23
- The task builds the gem, pushes its tag, and publishes to RubyGems. Complete MFA when prompted. If interrupted, inspect the tag and RubyGems version before retrying; never move a published tag. If only publication is missing, resume with `gem push pkg/mongoid-scroll-2.0.1.gem`.
19
+ ## Prepare
20
+
21
+ Start with a clean, up-to-date `master` and verify that the latest [CI checks](https://github.com/mongoid/mongoid-scroll/actions) pass. Follow semantic versioning: patch for fixes, minor for backward-compatible features, major for breaking changes. Check `VERSION` in [lib/mongoid/scroll/version.rb](lib/mongoid/scroll/version.rb) and the matching `(Next)` heading in [CHANGELOG.md](CHANGELOG.md), and change both in a pull request if needed, or pass a `version` override when dispatching. The workflow dates the `(Next)` heading using `YYYY/MM/DD` and removes the `* Your contribution here.` placeholder; a section without notes cannot be released.
22
+
23
+ Release automation requires MRI Ruby 3.3 or newer; the release dependency and tasks are skipped on older Ruby versions and JRuby. Release specs in [spec/release](spec/release) run the actual release tasks against a local fixture with the [ruby-gem-release RSpec helpers](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/testing.md), without contacting RubyGems or GitHub.
24
24
 
25
- A tag is not a GitHub release. After confirming RubyGems publication, create the matching GitHub release with changelog notes:
25
+ ## Publish
26
26
 
27
27
  ```sh
28
- version=2.0.1
29
- notes="$(mktemp)"
30
- awk -v version="$version" '
31
- /^### / {
32
- if (found) exit
33
- if ($2 == version) found = 1
34
- next
35
- }
36
- found { print }
37
- ' CHANGELOG.md > "$notes"
38
- gh release create "v$version" --repo mongoid/mongoid-scroll --verify-tag --title "$version" --notes-file "$notes" --latest
39
- rm "$notes"
40
- curl --fail --silent --show-error "https://rubygems.org/api/v2/rubygems/mongoid-scroll/versions/$version.json"
41
- gh release view "v$version" --repo mongoid/mongoid-scroll
28
+ gh workflow run release.yml --repo mongoid/mongoid-scroll --ref master
42
29
  ```
43
30
 
44
- Verify both the published gem and non-draft GitHub release before declaring completion.
31
+ Pass `-f version=x.y.z` to release a different version. Dispatching starts a real release; do not merge into `master` while it runs. The workflow prepares the release commit, starts MongoDB 8.0, runs lint and specs on Ruby 3.3, builds the gem, preserves recovery artifacts, publishes to RubyGems, pushes the release commit and `v` tag, and creates a GitHub Release with the changelog notes and the gem attached. It then increments the patch version, adds a new `(Next)` section, and pushes the next development commit. Verify the published version on [RubyGems](https://rubygems.org/gems/mongoid-scroll), the tag, the [GitHub Release](https://github.com/mongoid/mongoid-scroll/releases), and the next development commit.
45
32
 
46
- ## Prepare the Next Version
33
+ ## Recover a Partial Release
47
34
 
48
- Increment the development patch version in `lib/mongoid/scroll/version.rb` (for example, `2.0.2`). Add `### 2.0.2 (Next)` with a contribution placeholder above the released changelog section. Commit and push those changes to `master`, leaving the released tag unchanged.
35
+ Inspect the failed run, RubyGems, remote commits and tags, and the GitHub Release before retrying. Publication may have succeeded even if a later step failed. Never move a published tag or republish a version with different contents. Use the run's retained recovery artifacts and the upstream [recovery instructions](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#recovery-artifacts).
data/Rakefile CHANGED
@@ -1,6 +1,18 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/gem_tasks'
3
3
 
4
+ if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
5
+ Gem.loaded_specs.key?('ruby-gem-release')
6
+ require_relative 'script/release'
7
+ MongoidScrollRelease.workflow.install_tasks
8
+
9
+ %w[release release:rubygem_push release:source_control_push].each do |name|
10
+ Rake::Task[name].clear
11
+ desc 'Disabled; releases run through GitHub Actions, see RELEASING.md'
12
+ task(name) { abort "#{name} is disabled; releases run through GitHub Actions, see RELEASING.md" }
13
+ end
14
+ end
15
+
4
16
  require File.expand_path('lib/mongoid/scroll/version', __dir__)
5
17
 
6
18
  begin
@@ -20,8 +32,14 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
20
32
  spec.pattern = FileList['spec/**/*_spec.rb']
21
33
  end
22
34
 
23
- task :spec
24
- require 'rubocop/rake_task'
25
- RuboCop::RakeTask.new(:rubocop)
35
+ lint = RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
36
+ Gem.loaded_specs.key?('rubocop')
37
+ if lint
38
+ require 'rubocop/rake_task'
39
+ RuboCop::RakeTask.new(:rubocop)
40
+
41
+ desc 'Lint Ruby, Markdown, YAML, and spelling'
42
+ task lint: :rubocop
43
+ end
26
44
 
27
- task default: %i[rubocop spec]
45
+ task default: lint ? %i[rubocop spec] : %i[spec]
data/UPGRADING.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Upgrading
2
2
 
3
- ## Upgrading to >= 2.0.0
3
+ ## Upgrading To >= 2.0.0
4
4
 
5
5
  The second argument yielded in the block in `Mongoid::Criteria::Scrollable#scroll` and `Mongo::Scrollable#scroll` has changed from a cursor to an instance of `Mongoid::Criteria::Scrollable` which provides `next_cursor` and `previous_cursor`. The `next_cursor` method returns the same cursor as in versions prior to 2.0.0.
6
6
 
@@ -14,13 +14,13 @@ end
14
14
 
15
15
  Should be updated to:
16
16
 
17
- ```
17
+ ```ruby
18
18
  Feed::Item.asc(field_name).limit(2).scroll(cursor) do |_, iterator|
19
19
  cursor = iterator.next_cursor
20
20
  end
21
21
  ```
22
22
 
23
- ## Upgrading to >= 1.0.0
23
+ ## Upgrading To >= 1.0.0
24
24
 
25
25
  ### Mismatched Sort Fields
26
26
 
@@ -29,6 +29,6 @@ Both `Mongoid::Criteria::Scrollable#scroll` and `Mongo::Scrollable` now raise a
29
29
  For example, the following code will now raise a `MismatchedSortFieldsError` because we set a different field name (`position`) from the `created_at` field used to sort in `scroll`.
30
30
 
31
31
  ```ruby
32
- cursor.field_name = "position"
32
+ cursor.field_name = 'position'
33
33
  Feed::Item.desc(:created_at).scroll(cursor)
34
34
  ```
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Scroll
3
- VERSION = '2.0.1'.freeze
3
+ VERSION = '2.0.2'.freeze
4
4
  end
5
5
  end
@@ -1,5 +1,4 @@
1
- $LOAD_PATH.push File.expand_path('lib', __dir__)
2
- require 'mongoid/scroll/version'
1
+ require_relative 'lib/mongoid/scroll/version'
3
2
 
4
3
  Gem::Specification.new do |s|
5
4
  s.name = 'mongoid-scroll'
data/script/release.rb ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ruby-gem-release/changelog'
4
+ require 'ruby-gem-release/workflow/ruby_gem'
5
+
6
+ # Builds the ruby-gem-release workflow used by the Rakefile, the Release GitHub Actions workflow, and spec/release.
7
+ module MongoidScrollRelease
8
+ def self.workflow(**options)
9
+ RubyGemRelease::Workflow::RubyGem.new(
10
+ version: RubyGemRelease::Version::RubyConstant.new(path: 'lib/mongoid/scroll/version.rb', constant: 'VERSION'),
11
+ changelog: RubyGemRelease::Changelog::Intridea.new(placeholder: '* Your contribution here.'),
12
+ **options
13
+ )
14
+ end
15
+ end
@@ -362,7 +362,7 @@ describe Mongoid::Criteria do
362
362
  end
363
363
  end
364
364
 
365
- context 'with DateTime with a milisecond precision' do
365
+ context 'with DateTime with a millisecond precision' do
366
366
  let!(:item_1) { Feed::Item.create!(a_datetime: DateTime.new(2013, 1, 21, 1, 42, 3.1, 'UTC')) }
367
367
  let!(:item_2) { Feed::Item.create!(a_datetime: DateTime.new(2013, 1, 21, 1, 42, 3.2, 'UTC')) }
368
368
  let!(:item_3) { Feed::Item.create!(a_datetime: DateTime.new(2013, 1, 21, 1, 42, 3.3, 'UTC')) }
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mongoid::Scroll::BaseCursor do
4
+ it 'requires subclasses to implement serialization' do
5
+ expect { described_class.new(nil).to_s }.to raise_error(NotImplementedError, /to_s/)
6
+ end
7
+
8
+ it 'requires subclasses to implement parsing' do
9
+ expect { described_class.new(nil).send(:parse, 'cursor') }.to raise_error(NotImplementedError, /parse/)
10
+ end
11
+
12
+ it 'round trips a floating-point cursor' do
13
+ id = BSON::ObjectId.new
14
+ cursor = Mongoid::Scroll::Cursor.from_record({ 'score' => 1.25, '_id' => id }, field_name: 'score', field_type: Float)
15
+
16
+ expect(cursor.to_s).to eq("1.25:#{id}")
17
+ expect(Mongoid::Scroll::Cursor.new(cursor.to_s, field_name: 'score', field_type: Float).value).to eq(1.25)
18
+ end
19
+
20
+ it 'rejects an unsupported field type during serialization' do
21
+ cursor = Mongoid::Scroll::Cursor.new(nil, field_name: 'values', field_type: Array)
22
+ cursor.value = [1]
23
+ cursor.tiebreak_id = BSON::ObjectId.new
24
+
25
+ expect { cursor.to_s }.to raise_error(Mongoid::Scroll::Errors::UnsupportedFieldTypeError, /Array/)
26
+ end
27
+
28
+ it 'includes the descending tiebreaker record when requested' do
29
+ id = BSON::ObjectId.new
30
+ cursor = described_class.new(3, field_name: 'score', field_type: Integer, direction: -1, include_current: true, tiebreak_id: id)
31
+
32
+ expected = [
33
+ { 'score' => { '$lt' => 3 } },
34
+ { 'score' => 3, '_id' => { '$lte' => id } }
35
+ ]
36
+ expect(cursor.criteria).to eq('$or' => expected)
37
+ end
38
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mongoid::Scroll do
4
+ it 'defines a semantic version' do
5
+ expect(Mongoid::Scroll::VERSION).to match(/\A\d+\.\d+\.\d+\z/)
6
+ end
7
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
4
+ Gem.loaded_specs.key?('ruby-gem-release')
5
+ require_relative '../../script/release'
6
+ require 'ruby-gem-release/rspec'
7
+
8
+ RSpec.describe MongoidScrollRelease do
9
+ include RubyGemRelease::RSpec
10
+
11
+ let(:root) { File.expand_path('../..', __dir__) }
12
+ let(:version_path) { 'lib/mongoid/scroll/version.rb' }
13
+ let(:fixture_files) do
14
+ %w[
15
+ mongoid-scroll.gemspec script/release.rb lib/**/*.rb CHANGELOG.md
16
+ LICENSE.md README.md RELEASING.md UPGRADING.md
17
+ ]
18
+ end
19
+ let(:placeholder) { '* Your contribution here.' }
20
+ let(:note) { '* [#1](https://github.com/mongoid/mongoid-scroll/pull/1): Added a feature.' }
21
+
22
+ def changelog(notes)
23
+ [
24
+ '### 1.2.0 (Next)', '', notes, placeholder, '',
25
+ '### 1.1.0 (2026/01/01)', '', '* Previous release.', ''
26
+ ].join("\n")
27
+ end
28
+
29
+ def write_version(project, version)
30
+ source = File.read(File.join(root, version_path))
31
+ project.write(version_path, source.sub(/VERSION = (['"])[^'"]+\1/, "VERSION = '#{version}'"))
32
+ end
33
+
34
+ def with_project(notes)
35
+ with_release_project do |project|
36
+ project.environment.merge!(ENV.to_h.slice('MONGOID_VERSION'))
37
+ project.copy_files(path: root, files: fixture_files)
38
+ project.configure_workflow(require: 'script/release', builder: 'MongoidScrollRelease.workflow')
39
+ project.write('CHANGELOG.md', changelog(notes))
40
+ write_version(project, '1.2.0')
41
+ project.commit!
42
+ yield project
43
+ end
44
+ end
45
+
46
+ it 'builds the standard ruby-gem-release workflow' do
47
+ expect(described_class.workflow).to be_a(RubyGemRelease::Workflow::RubyGem)
48
+ end
49
+
50
+ it 'dates the release and prepares the next patch version' do
51
+ with_project(note) do |project|
52
+ project.release!
53
+
54
+ released = project.remote_file('v1.2.0', 'CHANGELOG.md')
55
+ expect(released).to match(%r{\A### 1\.2\.0 \(\d{4}/\d{2}/\d{2}\)\n\n})
56
+ expect(released).to include(note)
57
+ expect(released).not_to include('(Next)', placeholder)
58
+ expect(project.remote_file('v1.2.0', version_path)).to include("VERSION = '1.2.0'")
59
+ pending = project.remote_file('master', 'CHANGELOG.md')
60
+ expect(pending).to start_with("### 1.2.1 (Next)\n\n#{placeholder}\n\n### 1.2.0 (")
61
+ expect(project.remote_file('master', version_path)).to include("VERSION = '1.2.1'")
62
+ expect(project.git('status', '--porcelain')).to be_empty
63
+ end
64
+ end
65
+
66
+ it 'rejects placeholder-only notes without changing files or remote refs' do
67
+ with_project('') do |project|
68
+ original = project.git('rev-parse', 'origin/master')
69
+ project.run_task('release:workflow:capture')
70
+
71
+ expect { project.run_task('release:validate') }.to raise_error(RuntimeError, /no pending changelog notes/)
72
+ expect(project.git('status', '--porcelain')).to be_empty
73
+ expect(project.git('rev-parse', 'origin/master')).to eq(original)
74
+ end
75
+ end
76
+ end
77
+ end
data/spec/spec_helper.rb CHANGED
@@ -16,7 +16,7 @@ require 'logger'
16
16
  require 'database_cleaner/mongoid'
17
17
  require 'mongoid-scroll'
18
18
 
19
- Time.zone ||= 'EST'
19
+ Time.zone ||= 'Etc/GMT+5'
20
20
 
21
21
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each do |f|
22
22
  require f
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-scroll
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2026-10-15 00:00:00.000000000 Z
12
+ date: 2026-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -48,10 +48,13 @@ files:
48
48
  - ".github/workflows/ci.yml"
49
49
  - ".github/workflows/danger-comment.yml"
50
50
  - ".github/workflows/danger.yml"
51
+ - ".github/workflows/lint.yml"
52
+ - ".github/workflows/release.yml"
51
53
  - ".gitignore"
52
54
  - ".rspec"
53
55
  - ".rubocop.yml"
54
56
  - ".rubocop_todo.yml"
57
+ - ".spellcheck.txt"
55
58
  - CHANGELOG.md
56
59
  - Dangerfile
57
60
  - Gemfile
@@ -83,10 +86,14 @@ files:
83
86
  - lib/mongoid/scroll/version.rb
84
87
  - lib/mongoid_scroll.rb
85
88
  - mongoid-scroll.gemspec
89
+ - script/release.rb
86
90
  - spec/mongoid/base64_encoded_cursor_spec.rb
87
91
  - spec/mongoid/criteria_spec.rb
88
92
  - spec/mongoid/cursor_spec.rb
93
+ - spec/mongoid/scroll/base_cursor_spec.rb
89
94
  - spec/mongoid/scroll_spec.rb
95
+ - spec/mongoid/scroll_version_spec.rb
96
+ - spec/release/release_spec.rb
90
97
  - spec/spec_helper.rb
91
98
  - spec/support/feed/embedded_item.rb
92
99
  - spec/support/feed/item.rb
@@ -112,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
119
  - !ruby/object:Gem::Version
113
120
  version: 1.3.6
114
121
  requirements: []
115
- rubygems_version: 3.5.16
122
+ rubygems_version: 3.5.22
116
123
  signing_key:
117
124
  specification_version: 4
118
125
  summary: Mongoid extensions to enable infinite scroll.