pagy_cursor 0.2.1 → 0.2.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: db5bbbc8ad4eeacb38c8f09bf5ce0e7b740741f128e955a04edad241ca164b47
4
- data.tar.gz: 89c124e2905ab7f3a9e60ed6afc74576066faa55fcc028f42142bf07056400ee
3
+ metadata.gz: 44004bd3c0d4a31c61ce024c96e7e69a064c49342aed3e24154a42b61431f0b2
4
+ data.tar.gz: 15bee98c168a66fb9fa7db1312e73d4ee5e8123c599d2106b51b3b18a380a367
5
5
  SHA512:
6
- metadata.gz: 023b19a137c638a766107721ec7e728d0ebfa6b32788686a9edaeecc469d04b609519bf0bc8c72d807f396338fdb294f185d8c538f62386e1c00e8f702eb4232
7
- data.tar.gz: 7d8731348178705c581d886f8b3f409e5e661cd90a93dd6e1fb79aede4ecbc1c625e5142d7ec65c624a8d7e0fc673907ca98fabb7ba313d8e58af9c01dc16e73
6
+ metadata.gz: 58f4f60789e0558c92a060b13cc118cc5696097a34b9b14613bbd526030de18b2aa6b133967262b96c8b45de1ff9b2db04dae786d35ac934075f9d6b5d233307
7
+ data.tar.gz: e41e82f58a98e13e83173788dc402cc51df263b5d0ac9bf53cb1c22eef9f1dca97904afe8bd653502edabc874717c8dc9eade484de4b16936cbd941ecdd05e12
@@ -34,9 +34,12 @@ jobs:
34
34
  - ruby-version: 2.7
35
35
  env:
36
36
  BUNDLE_GEMFILE: gemfiles/active_record_52.gemfile
37
- - ruby-version: 3.0
37
+ - ruby-version: 2.7
38
38
  env:
39
39
  BUNDLE_GEMFILE: gemfiles/active_record_60.gemfile
40
+ - ruby-version: 3.0
41
+ env:
42
+ BUNDLE_GEMFILE: gemfiles/active_record_61.gemfile
40
43
 
41
44
  fail-fast: false
42
45
  env: ${{ matrix.env }}
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
- gem "rails", "~> 6.0.0"
5
+ gem "rails", "~> 6.1"
6
6
  gem "pg"
7
7
  gem "sqlite3"
8
8
  gem "mysql2"
data/Gemfile.lock CHANGED
@@ -1,163 +1,162 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pagy_cursor (0.2.0)
4
+ pagy_cursor (0.2.1)
5
5
  activerecord (>= 5)
6
- pagy
6
+ pagy (< 5)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (6.0.2.1)
12
- actionpack (= 6.0.2.1)
11
+ actioncable (6.1.4.4)
12
+ actionpack (= 6.1.4.4)
13
+ activesupport (= 6.1.4.4)
13
14
  nio4r (~> 2.0)
14
15
  websocket-driver (>= 0.6.1)
15
- actionmailbox (6.0.2.1)
16
- actionpack (= 6.0.2.1)
17
- activejob (= 6.0.2.1)
18
- activerecord (= 6.0.2.1)
19
- activestorage (= 6.0.2.1)
20
- activesupport (= 6.0.2.1)
16
+ actionmailbox (6.1.4.4)
17
+ actionpack (= 6.1.4.4)
18
+ activejob (= 6.1.4.4)
19
+ activerecord (= 6.1.4.4)
20
+ activestorage (= 6.1.4.4)
21
+ activesupport (= 6.1.4.4)
21
22
  mail (>= 2.7.1)
22
- actionmailer (6.0.2.1)
23
- actionpack (= 6.0.2.1)
24
- actionview (= 6.0.2.1)
25
- activejob (= 6.0.2.1)
23
+ actionmailer (6.1.4.4)
24
+ actionpack (= 6.1.4.4)
25
+ actionview (= 6.1.4.4)
26
+ activejob (= 6.1.4.4)
27
+ activesupport (= 6.1.4.4)
26
28
  mail (~> 2.5, >= 2.5.4)
27
29
  rails-dom-testing (~> 2.0)
28
- actionpack (6.0.2.1)
29
- actionview (= 6.0.2.1)
30
- activesupport (= 6.0.2.1)
31
- rack (~> 2.0, >= 2.0.8)
30
+ actionpack (6.1.4.4)
31
+ actionview (= 6.1.4.4)
32
+ activesupport (= 6.1.4.4)
33
+ rack (~> 2.0, >= 2.0.9)
32
34
  rack-test (>= 0.6.3)
33
35
  rails-dom-testing (~> 2.0)
34
36
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
- actiontext (6.0.2.1)
36
- actionpack (= 6.0.2.1)
37
- activerecord (= 6.0.2.1)
38
- activestorage (= 6.0.2.1)
39
- activesupport (= 6.0.2.1)
37
+ actiontext (6.1.4.4)
38
+ actionpack (= 6.1.4.4)
39
+ activerecord (= 6.1.4.4)
40
+ activestorage (= 6.1.4.4)
41
+ activesupport (= 6.1.4.4)
40
42
  nokogiri (>= 1.8.5)
41
- actionview (6.0.2.1)
42
- activesupport (= 6.0.2.1)
43
+ actionview (6.1.4.4)
44
+ activesupport (= 6.1.4.4)
43
45
  builder (~> 3.1)
44
46
  erubi (~> 1.4)
45
47
  rails-dom-testing (~> 2.0)
46
48
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
- activejob (6.0.2.1)
48
- activesupport (= 6.0.2.1)
49
+ activejob (6.1.4.4)
50
+ activesupport (= 6.1.4.4)
49
51
  globalid (>= 0.3.6)
50
- activemodel (6.0.2.1)
51
- activesupport (= 6.0.2.1)
52
- activerecord (6.0.2.1)
53
- activemodel (= 6.0.2.1)
54
- activesupport (= 6.0.2.1)
55
- activestorage (6.0.2.1)
56
- actionpack (= 6.0.2.1)
57
- activejob (= 6.0.2.1)
58
- activerecord (= 6.0.2.1)
59
- marcel (~> 0.3.1)
60
- activesupport (6.0.2.1)
52
+ activemodel (6.1.4.4)
53
+ activesupport (= 6.1.4.4)
54
+ activerecord (6.1.4.4)
55
+ activemodel (= 6.1.4.4)
56
+ activesupport (= 6.1.4.4)
57
+ activestorage (6.1.4.4)
58
+ actionpack (= 6.1.4.4)
59
+ activejob (= 6.1.4.4)
60
+ activerecord (= 6.1.4.4)
61
+ activesupport (= 6.1.4.4)
62
+ marcel (~> 1.0.0)
63
+ mini_mime (>= 1.1.0)
64
+ activesupport (6.1.4.4)
61
65
  concurrent-ruby (~> 1.0, >= 1.0.2)
62
- i18n (>= 0.7, < 2)
63
- minitest (~> 5.1)
64
- tzinfo (~> 1.1)
65
- zeitwerk (~> 2.2)
66
+ i18n (>= 1.6, < 2)
67
+ minitest (>= 5.1)
68
+ tzinfo (~> 2.0)
69
+ zeitwerk (~> 2.3)
66
70
  builder (3.2.4)
67
- coderay (1.1.2)
68
- concurrent-ruby (1.1.6)
71
+ coderay (1.1.3)
72
+ concurrent-ruby (1.1.9)
69
73
  crass (1.0.6)
70
- diff-lcs (1.3)
71
- erubi (1.9.0)
72
- globalid (0.4.2)
73
- activesupport (>= 4.2.0)
74
- i18n (1.8.2)
74
+ diff-lcs (1.5.0)
75
+ erubi (1.10.0)
76
+ globalid (1.0.0)
77
+ activesupport (>= 5.0)
78
+ i18n (1.9.1)
75
79
  concurrent-ruby (~> 1.0)
76
- loofah (2.4.0)
80
+ loofah (2.13.0)
77
81
  crass (~> 1.0.2)
78
82
  nokogiri (>= 1.5.9)
79
83
  mail (2.7.1)
80
84
  mini_mime (>= 0.1.1)
81
- marcel (0.3.3)
82
- mimemagic (~> 0.3.2)
83
- method_source (0.9.2)
84
- mimemagic (0.3.4)
85
- mini_mime (1.0.2)
86
- mini_portile2 (2.6.1)
87
- minitest (5.14.0)
85
+ marcel (1.0.2)
86
+ method_source (1.0.0)
87
+ mini_mime (1.1.2)
88
+ minitest (5.15.0)
88
89
  mysql2 (0.5.3)
89
- nio4r (2.5.2)
90
- nokogiri (1.12.5)
91
- mini_portile2 (~> 2.6.1)
90
+ nio4r (2.5.8)
91
+ nokogiri (1.12.5-x86_64-darwin)
92
92
  racc (~> 1.4)
93
- pagy (3.8.2)
94
- pg (1.2.2)
95
- pry (0.12.2)
96
- coderay (~> 1.1.0)
97
- method_source (~> 0.9.0)
98
- racc (1.5.2)
93
+ pagy (4.11.0)
94
+ pg (1.3.1)
95
+ pry (0.14.1)
96
+ coderay (~> 1.1)
97
+ method_source (~> 1.0)
98
+ racc (1.6.0)
99
99
  rack (2.2.3)
100
100
  rack-test (1.1.0)
101
101
  rack (>= 1.0, < 3)
102
- rails (6.0.2.1)
103
- actioncable (= 6.0.2.1)
104
- actionmailbox (= 6.0.2.1)
105
- actionmailer (= 6.0.2.1)
106
- actionpack (= 6.0.2.1)
107
- actiontext (= 6.0.2.1)
108
- actionview (= 6.0.2.1)
109
- activejob (= 6.0.2.1)
110
- activemodel (= 6.0.2.1)
111
- activerecord (= 6.0.2.1)
112
- activestorage (= 6.0.2.1)
113
- activesupport (= 6.0.2.1)
114
- bundler (>= 1.3.0)
115
- railties (= 6.0.2.1)
102
+ rails (6.1.4.4)
103
+ actioncable (= 6.1.4.4)
104
+ actionmailbox (= 6.1.4.4)
105
+ actionmailer (= 6.1.4.4)
106
+ actionpack (= 6.1.4.4)
107
+ actiontext (= 6.1.4.4)
108
+ actionview (= 6.1.4.4)
109
+ activejob (= 6.1.4.4)
110
+ activemodel (= 6.1.4.4)
111
+ activerecord (= 6.1.4.4)
112
+ activestorage (= 6.1.4.4)
113
+ activesupport (= 6.1.4.4)
114
+ bundler (>= 1.15.0)
115
+ railties (= 6.1.4.4)
116
116
  sprockets-rails (>= 2.0.0)
117
117
  rails-dom-testing (2.0.3)
118
118
  activesupport (>= 4.2.0)
119
119
  nokogiri (>= 1.6)
120
- rails-html-sanitizer (1.3.0)
120
+ rails-html-sanitizer (1.4.2)
121
121
  loofah (~> 2.3)
122
- railties (6.0.2.1)
123
- actionpack (= 6.0.2.1)
124
- activesupport (= 6.0.2.1)
122
+ railties (6.1.4.4)
123
+ actionpack (= 6.1.4.4)
124
+ activesupport (= 6.1.4.4)
125
125
  method_source
126
- rake (>= 0.8.7)
127
- thor (>= 0.20.3, < 2.0)
128
- rake (13.0.1)
129
- rspec (3.9.0)
130
- rspec-core (~> 3.9.0)
131
- rspec-expectations (~> 3.9.0)
132
- rspec-mocks (~> 3.9.0)
133
- rspec-core (3.9.1)
134
- rspec-support (~> 3.9.1)
135
- rspec-expectations (3.9.0)
126
+ rake (>= 0.13)
127
+ thor (~> 1.0)
128
+ rake (13.0.6)
129
+ rspec (3.10.0)
130
+ rspec-core (~> 3.10.0)
131
+ rspec-expectations (~> 3.10.0)
132
+ rspec-mocks (~> 3.10.0)
133
+ rspec-core (3.10.2)
134
+ rspec-support (~> 3.10.0)
135
+ rspec-expectations (3.10.2)
136
136
  diff-lcs (>= 1.2.0, < 2.0)
137
- rspec-support (~> 3.9.0)
138
- rspec-mocks (3.9.1)
137
+ rspec-support (~> 3.10.0)
138
+ rspec-mocks (3.10.3)
139
139
  diff-lcs (>= 1.2.0, < 2.0)
140
- rspec-support (~> 3.9.0)
141
- rspec-support (3.9.2)
142
- sprockets (4.0.0)
140
+ rspec-support (~> 3.10.0)
141
+ rspec-support (3.10.3)
142
+ sprockets (4.0.2)
143
143
  concurrent-ruby (~> 1.0)
144
144
  rack (> 1, < 3)
145
- sprockets-rails (3.2.1)
146
- actionpack (>= 4.0)
147
- activesupport (>= 4.0)
145
+ sprockets-rails (3.4.2)
146
+ actionpack (>= 5.2)
147
+ activesupport (>= 5.2)
148
148
  sprockets (>= 3.0.0)
149
149
  sqlite3 (1.4.2)
150
- thor (1.0.1)
151
- thread_safe (0.3.6)
152
- tzinfo (1.2.6)
153
- thread_safe (~> 0.1)
154
- websocket-driver (0.7.1)
150
+ thor (1.2.1)
151
+ tzinfo (2.0.4)
152
+ concurrent-ruby (~> 1.0)
153
+ websocket-driver (0.7.5)
155
154
  websocket-extensions (>= 0.1.0)
156
155
  websocket-extensions (0.1.5)
157
- zeitwerk (2.3.0)
156
+ zeitwerk (2.5.4)
158
157
 
159
158
  PLATFORMS
160
- ruby
159
+ x86_64-darwin-19
161
160
 
162
161
  DEPENDENCIES
163
162
  bundler (~> 2.0)
@@ -165,10 +164,10 @@ DEPENDENCIES
165
164
  pagy_cursor!
166
165
  pg
167
166
  pry
168
- rails (~> 6.0.0)
167
+ rails (~> 6.1)
169
168
  rake (~> 13.0)
170
169
  rspec (~> 3.0)
171
170
  sqlite3
172
171
 
173
172
  BUNDLED WITH
174
- 2.1.4
173
+ 2.2.30
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
- gem "rails", "~> 6.0.0"
5
+ gem "rails", "~> 6.0"
6
6
  gem "pg"
7
7
  gem "sqlite3"
8
8
  gem "mysql2"
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gem "rails", "~> 6.1"
6
+ gem "pg"
7
+ gem "sqlite3"
8
+ gem "mysql2"
9
+ gem "pry"
10
+ # Specify your gem's dependencies in pagy_cursor.gemspec
11
+ gemspec path: "../"
@@ -10,7 +10,7 @@ class Pagy
10
10
  items = pagy_cursor_get_items(collection, pagy, pagy.position)
11
11
  pagy.has_more = pagy_cursor_has_more?(items, pagy)
12
12
 
13
- return pagy, items[0..pagy.items-1]
13
+ return pagy, items
14
14
  end
15
15
 
16
16
  def pagy_cursor_get_vars(collection, vars)
@@ -23,16 +23,17 @@ class Pagy
23
23
  def pagy_cursor_get_items(collection, pagy, position=nil)
24
24
  if position.present?
25
25
  sql_comparation = pagy.arel_table[pagy.primary_key].send(pagy.comparation, position)
26
- collection.where(sql_comparation).reorder(pagy.order).limit(pagy.items + 1)
26
+ collection.where(sql_comparation).reorder(pagy.order).limit(pagy.items)
27
27
  else
28
- collection.reorder(pagy.order).limit(pagy.items + 1)
28
+ collection.reorder(pagy.order).limit(pagy.items)
29
29
  end
30
30
  end
31
31
 
32
32
  def pagy_cursor_has_more?(collection, pagy)
33
33
  return false if collection.empty?
34
34
 
35
- collection.size > pagy.items
35
+ next_position = collection.last[pagy.primary_key]
36
+ pagy_cursor_get_items(collection, pagy, next_position).exists?
36
37
  end
37
38
  end
38
39
  end
@@ -9,7 +9,7 @@ class Pagy
9
9
  items = pagy_uuid_cursor_get_items(collection, pagy, pagy.position)
10
10
  pagy.has_more = pagy_uuid_cursor_has_more?(items, pagy)
11
11
 
12
- return pagy, items[0..pagy.items-1]
12
+ return pagy, items
13
13
  end
14
14
 
15
15
  def pagy_uuid_cursor_get_vars(collection, vars)
@@ -29,13 +29,14 @@ class Pagy
29
29
 
30
30
  collection = collection.where(sql_comparation)
31
31
  end
32
- collection.reorder(pagy.order).limit(pagy.items + 1)
32
+ collection.reorder(pagy.order).limit(pagy.items)
33
33
  end
34
34
 
35
35
  def pagy_uuid_cursor_has_more?(collection, pagy)
36
36
  return false if collection.empty?
37
37
 
38
- collection.size > pagy.items
38
+ next_position = collection.last[pagy.primary_key]
39
+ pagy_uuid_cursor_get_items(collection, pagy, next_position).exists?
39
40
  end
40
41
  end
41
42
  end
@@ -1,3 +1,3 @@
1
1
  module PagyCursor
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy_cursor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uysim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2022-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pagy
@@ -103,6 +103,7 @@ files:
103
103
  - gemfiles/active_record_51.gemfile
104
104
  - gemfiles/active_record_52.gemfile
105
105
  - gemfiles/active_record_60.gemfile
106
+ - gemfiles/active_record_61.gemfile
106
107
  - lib/pagy_cursor.rb
107
108
  - lib/pagy_cursor/pagy/cursor.rb
108
109
  - lib/pagy_cursor/pagy/extras/cursor.rb
@@ -128,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
129
  - !ruby/object:Gem::Version
129
130
  version: '0'
130
131
  requirements: []
131
- rubygems_version: 3.2.22
132
+ rubygems_version: 3.2.32
132
133
  signing_key:
133
134
  specification_version: 4
134
135
  summary: cursor paginations for pagy