pagy_cursor 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aeef340ec1e16f142493c13d33e9aff54b231be6e6bccbcd54407feafe8ee392
4
- data.tar.gz: 6e4f963a7cc5ae9d19c6a07327464989081e69bfc6c431fa672aad91dded0af7
3
+ metadata.gz: 1aa8174327f3bb06b60e699eee881febd9d18671244ce25ebe2800466ea40158
4
+ data.tar.gz: 559f1193f7628bf2ae5137f050b42520f470ef49de90372bd1c2641765d1ba28
5
5
  SHA512:
6
- metadata.gz: d78438ba52a1287c0c445d4e59a7688bf625116cd54468a6e879f2871361f9d3a2731c150ddb1c40f0c29c3dfdea387f0812cc2b20136ccdf4d511777565494b
7
- data.tar.gz: 5f0498e40683a5e51caa923845e56fcf9d9633f6cb22b48c5fb9453bffbf5007f43ca7e5e24ae65de194c68fe1bfe3d6e90d70783a877ec69fb4b73c00734cc2
6
+ metadata.gz: '0278d99df9abb81c852d8195e09376c7d3965f07a181357bfb16d3437aaa614240e59b81b7e9fc6f662370f6c1a26fe08bf54b920b9b08e092dffcebea866461'
7
+ data.tar.gz: 4a5469f8224cb91bf7f315f98f14a96e2488ebb24b76161834e9b6052b9a93de8fa8189e54beba3d1fee17e1965530e16cd0196556c9b3d597e6af6394d2c336
@@ -37,6 +37,9 @@ jobs:
37
37
  - ruby-version: 3.2
38
38
  env:
39
39
  BUNDLE_GEMFILE: gemfiles/active_record_70.gemfile
40
+ - ruby-version: 3.3
41
+ env:
42
+ BUNDLE_GEMFILE: gemfiles/active_record_71.gemfile
40
43
  fail-fast: false
41
44
  env: ${{ matrix.env }}
42
45
 
@@ -76,7 +79,7 @@ jobs:
76
79
  - ruby-version: 2.7
77
80
  env:
78
81
  BUNDLE_GEMFILE: gemfiles/active_record_52.gemfile
79
- - ruby-version: "3.0"
82
+ - ruby-version: 3.0
80
83
  env:
81
84
  BUNDLE_GEMFILE: gemfiles/active_record_61.gemfile
82
85
  - ruby-version: 3.1
@@ -85,6 +88,9 @@ jobs:
85
88
  - ruby-version: 3.2
86
89
  env:
87
90
  BUNDLE_GEMFILE: gemfiles/active_record_70.gemfile
91
+ - ruby-version: 3.3
92
+ env:
93
+ BUNDLE_GEMFILE: gemfiles/active_record_71.gemfile
88
94
  fail-fast: false
89
95
  env: ${{ matrix.env }}
90
96
  steps:
data/Gemfile CHANGED
@@ -2,10 +2,10 @@ source "https://rubygems.org"
2
2
 
3
3
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
- gem "rails", "~> 7.0.0"
5
+ gem "rails", "~> 7.1.0"
6
6
  gem "pg"
7
- gem "sqlite3"
8
- # gem "mysql2"
9
- gem "pry"
7
+ gem "sqlite3", "~> 1.4"
8
+ gem "mysql2"
9
+
10
10
  # Specify your gem's dependencies in pagy_cursor.gemspec
11
11
  gemspec path: "./"
data/Gemfile.lock CHANGED
@@ -1,188 +1,214 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pagy_cursor (0.6.0)
4
+ pagy_cursor (0.7.0)
5
5
  activerecord (>= 5)
6
- pagy (>= 6, < 7)
6
+ pagy (>= 6, < 9)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (7.0.4.3)
12
- actionpack (= 7.0.4.3)
13
- activesupport (= 7.0.4.3)
11
+ actioncable (7.1.3.4)
12
+ actionpack (= 7.1.3.4)
13
+ activesupport (= 7.1.3.4)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (7.0.4.3)
17
- actionpack (= 7.0.4.3)
18
- activejob (= 7.0.4.3)
19
- activerecord (= 7.0.4.3)
20
- activestorage (= 7.0.4.3)
21
- activesupport (= 7.0.4.3)
16
+ zeitwerk (~> 2.6)
17
+ actionmailbox (7.1.3.4)
18
+ actionpack (= 7.1.3.4)
19
+ activejob (= 7.1.3.4)
20
+ activerecord (= 7.1.3.4)
21
+ activestorage (= 7.1.3.4)
22
+ activesupport (= 7.1.3.4)
22
23
  mail (>= 2.7.1)
23
24
  net-imap
24
25
  net-pop
25
26
  net-smtp
26
- actionmailer (7.0.4.3)
27
- actionpack (= 7.0.4.3)
28
- actionview (= 7.0.4.3)
29
- activejob (= 7.0.4.3)
30
- activesupport (= 7.0.4.3)
27
+ actionmailer (7.1.3.4)
28
+ actionpack (= 7.1.3.4)
29
+ actionview (= 7.1.3.4)
30
+ activejob (= 7.1.3.4)
31
+ activesupport (= 7.1.3.4)
31
32
  mail (~> 2.5, >= 2.5.4)
32
33
  net-imap
33
34
  net-pop
34
35
  net-smtp
35
- rails-dom-testing (~> 2.0)
36
- actionpack (7.0.4.3)
37
- actionview (= 7.0.4.3)
38
- activesupport (= 7.0.4.3)
39
- rack (~> 2.0, >= 2.2.0)
36
+ rails-dom-testing (~> 2.2)
37
+ actionpack (7.1.3.4)
38
+ actionview (= 7.1.3.4)
39
+ activesupport (= 7.1.3.4)
40
+ nokogiri (>= 1.8.5)
41
+ racc
42
+ rack (>= 2.2.4)
43
+ rack-session (>= 1.0.1)
40
44
  rack-test (>= 0.6.3)
41
- rails-dom-testing (~> 2.0)
42
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
- actiontext (7.0.4.3)
44
- actionpack (= 7.0.4.3)
45
- activerecord (= 7.0.4.3)
46
- activestorage (= 7.0.4.3)
47
- activesupport (= 7.0.4.3)
45
+ rails-dom-testing (~> 2.2)
46
+ rails-html-sanitizer (~> 1.6)
47
+ actiontext (7.1.3.4)
48
+ actionpack (= 7.1.3.4)
49
+ activerecord (= 7.1.3.4)
50
+ activestorage (= 7.1.3.4)
51
+ activesupport (= 7.1.3.4)
48
52
  globalid (>= 0.6.0)
49
53
  nokogiri (>= 1.8.5)
50
- actionview (7.0.4.3)
51
- activesupport (= 7.0.4.3)
54
+ actionview (7.1.3.4)
55
+ activesupport (= 7.1.3.4)
52
56
  builder (~> 3.1)
53
- erubi (~> 1.4)
54
- rails-dom-testing (~> 2.0)
55
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
- activejob (7.0.4.3)
57
- activesupport (= 7.0.4.3)
57
+ erubi (~> 1.11)
58
+ rails-dom-testing (~> 2.2)
59
+ rails-html-sanitizer (~> 1.6)
60
+ activejob (7.1.3.4)
61
+ activesupport (= 7.1.3.4)
58
62
  globalid (>= 0.3.6)
59
- activemodel (7.0.4.3)
60
- activesupport (= 7.0.4.3)
61
- activerecord (7.0.4.3)
62
- activemodel (= 7.0.4.3)
63
- activesupport (= 7.0.4.3)
64
- activestorage (7.0.4.3)
65
- actionpack (= 7.0.4.3)
66
- activejob (= 7.0.4.3)
67
- activerecord (= 7.0.4.3)
68
- activesupport (= 7.0.4.3)
63
+ activemodel (7.1.3.4)
64
+ activesupport (= 7.1.3.4)
65
+ activerecord (7.1.3.4)
66
+ activemodel (= 7.1.3.4)
67
+ activesupport (= 7.1.3.4)
68
+ timeout (>= 0.4.0)
69
+ activestorage (7.1.3.4)
70
+ actionpack (= 7.1.3.4)
71
+ activejob (= 7.1.3.4)
72
+ activerecord (= 7.1.3.4)
73
+ activesupport (= 7.1.3.4)
69
74
  marcel (~> 1.0)
70
- mini_mime (>= 1.1.0)
71
- activesupport (7.0.4.3)
75
+ activesupport (7.1.3.4)
76
+ base64
77
+ bigdecimal
72
78
  concurrent-ruby (~> 1.0, >= 1.0.2)
79
+ connection_pool (>= 2.2.5)
80
+ drb
73
81
  i18n (>= 1.6, < 2)
74
82
  minitest (>= 5.1)
83
+ mutex_m
75
84
  tzinfo (~> 2.0)
76
- builder (3.2.4)
77
- coderay (1.1.3)
78
- concurrent-ruby (1.2.2)
85
+ base64 (0.2.0)
86
+ bigdecimal (3.1.8)
87
+ builder (3.3.0)
88
+ concurrent-ruby (1.3.3)
89
+ connection_pool (2.4.1)
79
90
  crass (1.0.6)
80
- date (3.3.3)
81
- diff-lcs (1.5.0)
82
- erubi (1.12.0)
83
- globalid (1.1.0)
84
- activesupport (>= 5.0)
85
- i18n (1.12.0)
91
+ date (3.3.4)
92
+ diff-lcs (1.5.1)
93
+ drb (2.2.1)
94
+ erubi (1.13.0)
95
+ globalid (1.2.1)
96
+ activesupport (>= 6.1)
97
+ i18n (1.14.5)
86
98
  concurrent-ruby (~> 1.0)
87
- loofah (2.20.0)
99
+ io-console (0.7.2)
100
+ irb (1.14.0)
101
+ rdoc (>= 4.0.0)
102
+ reline (>= 0.4.2)
103
+ loofah (2.22.0)
88
104
  crass (~> 1.0.2)
89
- nokogiri (>= 1.5.9)
105
+ nokogiri (>= 1.12.0)
90
106
  mail (2.8.1)
91
107
  mini_mime (>= 0.1.1)
92
108
  net-imap
93
109
  net-pop
94
110
  net-smtp
95
- marcel (1.0.2)
96
- method_source (1.0.0)
97
- mini_mime (1.1.2)
98
- minitest (5.18.0)
99
- net-imap (0.3.4)
111
+ marcel (1.0.4)
112
+ mini_mime (1.1.5)
113
+ minitest (5.24.1)
114
+ mutex_m (0.2.0)
115
+ mysql2 (0.5.6)
116
+ net-imap (0.4.14)
100
117
  date
101
118
  net-protocol
102
119
  net-pop (0.1.2)
103
120
  net-protocol
104
- net-protocol (0.2.1)
121
+ net-protocol (0.2.2)
105
122
  timeout
106
- net-smtp (0.3.3)
123
+ net-smtp (0.5.0)
107
124
  net-protocol
108
- nio4r (2.5.9)
109
- nokogiri (1.14.3-arm64-darwin)
110
- racc (~> 1.4)
111
- nokogiri (1.14.3-x86_64-darwin)
125
+ nio4r (2.7.3)
126
+ nokogiri (1.16.7-x86_64-linux)
112
127
  racc (~> 1.4)
113
- pagy (6.0.3)
114
- pg (1.4.6)
115
- pry (0.14.2)
116
- coderay (~> 1.1)
117
- method_source (~> 1.0)
118
- racc (1.6.2)
119
- rack (2.2.6.4)
128
+ pagy (8.6.3)
129
+ pg (1.5.7)
130
+ psych (5.1.2)
131
+ stringio
132
+ racc (1.8.1)
133
+ rack (3.1.7)
134
+ rack-session (2.0.0)
135
+ rack (>= 3.0.0)
120
136
  rack-test (2.1.0)
121
137
  rack (>= 1.3)
122
- rails (7.0.4.3)
123
- actioncable (= 7.0.4.3)
124
- actionmailbox (= 7.0.4.3)
125
- actionmailer (= 7.0.4.3)
126
- actionpack (= 7.0.4.3)
127
- actiontext (= 7.0.4.3)
128
- actionview (= 7.0.4.3)
129
- activejob (= 7.0.4.3)
130
- activemodel (= 7.0.4.3)
131
- activerecord (= 7.0.4.3)
132
- activestorage (= 7.0.4.3)
133
- activesupport (= 7.0.4.3)
138
+ rackup (2.1.0)
139
+ rack (>= 3)
140
+ webrick (~> 1.8)
141
+ rails (7.1.3.4)
142
+ actioncable (= 7.1.3.4)
143
+ actionmailbox (= 7.1.3.4)
144
+ actionmailer (= 7.1.3.4)
145
+ actionpack (= 7.1.3.4)
146
+ actiontext (= 7.1.3.4)
147
+ actionview (= 7.1.3.4)
148
+ activejob (= 7.1.3.4)
149
+ activemodel (= 7.1.3.4)
150
+ activerecord (= 7.1.3.4)
151
+ activestorage (= 7.1.3.4)
152
+ activesupport (= 7.1.3.4)
134
153
  bundler (>= 1.15.0)
135
- railties (= 7.0.4.3)
136
- rails-dom-testing (2.0.3)
137
- activesupport (>= 4.2.0)
154
+ railties (= 7.1.3.4)
155
+ rails-dom-testing (2.2.0)
156
+ activesupport (>= 5.0.0)
157
+ minitest
138
158
  nokogiri (>= 1.6)
139
- rails-html-sanitizer (1.5.0)
140
- loofah (~> 2.19, >= 2.19.1)
141
- railties (7.0.4.3)
142
- actionpack (= 7.0.4.3)
143
- activesupport (= 7.0.4.3)
144
- method_source
159
+ rails-html-sanitizer (1.6.0)
160
+ loofah (~> 2.21)
161
+ nokogiri (~> 1.14)
162
+ railties (7.1.3.4)
163
+ actionpack (= 7.1.3.4)
164
+ activesupport (= 7.1.3.4)
165
+ irb
166
+ rackup (>= 1.0.0)
145
167
  rake (>= 12.2)
146
- thor (~> 1.0)
147
- zeitwerk (~> 2.5)
148
- rake (13.0.6)
149
- rspec (3.12.0)
150
- rspec-core (~> 3.12.0)
151
- rspec-expectations (~> 3.12.0)
152
- rspec-mocks (~> 3.12.0)
153
- rspec-core (3.12.2)
154
- rspec-support (~> 3.12.0)
155
- rspec-expectations (3.12.3)
168
+ thor (~> 1.0, >= 1.2.2)
169
+ zeitwerk (~> 2.6)
170
+ rake (13.2.1)
171
+ rdoc (6.7.0)
172
+ psych (>= 4.0.0)
173
+ reline (0.5.9)
174
+ io-console (~> 0.5)
175
+ rspec (3.13.0)
176
+ rspec-core (~> 3.13.0)
177
+ rspec-expectations (~> 3.13.0)
178
+ rspec-mocks (~> 3.13.0)
179
+ rspec-core (3.13.0)
180
+ rspec-support (~> 3.13.0)
181
+ rspec-expectations (3.13.1)
156
182
  diff-lcs (>= 1.2.0, < 2.0)
157
- rspec-support (~> 3.12.0)
158
- rspec-mocks (3.12.5)
183
+ rspec-support (~> 3.13.0)
184
+ rspec-mocks (3.13.1)
159
185
  diff-lcs (>= 1.2.0, < 2.0)
160
- rspec-support (~> 3.12.0)
161
- rspec-support (3.12.0)
162
- sqlite3 (1.6.2-arm64-darwin)
163
- sqlite3 (1.6.2-x86_64-darwin)
164
- thor (1.2.1)
165
- timeout (0.3.2)
186
+ rspec-support (~> 3.13.0)
187
+ rspec-support (3.13.1)
188
+ sqlite3 (1.7.3-x86_64-linux)
189
+ stringio (3.1.1)
190
+ thor (1.3.1)
191
+ timeout (0.4.1)
166
192
  tzinfo (2.0.6)
167
193
  concurrent-ruby (~> 1.0)
168
- websocket-driver (0.7.5)
194
+ webrick (1.8.1)
195
+ websocket-driver (0.7.6)
169
196
  websocket-extensions (>= 0.1.0)
170
197
  websocket-extensions (0.1.5)
171
- zeitwerk (2.6.7)
198
+ zeitwerk (2.6.17)
172
199
 
173
200
  PLATFORMS
174
- arm64-darwin-21
175
- x86_64-darwin-19
201
+ x86_64-linux
176
202
 
177
203
  DEPENDENCIES
178
- bundler (~> 2.0)
204
+ bundler (~> 2)
205
+ mysql2
179
206
  pagy_cursor!
180
207
  pg
181
- pry
182
- rails (~> 7.0.0)
183
- rake (~> 13.0)
184
- rspec (~> 3.0)
185
- sqlite3
208
+ rails (~> 7.1.0)
209
+ rake (~> 13)
210
+ rspec (~> 3)
211
+ sqlite3 (~> 1.4)
186
212
 
187
213
  BUNDLED WITH
188
- 2.2.22
214
+ 2.5.11
data/README.md CHANGED
@@ -58,6 +58,7 @@ Many thanks to:
58
58
  - [Hirokazu Hata](https://github.com/h-michael)
59
59
  - [M. Yunan Helmy](https://github.com/yunanhelmy)
60
60
  - [Eumir Gaspar](https://github.com/corroded)
61
+ - [Jasl](https://github.com/jasl)
61
62
 
62
63
  ## Support Databases
63
64
 
@@ -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", "~> 7.1.0"
6
+ gem "pg"
7
+ gem "sqlite3", "~> 1.4"
8
+ gem "mysql2"
9
+
10
+ # Specify your gem's dependencies in pagy_cursor.gemspec
11
+ gemspec path: "../"
@@ -1,12 +1,13 @@
1
- class Pagy
1
+ # frozen_string_literal: true
2
2
 
3
+ class Pagy
3
4
  class Cursor < Pagy
4
- attr_reader :before, :after, :arel_table, :primary_key, :order, :comparation, :position
5
+ attr_reader :before, :after, :arel_table, :primary_key, :order, :comparison, :position
5
6
  attr_accessor :has_more
6
7
  alias_method :has_more?, :has_more
7
8
 
8
9
  def initialize(vars)
9
- @vars = DEFAULT.merge(vars.delete_if{|_,v| v.nil? || v == '' })
10
+ @vars = DEFAULT.merge(vars.delete_if { |_, v| v.nil? || v == "" })
10
11
  @items = vars[:items] || DEFAULT[:items]
11
12
  @before = vars[:before]
12
13
  @after = vars[:after]
@@ -15,32 +16,30 @@ class Pagy
15
16
  @reorder = vars[:order] || {}
16
17
 
17
18
  if @before.present? and @after.present?
18
- raise(ArgumentError, 'before and after can not be both mentioned')
19
+ raise(ArgumentError, "before and after can not be both mentioned")
19
20
  end
20
21
 
21
- if vars[:backend] == 'uuid'
22
-
23
- @comparation = 'lt' # arel table less than
22
+ if vars[:backend] == "uuid"
23
+ @comparison = "lt" # arel table less than
24
24
  @position = @before
25
- @order = @reorder.merge({ :created_at => :desc , @primary_key => :desc })
25
+ @order = @reorder.merge({ :created_at => :desc, @primary_key => :desc })
26
26
 
27
- if @after.present? || (@reorder.present? && @reorder.values.uniq.first.to_sym == :asc)
28
- @comparation = 'gt' # arel table greater than
27
+ if @after.present? || (@reorder.present? && @reorder.values.uniq.first&.to_sym == :asc)
28
+ @comparison = "gt" # arel table greater than
29
29
  @position = @after
30
- @order = @reorder.merge({ :created_at => :asc , @primary_key => :asc })
30
+ @order = @reorder.merge({ :created_at => :asc, @primary_key => :asc })
31
31
  end
32
32
  else
33
-
34
- @comparation = 'lt'
33
+ @comparison = "lt"
35
34
  @position = @before
36
35
  @order = @reorder.merge({ @primary_key => :desc })
37
36
 
38
- if @after.present? || (@reorder.present? && @reorder.values.uniq.first.to_sym == :asc)
39
- @comparation = 'gt'
37
+ if @after.present? || (@reorder.present? && @reorder.values.uniq.first&.to_sym == :asc)
38
+ @comparison = "gt"
40
39
  @position = @after
41
40
  @order = @reorder.merge({ @primary_key => :asc })
42
41
  end
43
42
  end
44
43
  end
45
44
  end
46
- end
45
+ end
@@ -1,29 +1,30 @@
1
- require 'pagy_cursor/pagy/cursor'
2
- class Pagy
3
-
4
- module Backend ; private # the whole module is private so no problem with including it in a controller
1
+ # frozen_string_literal: true
5
2
 
3
+ class Pagy
4
+ module Backend; private # the whole module is private so no problem with including it in a controller
6
5
  # Return Pagy object and items
7
- def pagy_cursor(collection, vars={}, options={})
6
+ def pagy_cursor(collection, vars = {})
8
7
  pagy = Pagy::Cursor.new(pagy_cursor_get_vars(collection, vars))
9
8
 
10
- items = pagy_cursor_get_items(collection, pagy, pagy.position)
11
- pagy.has_more = pagy_cursor_has_more?(items, pagy)
9
+ items = pagy_cursor_get_items(collection, pagy, pagy.position)
10
+ pagy.has_more = pagy_cursor_has_more?(items, pagy)
12
11
 
13
- return pagy, items
12
+ [pagy, items]
14
13
  end
15
14
 
16
15
  def pagy_cursor_get_vars(collection, vars)
16
+ pagy_set_items_from_params(vars) if defined?(ItemsExtra)
17
+
17
18
  vars[:arel_table] = collection.arel_table
18
19
  vars[:primary_key] = collection.primary_key
19
- vars[:backend] = 'sequence'
20
+ vars[:backend] = "sequence"
20
21
  vars
21
22
  end
22
23
 
23
- def pagy_cursor_get_items(collection, pagy, position=nil)
24
+ def pagy_cursor_get_items(collection, pagy, position = nil)
24
25
  if position.present?
25
- sql_comparation = pagy.arel_table[pagy.primary_key].send(pagy.comparation, position)
26
- collection.where(sql_comparation).reorder(pagy.order).limit(pagy.items)
26
+ sql_comparison = pagy.arel_table[pagy.primary_key].send(pagy.comparison, position)
27
+ collection.where(sql_comparison).reorder(pagy.order).limit(pagy.items)
27
28
  else
28
29
  collection.reorder(pagy.order).limit(pagy.items)
29
30
  end
@@ -1,25 +1,26 @@
1
- require 'pagy_cursor/pagy/cursor'
2
- class Pagy
3
-
4
- module Backend ; private # the whole module is private so no problem with including it in a controller
1
+ # frozen_string_literal: true
5
2
 
3
+ class Pagy
4
+ module Backend; private # the whole module is private so no problem with including it in a controller
6
5
  # Return Pagy object and items
7
- def pagy_uuid_cursor(collection, vars={})
6
+ def pagy_uuid_cursor(collection, vars = {})
8
7
  pagy = Pagy::Cursor.new(pagy_uuid_cursor_get_vars(collection, vars))
9
- items = pagy_uuid_cursor_get_items(collection, pagy, pagy.position)
10
- pagy.has_more = pagy_uuid_cursor_has_more?(items, pagy)
8
+ items = pagy_uuid_cursor_get_items(collection, pagy, pagy.position)
9
+ pagy.has_more = pagy_uuid_cursor_has_more?(items, pagy)
11
10
 
12
11
  return pagy, items
13
12
  end
14
13
 
15
14
  def pagy_uuid_cursor_get_vars(collection, vars)
15
+ pagy_set_items_from_params(vars) if defined?(ItemsExtra)
16
+
16
17
  vars[:arel_table] = collection.arel_table
17
18
  vars[:primary_key] = collection.primary_key
18
- vars[:backend] = 'uuid'
19
+ vars[:backend] = "uuid"
19
20
  vars
20
21
  end
21
22
 
22
- def pagy_uuid_cursor_get_items(collection, pagy, position=nil)
23
+ def pagy_uuid_cursor_get_items(collection, pagy, position = nil)
23
24
  if position.present?
24
25
  arel_table = pagy.arel_table
25
26
 
@@ -28,19 +29,19 @@ class Pagy
28
29
  # Select the primary sort key
29
30
  # pagy.order should be something like:
30
31
  # [:created_at, :id] or [:foo_column, ..., :created_at, :id]
31
- primary_sort_key = pagy.order.keys.detect{ |order_key| ![:created_at, :id].include?(order_key.to_sym) } || :created_at
32
+ primary_sort_key = pagy.order.keys.detect { |order_key| ![:created_at, :id].include?(order_key.to_sym) } || :created_at
32
33
 
33
34
  select_previous_row = arel_table.project(arel_table[primary_sort_key]).
34
35
  where(arel_table[pagy.primary_key].eq(position))
35
36
 
36
- sql_comparation = arel_table[primary_sort_key].
37
- send(pagy.comparation, select_previous_row).
37
+ sql_comparison = arel_table[primary_sort_key].
38
+ send(pagy.comparison, select_previous_row).
38
39
  or(
39
40
  arel_table[primary_sort_key].eq(select_previous_row).
40
- and(arel_table[pagy.primary_key].send(pagy.comparation, position))
41
+ and(arel_table[pagy.primary_key].send(pagy.comparison, position))
41
42
  )
42
43
 
43
- collection = collection.where(sql_comparation)
44
+ collection = collection.where(sql_comparison)
44
45
  end
45
46
  collection.reorder(pagy.order).limit(pagy.items)
46
47
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PagyCursor
2
- VERSION = "0.6.1"
4
+ VERSION = "0.8.0"
3
5
  end
data/lib/pagy_cursor.rb CHANGED
@@ -1,6 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "pagy"
4
+ require "pagy_cursor/pagy/cursor"
5
+ require "pagy_cursor/pagy/extras/cursor"
6
+ require "pagy_cursor/pagy/extras/uuid_cursor"
7
+
2
8
  require "pagy_cursor/version"
9
+
3
10
  module PagyCursor
4
- class Error < StandardError; end
5
- # Your code goes here...
6
11
  end
data/pagy_cursor.gemspec CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "pagy_cursor/version"
@@ -9,8 +8,8 @@ Gem::Specification.new do |spec|
9
8
  spec.authors = ["Uysim"]
10
9
  spec.email = ["uysimty@gmail.com"]
11
10
 
12
- spec.summary = "cursor paginations for pagy"
13
- spec.description = "use pagy for cursor paginations with rails"
11
+ spec.summary = "cursor-based pagination for pagy"
12
+ spec.description = "use pagy for cursor-based pagination with rails"
14
13
  spec.homepage = "https://github.com/Uysim/pagy-cursor"
15
14
  spec.license = "MIT"
16
15
 
@@ -22,10 +21,10 @@ Gem::Specification.new do |spec|
22
21
  spec.bindir = "exe"
23
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
23
  spec.require_paths = ["lib"]
25
- spec.add_dependency "pagy", ">= 6", "< 7"
24
+ spec.add_dependency "pagy", ">= 6", "< 9"
26
25
  spec.add_dependency "activerecord", ">= 5"
27
26
 
28
- spec.add_development_dependency "bundler", "~> 2.0"
29
- spec.add_development_dependency "rake", "~> 13.0"
30
- spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "bundler", "~> 2"
28
+ spec.add_development_dependency "rake", "~> 13"
29
+ spec.add_development_dependency "rspec", "~> 3"
31
30
  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.6.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uysim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-11 00:00:00.000000000 Z
11
+ date: 2024-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pagy
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '6'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '9'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '6'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '9'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activerecord
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -50,43 +50,43 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '2.0'
53
+ version: '2'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '2.0'
60
+ version: '2'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '13.0'
67
+ version: '13'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '13.0'
74
+ version: '13'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rspec
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '3.0'
81
+ version: '3'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '3.0'
89
- description: use pagy for cursor paginations with rails
88
+ version: '3'
89
+ description: use pagy for cursor-based pagination with rails
90
90
  email:
91
91
  - uysimty@gmail.com
92
92
  executables: []
@@ -108,6 +108,7 @@ files:
108
108
  - gemfiles/active_record_52.gemfile
109
109
  - gemfiles/active_record_61.gemfile
110
110
  - gemfiles/active_record_70.gemfile
111
+ - gemfiles/active_record_71.gemfile
111
112
  - lib/pagy_cursor.rb
112
113
  - lib/pagy_cursor/pagy/cursor.rb
113
114
  - lib/pagy_cursor/pagy/extras/cursor.rb
@@ -133,8 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  - !ruby/object:Gem::Version
134
135
  version: '0'
135
136
  requirements: []
136
- rubygems_version: 3.3.26
137
+ rubygems_version: 3.4.19
137
138
  signing_key:
138
139
  specification_version: 4
139
- summary: cursor paginations for pagy
140
+ summary: cursor-based pagination for pagy
140
141
  test_files: []