geared_pagination 1.0.2 → 1.1.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: 6c0df2ffda60431042065c8239bc92687ff300db3d4e6ffaa0f711334004ce7b
4
- data.tar.gz: 5dbc61434adb9fe75618fb3e0ab075eea9abf90867de2e3f104cf1435b10a91e
3
+ metadata.gz: e47e02d5c3c03e2a1fdcfefba1e637b18f657ae70cfd7ba856c8196549cdcd11
4
+ data.tar.gz: 1f14405e08bdad25c2d8a0d7b8d3beb6b60841f2b34c3f9b08eb63fd1260a348
5
5
  SHA512:
6
- metadata.gz: 1a789e055a1a1a6686e64dbd2bffc91e39caca801dfaee071fe6a1afd9a445fc006b01b4df2917dd1befaafb26278331ddadce9d7f2c2714b42c4f98e394632b
7
- data.tar.gz: 0d635bfa95bbedcb9e34111413d60d1fb486dcbc80d2a2567921525fc2170b8e637a4bd65ef9cc2235ed2446c9c3ecfa3060e6ce45cae662eed5c0ec6b785f16
6
+ metadata.gz: d48fc3e0cba4123df563a29081afd854f8af253c9ff39abb2a65e50bc83373974cd8cfb71334704ab3b9833cd43e32f364119d1475b46ec6dae54a2b7bc8f9c1
7
+ data.tar.gz: 743b038bbcc2d062fb4917b3c2842b9be34283e504b0150d74ba6260a021183267b68b7fc2806e31f0bd74021913be55fe046779d41bb6edda25be17eadd5785
@@ -7,10 +7,10 @@ jobs:
7
7
  steps:
8
8
  - uses: actions/checkout@v1
9
9
 
10
- - name: Set up Ruby 2.6
10
+ - name: Set up Ruby 2.7
11
11
  uses: actions/setup-ruby@v1
12
12
  with:
13
- ruby-version: 2.6.x
13
+ ruby-version: 2.7.x
14
14
 
15
15
  - name: Cache gem dependencies
16
16
  uses: actions/cache@v1
data/Gemfile.lock CHANGED
@@ -1,141 +1,160 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geared_pagination (1.0.2)
4
+ geared_pagination (1.1.2)
5
5
  activesupport (>= 5.0)
6
6
  addressable (>= 2.5.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (6.0.3)
12
- actionpack (= 6.0.3)
11
+ actioncable (7.0.3)
12
+ actionpack (= 7.0.3)
13
+ activesupport (= 7.0.3)
13
14
  nio4r (~> 2.0)
14
15
  websocket-driver (>= 0.6.1)
15
- actionmailbox (6.0.3)
16
- actionpack (= 6.0.3)
17
- activejob (= 6.0.3)
18
- activerecord (= 6.0.3)
19
- activestorage (= 6.0.3)
20
- activesupport (= 6.0.3)
16
+ actionmailbox (7.0.3)
17
+ actionpack (= 7.0.3)
18
+ activejob (= 7.0.3)
19
+ activerecord (= 7.0.3)
20
+ activestorage (= 7.0.3)
21
+ activesupport (= 7.0.3)
21
22
  mail (>= 2.7.1)
22
- actionmailer (6.0.3)
23
- actionpack (= 6.0.3)
24
- actionview (= 6.0.3)
25
- activejob (= 6.0.3)
23
+ net-imap
24
+ net-pop
25
+ net-smtp
26
+ actionmailer (7.0.3)
27
+ actionpack (= 7.0.3)
28
+ actionview (= 7.0.3)
29
+ activejob (= 7.0.3)
30
+ activesupport (= 7.0.3)
26
31
  mail (~> 2.5, >= 2.5.4)
32
+ net-imap
33
+ net-pop
34
+ net-smtp
27
35
  rails-dom-testing (~> 2.0)
28
- actionpack (6.0.3)
29
- actionview (= 6.0.3)
30
- activesupport (= 6.0.3)
31
- rack (~> 2.0, >= 2.0.8)
36
+ actionpack (7.0.3)
37
+ actionview (= 7.0.3)
38
+ activesupport (= 7.0.3)
39
+ rack (~> 2.0, >= 2.2.0)
32
40
  rack-test (>= 0.6.3)
33
41
  rails-dom-testing (~> 2.0)
34
42
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
- actiontext (6.0.3)
36
- actionpack (= 6.0.3)
37
- activerecord (= 6.0.3)
38
- activestorage (= 6.0.3)
39
- activesupport (= 6.0.3)
43
+ actiontext (7.0.3)
44
+ actionpack (= 7.0.3)
45
+ activerecord (= 7.0.3)
46
+ activestorage (= 7.0.3)
47
+ activesupport (= 7.0.3)
48
+ globalid (>= 0.6.0)
40
49
  nokogiri (>= 1.8.5)
41
- actionview (6.0.3)
42
- activesupport (= 6.0.3)
50
+ actionview (7.0.3)
51
+ activesupport (= 7.0.3)
43
52
  builder (~> 3.1)
44
53
  erubi (~> 1.4)
45
54
  rails-dom-testing (~> 2.0)
46
55
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
- activejob (6.0.3)
48
- activesupport (= 6.0.3)
56
+ activejob (7.0.3)
57
+ activesupport (= 7.0.3)
49
58
  globalid (>= 0.3.6)
50
- activemodel (6.0.3)
51
- activesupport (= 6.0.3)
52
- activerecord (6.0.3)
53
- activemodel (= 6.0.3)
54
- activesupport (= 6.0.3)
55
- activestorage (6.0.3)
56
- actionpack (= 6.0.3)
57
- activejob (= 6.0.3)
58
- activerecord (= 6.0.3)
59
- marcel (~> 0.3.1)
60
- activesupport (6.0.3)
59
+ activemodel (7.0.3)
60
+ activesupport (= 7.0.3)
61
+ activerecord (7.0.3)
62
+ activemodel (= 7.0.3)
63
+ activesupport (= 7.0.3)
64
+ activestorage (7.0.3)
65
+ actionpack (= 7.0.3)
66
+ activejob (= 7.0.3)
67
+ activerecord (= 7.0.3)
68
+ activesupport (= 7.0.3)
69
+ marcel (~> 1.0)
70
+ mini_mime (>= 1.1.0)
71
+ activesupport (7.0.3)
61
72
  concurrent-ruby (~> 1.0, >= 1.0.2)
62
- i18n (>= 0.7, < 2)
63
- minitest (~> 5.1)
64
- tzinfo (~> 1.1)
65
- zeitwerk (~> 2.2, >= 2.2.2)
66
- addressable (2.7.0)
73
+ i18n (>= 1.6, < 2)
74
+ minitest (>= 5.1)
75
+ tzinfo (~> 2.0)
76
+ addressable (2.8.0)
67
77
  public_suffix (>= 2.0.2, < 5.0)
68
78
  builder (3.2.4)
69
- byebug (10.0.2)
70
- concurrent-ruby (1.1.6)
79
+ byebug (11.1.3)
80
+ concurrent-ruby (1.1.10)
71
81
  crass (1.0.6)
72
- erubi (1.9.0)
73
- globalid (0.4.2)
74
- activesupport (>= 4.2.0)
75
- i18n (1.8.2)
82
+ digest (3.1.0)
83
+ erubi (1.10.0)
84
+ globalid (1.0.0)
85
+ activesupport (>= 5.0)
86
+ i18n (1.10.0)
76
87
  concurrent-ruby (~> 1.0)
77
- loofah (2.5.0)
88
+ loofah (2.18.0)
78
89
  crass (~> 1.0.2)
79
90
  nokogiri (>= 1.5.9)
80
91
  mail (2.7.1)
81
92
  mini_mime (>= 0.1.1)
82
- marcel (0.3.3)
83
- mimemagic (~> 0.3.2)
93
+ marcel (1.0.2)
84
94
  method_source (1.0.0)
85
- mimemagic (0.3.5)
86
- mini_mime (1.0.2)
87
- mini_portile2 (2.4.0)
88
- minitest (5.14.0)
89
- nio4r (2.5.2)
90
- nokogiri (1.10.9)
91
- mini_portile2 (~> 2.4.0)
92
- public_suffix (4.0.6)
93
- rack (2.2.2)
95
+ mini_mime (1.1.2)
96
+ mini_portile2 (2.8.0)
97
+ minitest (5.15.0)
98
+ net-imap (0.2.3)
99
+ digest
100
+ net-protocol
101
+ strscan
102
+ net-pop (0.1.1)
103
+ digest
104
+ net-protocol
105
+ timeout
106
+ net-protocol (0.1.3)
107
+ timeout
108
+ net-smtp (0.3.1)
109
+ digest
110
+ net-protocol
111
+ timeout
112
+ nio4r (2.5.8)
113
+ nokogiri (1.13.6)
114
+ mini_portile2 (~> 2.8.0)
115
+ racc (~> 1.4)
116
+ public_suffix (4.0.7)
117
+ racc (1.6.0)
118
+ rack (2.2.3.1)
94
119
  rack-test (1.1.0)
95
120
  rack (>= 1.0, < 3)
96
- rails (6.0.3)
97
- actioncable (= 6.0.3)
98
- actionmailbox (= 6.0.3)
99
- actionmailer (= 6.0.3)
100
- actionpack (= 6.0.3)
101
- actiontext (= 6.0.3)
102
- actionview (= 6.0.3)
103
- activejob (= 6.0.3)
104
- activemodel (= 6.0.3)
105
- activerecord (= 6.0.3)
106
- activestorage (= 6.0.3)
107
- activesupport (= 6.0.3)
108
- bundler (>= 1.3.0)
109
- railties (= 6.0.3)
110
- sprockets-rails (>= 2.0.0)
121
+ rails (7.0.3)
122
+ actioncable (= 7.0.3)
123
+ actionmailbox (= 7.0.3)
124
+ actionmailer (= 7.0.3)
125
+ actionpack (= 7.0.3)
126
+ actiontext (= 7.0.3)
127
+ actionview (= 7.0.3)
128
+ activejob (= 7.0.3)
129
+ activemodel (= 7.0.3)
130
+ activerecord (= 7.0.3)
131
+ activestorage (= 7.0.3)
132
+ activesupport (= 7.0.3)
133
+ bundler (>= 1.15.0)
134
+ railties (= 7.0.3)
111
135
  rails-dom-testing (2.0.3)
112
136
  activesupport (>= 4.2.0)
113
137
  nokogiri (>= 1.6)
114
- rails-html-sanitizer (1.3.0)
138
+ rails-html-sanitizer (1.4.3)
115
139
  loofah (~> 2.3)
116
- railties (6.0.3)
117
- actionpack (= 6.0.3)
118
- activesupport (= 6.0.3)
140
+ railties (7.0.3)
141
+ actionpack (= 7.0.3)
142
+ activesupport (= 7.0.3)
119
143
  method_source
120
- rake (>= 0.8.7)
121
- thor (>= 0.20.3, < 2.0)
122
- rake (13.0.1)
123
- sprockets (4.0.0)
124
- concurrent-ruby (~> 1.0)
125
- rack (> 1, < 3)
126
- sprockets-rails (3.2.1)
127
- actionpack (>= 4.0)
128
- activesupport (>= 4.0)
129
- sprockets (>= 3.0.0)
144
+ rake (>= 12.2)
145
+ thor (~> 1.0)
146
+ zeitwerk (~> 2.5)
147
+ rake (13.0.6)
130
148
  sqlite3 (1.4.2)
131
- thor (1.0.1)
132
- thread_safe (0.3.6)
133
- tzinfo (1.2.7)
134
- thread_safe (~> 0.1)
135
- websocket-driver (0.7.1)
149
+ strscan (3.0.3)
150
+ thor (1.2.1)
151
+ timeout (0.3.0)
152
+ tzinfo (2.0.4)
153
+ concurrent-ruby (~> 1.0)
154
+ websocket-driver (0.7.5)
136
155
  websocket-extensions (>= 0.1.0)
137
- websocket-extensions (0.1.4)
138
- zeitwerk (2.3.0)
156
+ websocket-extensions (0.1.5)
157
+ zeitwerk (2.5.4)
139
158
 
140
159
  PLATFORMS
141
160
  ruby
@@ -149,4 +168,4 @@ DEPENDENCIES
149
168
  sqlite3
150
169
 
151
170
  BUNDLED WITH
152
- 1.17.2
171
+ 2.3.15
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'geared_pagination'
3
- s.version = '1.0.2'
3
+ s.version = '1.1.2'
4
4
  s.authors = 'David Heinemeier Hansson'
5
5
  s.email = 'david@basecamp.com'
6
6
  s.summary = 'Paginate Active Record sets at variable speeds'
@@ -6,6 +6,8 @@ module GearedPagination
6
6
  class << self
7
7
  def from_param(key)
8
8
  key.present? ? decode(key) : new
9
+ rescue ArgumentError, JSON::ParserError
10
+ new
9
11
  end
10
12
 
11
13
  def decode(key)
@@ -35,7 +35,11 @@ module GearedPagination
35
35
  end
36
36
 
37
37
  def last?
38
- number >= recordset.page_count
38
+ number == recordset.page_count
39
+ end
40
+
41
+ def before_last?
42
+ number < recordset.page_count
39
43
  end
40
44
 
41
45
 
@@ -32,7 +32,7 @@ module GearedPagination
32
32
  end
33
33
 
34
34
  def records_count
35
- @records_count ||= records.unscope(:limit).unscope(:offset).count
35
+ @records_count ||= records.unscope(:limit).unscope(:offset).unscope(:select).count
36
36
  end
37
37
 
38
38
  private
data/test/cursor_test.rb CHANGED
@@ -7,6 +7,11 @@ class GearedPagination::CursorTest < ActiveSupport::TestCase
7
7
  assert_equal 1, GearedPagination::Cursor.from_param(" ").page_number
8
8
  end
9
9
 
10
+ test "from an invalid param" do
11
+ assert_equal 1, GearedPagination::Cursor.from_param("aGVsbG8K").page_number
12
+ assert_equal 1, GearedPagination::Cursor.from_param("\o/ not base64").page_number
13
+ end
14
+
10
15
  test "decode" do
11
16
  assert_equal 1, GearedPagination::Cursor.decode("eyJwYWdlX251bWJlciI6MX0=").page_number
12
17
  end
@@ -44,14 +44,6 @@ Rails.application.configure do
44
44
  # Highlight code that triggered database queries in logs.
45
45
  config.active_record.verbose_query_logs = true
46
46
 
47
- # Debug mode disables concatenation and preprocessing of assets.
48
- # This option may cause significant delays in view rendering with a large
49
- # number of complex assets.
50
- config.assets.debug = true
51
-
52
- # Suppress logger output for asset requests.
53
- config.assets.quiet = true
54
-
55
47
  # Raises error for missing translations
56
48
  # config.action_view.raise_on_missing_translations = true
57
49
 
@@ -1,13 +1,5 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Version of your assets, change this if you want to expire all your assets.
4
- Rails.application.config.assets.version = '1.0'
5
-
6
- # Add additional assets to the asset load path.
7
- # Rails.application.config.assets.paths << Emoji.images_path
8
- # Add Yarn node_modules folder to the asset load path.
9
- Rails.application.config.assets.paths << Rails.root.join('node_modules')
10
-
11
3
  # Precompile additional assets.
12
4
  # application.js, application.css, and all non-JS/CSS in the app/assets
13
5
  # folder are already added.
data/test/page_test.rb CHANGED
@@ -20,8 +20,13 @@ class GearedPagination::PageTest < ActiveSupport::TestCase
20
20
  end
21
21
 
22
22
  test "last with page number greater than page count" do
23
- page_for_empty_set = GearedPagination::Recordset.new(Recording.none, per_page: 1000).page(2)
24
- assert page_for_empty_set.last?
23
+ assert_not GearedPagination::Recordset.new(Recording.none, per_page: 1000).page(2).last?
24
+ end
25
+
26
+ test "before_last" do
27
+ assert GearedPagination::Recordset.new(Recording.all, per_page: 1).page(1).before_last?
28
+ assert_not GearedPagination::Recordset.new(Recording.all, per_page: 1000).page(1).before_last?
29
+ assert_not GearedPagination::Recordset.new(Recording.none, per_page: 1000).page(2).before_last?
25
30
  end
26
31
 
27
32
  test "next offset param" do
@@ -70,4 +70,10 @@ class GearedPagination::RecordsetTest < ActiveSupport::TestCase
70
70
  test "records count" do
71
71
  assert_equal Recording.all.count, GearedPagination::Recordset.new(Recording.all, per_page: [ 10, 15, 20 ]).records_count
72
72
  end
73
+
74
+ test "unscope select for count" do
75
+ select_scoped_records = Recording.all.select(:id, :number)
76
+ recordset = GearedPagination::Recordset.new(select_scoped_records, per_page: [ 10, 15, 20 ])
77
+ assert_equal Recording.all.count, recordset.records_count
78
+ end
73
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geared_pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-14 00:00:00.000000000 Z
11
+ date: 2022-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.12'
55
- description:
55
+ description:
56
56
  email: david@basecamp.com
57
57
  executables: []
58
58
  extensions: []
@@ -162,7 +162,7 @@ homepage: https://github.com/basecamp/geared_pagination
162
162
  licenses:
163
163
  - MIT
164
164
  metadata: {}
165
- post_install_message:
165
+ post_install_message:
166
166
  rdoc_options: []
167
167
  require_paths:
168
168
  - lib
@@ -177,8 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  - !ruby/object:Gem::Version
178
178
  version: '0'
179
179
  requirements: []
180
- rubygems_version: 3.0.3
181
- signing_key:
180
+ rubygems_version: 3.1.6
181
+ signing_key:
182
182
  specification_version: 4
183
183
  summary: Paginate Active Record sets at variable speeds
184
184
  test_files: