mongoid-scroll 0.3.2 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 49f6957fe1cfab726fa346c141eb979487590912
4
- data.tar.gz: e791fd49a8bf4aa187aaccb5222ada9f1e0dcf89
2
+ SHA256:
3
+ metadata.gz: 976d59e1ce7d21c024936f21e58be085fa096260c8ee38b4c0d6f70d35145449
4
+ data.tar.gz: 389db57d4b31efa2114f9c3f5f86545f691a2db96de1d3aaad5ff995a0b02f45
5
5
  SHA512:
6
- metadata.gz: 5cdf23a3ee65c76874d71ff8d78cb948c478e8f75b53cc930717493d2bc7ebc13b3787c06c4527eec197bd241b7b7ac4f62ca4ce5eb01cf67f56e54b2438a17b
7
- data.tar.gz: 9606b19764c8aa3a578e1f7b7f278d9cc4f1ce1849aaa5de5804024dd9a7399b9a4d337febe88dea7f415692268ea1c171091ca6eff0bcc467f15f3f1799d7e3
6
+ metadata.gz: f4929b559f25512c5ebe9a66519f018e834a2678e60c4062047bbdeb466d87b1c99be3a23b157f1c331c61d39bb5627f2ff4eef13158c697596755adf9eea927
7
+ data.tar.gz: bd8df34a05b1861472d6710e96c58104af9f0873fffc6cbb4191c91d4eab2c42bb739c0c8a522a92d61eb8898f3ace07adbccd48b40396f2330831cb4c014426
data/.rubocop.yml CHANGED
@@ -4,5 +4,3 @@ AllCops:
4
4
  Exclude:
5
5
  - vendor/**/*
6
6
  - gemfiles/vendor/**/*
7
-
8
-
data/.rubocop_todo.yml CHANGED
@@ -1,57 +1,78 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2015-08-08 11:38:01 -0400 using RuboCop version 0.33.0.
3
+ # on 2018-03-13 23:29:51 +0100 using RuboCop version 0.49.1.
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: 5
9
+ # Offense count: 6
10
+ # Configuration parameters: Include.
11
+ # Include: **/Gemfile, **/gems.rb
12
+ Bundler/DuplicatedGem:
13
+ Exclude:
14
+ - 'Gemfile'
15
+
16
+ # Offense count: 6
10
17
  Metrics/AbcSize:
11
- Max: 70
18
+ Max: 67
19
+
20
+ # Offense count: 14
21
+ # Configuration parameters: CountComments, ExcludedMethods.
22
+ Metrics/BlockLength:
23
+ Max: 216
12
24
 
13
25
  # Offense count: 5
14
26
  Metrics/CyclomaticComplexity:
15
27
  Max: 11
16
28
 
17
- # Offense count: 83
18
- # Configuration parameters: AllowURI, URISchemes.
29
+ # Offense count: 121
30
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
31
+ # URISchemes: http, https
19
32
  Metrics/LineLength:
20
- Max: 170
33
+ Max: 172
21
34
 
22
- # Offense count: 4
35
+ # Offense count: 6
23
36
  # Configuration parameters: CountComments.
24
37
  Metrics/MethodLength:
25
- Max: 26
38
+ Max: 25
26
39
 
27
40
  # Offense count: 3
28
41
  Metrics/PerceivedComplexity:
29
- Max: 12
42
+ Max: 11
30
43
 
31
- # Offense count: 13
44
+ # Offense count: 10
32
45
  Style/Documentation:
33
46
  Exclude:
47
+ - 'spec/**/*'
48
+ - 'test/**/*'
34
49
  - 'examples/mongoid_scroll_feed.rb'
35
- - 'lib/mongoid/criterion/scrollable.rb'
50
+ - 'lib/mongo/scrollable.rb'
51
+ - 'lib/mongoid/criteria/scrollable.rb'
36
52
  - 'lib/mongoid/scroll/cursor.rb'
37
53
  - 'lib/mongoid/scroll/errors/base.rb'
38
54
  - 'lib/mongoid/scroll/errors/invalid_cursor_error.rb'
39
55
  - 'lib/mongoid/scroll/errors/multiple_sort_fields_error.rb'
40
56
  - 'lib/mongoid/scroll/errors/no_such_field_error.rb'
41
57
  - 'lib/mongoid/scroll/errors/unsupported_field_type_error.rb'
42
- - 'lib/mongoid/scroll/mongoid.rb'
43
- - 'lib/mongoid/scroll/version.rb'
44
58
  - 'lib/moped/scrollable.rb'
45
- - 'spec/support/feed/embedded_item.rb'
46
- - 'spec/support/feed/item.rb'
47
59
 
48
60
  # Offense count: 1
49
- # Configuration parameters: Exclude.
61
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
62
+ # 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
50
63
  Style/FileName:
51
64
  Exclude:
52
65
  - 'lib/mongoid-scroll.rb'
53
66
 
54
- # Offense count: 6
67
+ # Offense count: 1
68
+ # Configuration parameters: MinBodyLength.
69
+ Style/GuardClause:
70
+ Exclude:
71
+ - 'lib/moped/scrollable.rb'
72
+
73
+ # Offense count: 1
74
+ # Cop supports --auto-correct.
55
75
  # Configuration parameters: SupportedStyles.
76
+ # SupportedStyles: compact, exploded
56
77
  Style/RaiseArgs:
57
78
  EnforcedStyle: compact
data/.travis.yml CHANGED
@@ -1,18 +1,37 @@
1
1
  services:
2
2
  - mongodb
3
3
 
4
- rvm:
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1.2
8
- - jruby-19mode
9
- - rbx-2
10
-
11
- env:
12
- - MONGOID_VERSION=3
13
- - MONGOID_VERSION=4
14
- - MONGOID_VERSION=5.0.0.beta
15
-
16
4
  language: ruby
17
5
 
18
6
  cache: bundler
7
+
8
+ before_install:
9
+ - gem update --system
10
+ - gem install bundler
11
+
12
+ matrix:
13
+ include:
14
+ - rvm: 2.3.1
15
+ env: MONGOID_VERSION=3
16
+ - rvm: 2.3.1
17
+ env: MONGOID_VERSION=4
18
+ - rvm: 2.3.1
19
+ env: MONGOID_VERSION=5
20
+ - rvm: 2.3.1
21
+ env: MONGOID_VERSION=6
22
+ - rvm: 2.3.1
23
+ env: MONGOID_VERSION=7
24
+ - rvm: 2.3.1
25
+ env: MONGOID_VERSION=HEAD
26
+ - rvm: 2.3.1
27
+ script:
28
+ - bundle exec danger
29
+
30
+ bundler_args: --without development
31
+
32
+ addons:
33
+ apt:
34
+ sources:
35
+ - mongodb-3.4-precise
36
+ packages:
37
+ - mongodb-org-server
data/CHANGELOG.md CHANGED
@@ -1,34 +1,50 @@
1
- 0.3.2 (8/8/2015)
2
- ----------------
1
+ ### 0.3.7 (2021/06/01)
3
2
 
4
- * [#7](https://github.com/dblock/mongoid-scroll/pull/7): Fix: pre-merge cursor criteria fields - [@sweir27](https://github.com/sweir27).
3
+ * [#22](https://github.com/mongoid/mongoid-scroll/pull/22): Compatibility with Mongoid 7 - [@asgerb](https://github.com/asgerb).
5
4
 
6
- 0.3.1 (7/27/2015)
7
- -----------------
5
+ ### 0.3.6 (2018/05/01)
6
+
7
+ * [#18](https://github.com/mongoid/mongoid-scroll/pull/18): Fix mongoid scroll without block returning wrong criteria - [@asgerb](https://github.com/asgerb).
8
+ * [#15](https://github.com/mongoid/mongoid-scroll/pull/15): Use MongoDB 3.4 in testing and fix tests w/ WiredTiger storage engine - [@dblock](https://github.com/dblock).
9
+ * [#14](https://github.com/mongoid/mongoid-scroll/pull/14): Allow scrolling by foreign key - [@joeyAghion](https://github.com/joeyAghion).
10
+
11
+ ### 0.3.5 (2016/09/27)
12
+
13
+ * [#11](https://github.com/mongoid/mongoid-scroll/pull/11): Compatibility with Mongoid 6 - [@dblock](https://github.com/dblock).
14
+ * [#12](https://github.com/mongoid/mongoid-scroll/pull/12): Added Danger, PR linter - [@dblock](https://github.com/dblock).
15
+
16
+ ### 0.3.4 (2015/10/22)
17
+
18
+ * Added support for [mongo-ruby-driver](https://github.com/mongodb/mongo-ruby-driver), `Mongo::Collection::View` - [@dblock](https://github.com/dblock).
19
+
20
+ ### 0.3.3 (2015/09/17)
21
+
22
+ * Compatibility with Mongoid 5 - [@dblock](https://github.com/dblock).
23
+
24
+ ### 0.3.2 (2015/8/8)
25
+
26
+ * [#7](https://github.com/mongoid/mongoid-scroll/pull/7): Fix: pre-merge cursor criteria fields - [@sweir27](https://github.com/sweir27).
27
+
28
+ ### 0.3.1 (2015/7/27)
8
29
 
9
30
  * Compatibility with Mongoid 5.x beta - [@dblock](https://github.com/dblock).
10
- * [#4](https://github.com/dblock/mongoid-scroll/pull/4): Fix: support chaining `$or` criteria - [@sweir27](https://github.com/sweir27).
11
- * [#5](https://github.com/dblock/mongoid-scroll/pull/5): Fix: embeddable objects now returned in pagination - [@sweir27](https://github.com/sweir27).
31
+ * [#4](https://github.com/mongoid/mongoid-scroll/pull/4): Fix: support chaining `$or` criteria - [@sweir27](https://github.com/sweir27).
32
+ * [#5](https://github.com/mongoid/mongoid-scroll/pull/5): Fix: embeddable objects now returned in pagination - [@sweir27](https://github.com/sweir27).
12
33
 
13
- 0.3.0 (1/7/2014)
14
- ----------------
34
+ ### 0.3.0 (2014/1/7)
15
35
 
16
36
  * Compatibility with Mongoid 4.x - [@dblock](https://github.com/dblock).
17
37
  * Implemeneted Rubocop, Ruby linter - [@dblock](https://github.com/dblock).
18
38
 
19
- 0.2.1 (3/21/2013)
20
- -----------------
39
+ ### 0.2.1 (2013/3/21)
21
40
 
22
41
  * Fix: scroll over a collection that has duplicate values while data is being modified in a way that causes a change in the natural sort order - [@dblock](https://github.com/dblock).
23
42
 
24
- 0.2.0 (3/14/2013)
25
- -----------------
43
+ ### 0.2.0 (2013/3/14)
26
44
 
27
45
  * Extended `Moped::Query` with `scroll` - [@dblock](https://github.com/dblock).
28
46
  * `Mongoid::Scroll::Cursor.from_record` can now be called with either a Mongoid field or `field_type` and `field_name` in the `options` hash - [@dblock](https://github.com/dblock).
29
47
 
30
- 0.1.0 (2/14/2013)
31
- -----------------
48
+ ### 0.1.0 (2013/2/14)
32
49
 
33
50
  * Initial public release, extends `Mongoid::Criteria` with `scroll` - [@dblock](https://github.com/dblock).
34
-
data/Dangerfile ADDED
@@ -0,0 +1 @@
1
+ danger.import_dangerfile(gem: 'mongoid-danger')
data/Gemfile CHANGED
@@ -2,20 +2,23 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- case version = ENV['MONGOID_VERSION'] || '~> 4.0'
6
- when /4/
7
- gem 'mongoid', '~> 4.0'
8
- when /3/
9
- gem 'mongoid', '~> 3.1'
10
- else
11
- gem 'mongoid', version
5
+ case version = ENV['MONGOID_VERSION'] || '~> 7.0'
6
+ when 'HEAD' then gem 'mongoid', github: 'mongodb/mongoid'
7
+ when /7/ then gem 'mongoid', '~> 7.0'
8
+ when /6/ then gem 'mongoid', '~> 6.0'
9
+ when /5/ then gem 'mongoid', '~> 5.0'
10
+ when /4/ then gem 'mongoid', '~> 4.0'
11
+ when /3/ then gem 'mongoid', '~> 3.1'
12
+ else gem 'mongoid', version
12
13
  end
13
14
 
14
15
  group :development, :test do
15
- gem 'rake'
16
16
  gem 'bundler'
17
+ gem 'database_cleaner', '~> 1.8.5'
18
+ gem 'faker'
19
+ gem 'mongoid-danger', '~> 0.1.0', require: false
20
+ gem 'rake'
17
21
  gem 'rspec', '~> 3.0'
18
22
  gem 'rspec-its'
19
- gem 'faker'
20
- gem 'rubocop', '0.33.0'
23
+ gem 'rubocop', '0.49.1'
21
24
  end
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2012 Daniel Doubrovkine, Artsy Inc.
3
+ Copyright (c) 2013-2015 Daniel Doubrovkine, Artsy Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,18 +1,17 @@
1
1
  Mongoid::Scroll
2
2
  ===============
3
3
 
4
- [![Gem Version](http://img.shields.io/gem/v/mongoid-scroll.svg)](http://badge.fury.io/rb/mongoid-scroll)
5
- [![Build Status](http://img.shields.io/travis/dblock/mongoid-scroll.svg)](https://travis-ci.org/dblock/mongoid-scroll)
6
- [![Dependency Status](https://gemnasium.com/dblock/mongoid-scroll.svg)](https://gemnasium.com/dblock/mongoid-scroll)
7
- [![Code Climate](https://codeclimate.com/github/dblock/mongoid-scroll.svg)](https://codeclimate.com/github/dblock/mongoid-scroll)
4
+ [![Gem Version](https://badge.fury.io/rb/mongoid-scroll.svg)](https://badge.fury.io/rb/mongoid-scroll)
5
+ [![Build Status](https://travis-ci.org/mongoid/mongoid-scroll.svg?branch=master)](https://travis-ci.org/mongoid/mongoid-scroll)
6
+ [![Dependency Status](https://gemnasium.com/mongoid/mongoid-scroll.svg)](https://gemnasium.com/mongoid/mongoid-scroll)
7
+ [![Code Climate](https://codeclimate.com/github/mongoid/mongoid-scroll.svg)](https://codeclimate.com/github/mongoid/mongoid-scroll)
8
8
 
9
-
10
- Mongoid extension that enables infinite scrolling for `Mongoid::Criteria` and `Moped::Query`.
9
+ Mongoid extension that enables infinite scrolling for `Mongoid::Criteria`, `Moped::Query` and `Mongo::Collection::View`.
11
10
 
12
11
  Compatibility
13
12
  -------------
14
13
 
15
- This gem supports Mongoid 3, 4 and 5 beta.
14
+ This gem supports Mongoid 3, 4, 5, 6, 7, Moped and Mongo-Ruby-Driver.
16
15
 
17
16
  Demo
18
17
  ----
@@ -85,9 +84,9 @@ Feed::Item.desc(:position).scroll(saved_cursor) do |record, next_cursor|
85
84
  end
86
85
  ```
87
86
 
88
- ### Moped
87
+ ### Moped (Mongoid 3 and 4)
89
88
 
90
- Scroll and save a cursor to the last item. You must also supply a `field_type` of the sort criteria.
89
+ Scroll a `Moped::Query` and save a cursor to the last item. You must also supply a `field_type` of the sort criteria.
91
90
 
92
91
  ```ruby
93
92
  saved_cursor = nil
@@ -106,6 +105,27 @@ session[:feed_items].find.sort(position: -1).limit(5).scroll(saved_cursor, { fie
106
105
  end
107
106
  ```
108
107
 
108
+ ### Mongo-Ruby-Driver (Mongoid 5)
109
+
110
+ Scroll a `Mongo::Collection::View` and save a cursor to the last item. You must also supply a `field_type` of the sort criteria.
111
+
112
+ ```ruby
113
+ saved_cursor = nil
114
+ client[:feed_items].find.sort(position: -1).limit(5).scroll(nil, { field_type: DateTime }) do |record, next_cursor|
115
+ # each record, one-by-one
116
+ saved_cursor = next_cursor
117
+ end
118
+ ```
119
+
120
+ Resume iterating using the previously saved cursor.
121
+
122
+ ```ruby
123
+ session[:feed_items].find.sort(position: -1).limit(5).scroll(saved_cursor, { field_type: DateTime }) do |record, next_cursor|
124
+ # each record, one-by-one
125
+ saved_cursor = next_cursor
126
+ end
127
+ ```
128
+
109
129
  Indexes and Performance
110
130
  -----------------------
111
131
 
@@ -164,6 +184,6 @@ Fork the project. Make your feature addition or bug fix with tests. Send a pull
164
184
  Copyright and License
165
185
  ---------------------
166
186
 
167
- MIT License, see [LICENSE](http://github.com/dblock/mongoid-scroll/raw/master/LICENSE.md) for details.
187
+ MIT License, see [LICENSE](http://github.com/mongoid/mongoid-scroll/raw/master/LICENSE.md) for details.
168
188
 
169
- (c) 2013 [Daniel Doubrovkine](http://github.com/dblock), based on code by [Frank Macreery](http://github.com/macreery), [Artsy Inc.](http://artsy.net)
189
+ (c) 2013-2015 [Daniel Doubrovkine](http://github.com/dblock), based on code by [Frank Macreery](http://github.com/macreery), [Artsy Inc.](http://artsy.net)
data/RELEASING.md ADDED
@@ -0,0 +1,67 @@
1
+ Releasing Mongoid::Scroll
2
+ =========================
3
+
4
+ There're no particular rules about when to release mongoid-scroll. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
5
+
6
+ ### Release
7
+
8
+ Run tests, check that all tests succeed locally.
9
+
10
+ ```
11
+ bundle install
12
+ rake
13
+ ```
14
+
15
+ Check that the last build succeeded in [Travis CI](https://travis-ci.org/mongoid/mongoid-scroll) for all supported platforms.
16
+
17
+ Increment the version, modify [lib/mongoid/scroll/version.rb](lib/mongoid/scroll/version.rb).
18
+
19
+ * Increment the third number if the release has bug fixes and/or very minor features, only (eg. change `0.4.1` to `0.4.2`).
20
+ * Increment the second number if the release contains major features or breaking API changes (eg. change `0.4.1` to `0.5.0`).
21
+
22
+ Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
23
+
24
+ ```
25
+ ### 0.4.0 (2018/12/24)
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-scroll/version.rb
34
+ git commit -m "Preparing for release, 0.4.0."
35
+ git push origin master
36
+ ```
37
+
38
+ Release.
39
+
40
+ ```
41
+ $ rake release
42
+
43
+ mongoid-scroll 0.4.0 built to pkg/mongoid-scroll-0.4.0.gem.
44
+ Tagged v0.4.0.
45
+ Pushed git commits and tags.
46
+ Pushed mongoid-scroll 0.4.0 to rubygems.org.
47
+ ```
48
+
49
+ ### Prepare for the Next Version
50
+
51
+ Add the next release to [CHANGELOG.md](CHANGELOG.md).
52
+
53
+ ```
54
+ ### 0.4.1 (Next)
55
+
56
+ * Your contribution here.
57
+ ```
58
+
59
+ Increment the minor version, modify [lib/mongoid-scroll/version.rb](lib/mongoid-scroll/version.rb).
60
+
61
+ Commit your changes.
62
+
63
+ ```
64
+ git add CHANGELOG.md lib/mongoid-scroll/version.rb
65
+ git commit -m "Preparing for next release, 0.4.1."
66
+ git push origin master
67
+ ```
data/Rakefile CHANGED
@@ -24,4 +24,4 @@ task :spec
24
24
  require 'rubocop/rake_task'
25
25
  RuboCop::RakeTask.new(:rubocop)
26
26
 
27
- task default: [:rubocop, :spec]
27
+ task default: %i[rubocop spec]
@@ -0,0 +1,45 @@
1
+ require 'bundler'
2
+ Bundler.setup(:default, :development)
3
+
4
+ require 'mongoid-scroll'
5
+ require 'faker'
6
+
7
+ raise 'No Mongo Ruby Driver' unless Object.const_defined?(:Mongo)
8
+
9
+ Mongo::Logger.logger = Logger.new($stdout)
10
+ Mongo::Logger.logger.level = Logger::INFO
11
+
12
+ Mongoid.connect_to 'mongoid_scroll_demo'
13
+ Mongoid.purge!
14
+
15
+ # total items to insert
16
+ total_items = 20
17
+ # a MongoDB query will be executed every scroll_by items
18
+ scroll_by = 7
19
+
20
+ # insert items with a position out-of-order
21
+ rands = (0..total_items).to_a.sort { rand }[0..total_items]
22
+ total_items.times do
23
+ Mongoid.default_client['feed_items'].insert_one(title: Faker::Lorem.sentence, position: rands.pop)
24
+ end
25
+
26
+ Mongoid.default_client['feed_items'].indexes.create_one(position: 1, _id: 1)
27
+
28
+ total_shown = 0
29
+ next_cursor = nil
30
+ loop do
31
+ current_cursor = next_cursor
32
+ next_cursor = nil
33
+ Mongoid.default_client['feed_items'].find.limit(scroll_by).sort(position: 1).scroll(current_cursor, field_type: Integer, field_name: 'position') do |item, cursor|
34
+ puts "#{item['position']}: #{item['title']}"
35
+ next_cursor = cursor
36
+ total_shown += 1
37
+ end
38
+ break unless next_cursor
39
+ # destroy an item just for the heck of it, scroll is not affected
40
+ item = Mongoid.default_client['feed_items'].find.sort(position: 1).first
41
+ Mongoid.default_client['feed_items'].find(_id: item['_id']).delete_one
42
+ end
43
+
44
+ # this will be 20
45
+ puts "Shown #{total_shown} items."