api-pagination 4.8.2 → 5.0.0

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
2
  SHA256:
3
- metadata.gz: e0006fcbe882c8a54820796eaf3d573d04b3dd2057cb9d6130b56389dff36790
4
- data.tar.gz: b585330048fb81eb9b83c377af32ea85d3fd80afcc864b70a01426e0d51c1bf4
3
+ metadata.gz: ba0df72041cd862671500fd9efe94c7fe8e35975877e0e9bbcd1c0b77860e4a4
4
+ data.tar.gz: debcf49e29dcda50d93cd31a2e9efec2332541dbe38f6bdaa488b450e5bb7d09
5
5
  SHA512:
6
- metadata.gz: e79b9e403a5a30834d9bd94e11687a79e08ac049463fe749b025dc98cd476ed11b98e0667b6e01f13315c9bf374d19fb500af6e0a98a1cecb1bf2753101be9ef
7
- data.tar.gz: '0398d5cab6c18f426823f8d99ef02a3796380047f87c99864600cfd0ff52bb86246f4d3091f8b3d95decd1f34827323792eebe2d77502abe05bcc235a7993382'
6
+ metadata.gz: 4661d9bfa18456e1c6fcfb837ef4c3acbc9e35dd983299201340dc077056e3f5632c39a8f718b285d66b4e3985aec23da68a56c8c278f0fc850f27626352bb0b
7
+ data.tar.gz: 688fae38d680fb9f1b133a627172d687c7fa6f56186039a88a5bfe238e396c5310359266580644d7719b981d6f3589ac884f6b6d88688c497c8516cbffd122cd
@@ -1,8 +1,8 @@
1
1
  module ApiPagination
2
2
  class Version
3
- MAJOR = 4
4
- MINOR = 8
5
- PATCH = 2
3
+ MAJOR = 5
4
+ MINOR = 0
5
+ PATCH = 0
6
6
 
7
7
  def self.to_s
8
8
  [MAJOR, MINOR, PATCH].join('.')
@@ -47,10 +47,10 @@ module ApiPagination
47
47
  private
48
48
 
49
49
  def paginate_with_pagy(collection, options)
50
- if Pagy::VARS[:max_per_page] && options[:per_page] > Pagy::VARS[:max_per_page]
51
- options[:per_page] = Pagy::VARS[:max_per_page]
50
+ if Pagy::DEFAULT[:max_per_page] && options[:per_page] > Pagy::DEFAULT[:max_per_page]
51
+ options[:per_page] = Pagy::DEFAULT[:max_per_page]
52
52
  elsif options[:per_page] <= 0
53
- options[:per_page] = Pagy::VARS[:items]
53
+ options[:per_page] = Pagy::DEFAULT[:items]
54
54
  end
55
55
 
56
56
  pagy = pagy_from(collection, options)
@@ -69,7 +69,7 @@ module ApiPagination
69
69
  else
70
70
  count = collection.is_a?(Array) ? collection.count : collection.count(:all)
71
71
  end
72
-
72
+
73
73
  Pagy.new(count: count, items: options[:per_page], page: options[:page])
74
74
  end
75
75
 
@@ -94,7 +94,7 @@ module ApiPagination
94
94
  options[:per_page] = get_default_per_page_for_kaminari(collection)
95
95
  end
96
96
 
97
- collection = Kaminari.paginate_array(collection, paginate_array_options) if collection.is_a?(Array)
97
+ collection = Kaminari.paginate_array(collection, **paginate_array_options) if collection.is_a?(Array)
98
98
  collection = collection.page(options[:page]).per(options[:per_page])
99
99
  collection.without_count if !collection.is_a?(Array) && !ApiPagination.config.include_total
100
100
  [collection, nil]
@@ -11,7 +11,7 @@ describe ApiPagination do
11
11
  describe '.paginate' do
12
12
  it 'should accept paginate_array_options option' do
13
13
  expect(Kaminari).to receive(:paginate_array)
14
- .with(collection, paginate_array_options)
14
+ .with(collection, **paginate_array_options)
15
15
  .and_call_original
16
16
 
17
17
  ApiPagination.paginate(
data/spec/rails_spec.rb CHANGED
@@ -262,7 +262,7 @@ describe NumbersController, :type => :controller do
262
262
  end
263
263
  end
264
264
 
265
- after :all do
265
+ after :all do
266
266
  class Fixnum
267
267
  class << self
268
268
  undef_method :default_per_page, :per_page
@@ -286,7 +286,7 @@ describe NumbersController, :type => :controller do
286
286
 
287
287
  expect(response.header['Per-Page']).to eq(
288
288
  case ApiPagination.config.paginator
289
- when :pagy then Pagy::VARS[:items].to_s
289
+ when :pagy then Pagy::DEFAULT[:items].to_s
290
290
  when :kaminari then Kaminari.config.default_per_page.to_s
291
291
  when :will_paginate then WillPaginate.per_page.to_s
292
292
  end
@@ -295,13 +295,13 @@ describe NumbersController, :type => :controller do
295
295
  end
296
296
  end
297
297
 
298
- context 'default per page in objects without paginator defaults' do
298
+ context 'default per page in objects without paginator defaults' do
299
299
  it 'should not fail if model does not respond to per page' do
300
300
  get :index_with_no_per_page, params: {count: 100}
301
301
 
302
302
  expect(response.header['Per-Page']).to eq(
303
303
  case ApiPagination.config.paginator
304
- when :pagy then Pagy::VARS[:items].to_s
304
+ when :pagy then Pagy::DEFAULT[:items].to_s
305
305
  when :kaminari then Kaminari.config.default_per_page.to_s
306
306
  when :will_paginate then WillPaginate.per_page.to_s
307
307
  end
@@ -309,4 +309,4 @@ describe NumbersController, :type => :controller do
309
309
  end
310
310
  end
311
311
  end
312
- end
312
+ end
metadata CHANGED
@@ -1,99 +1,171 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.2
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Celis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-07 00:00:00.000000000 Z
11
+ date: 2021-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: kaminari
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '1.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.2.1
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '3.0'
29
+ version: '1.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.2.1
27
33
  - !ruby/object:Gem::Dependency
28
- name: grape
34
+ name: pagy
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '5.1'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 5.1.2
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '5.1'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 5.1.2
53
+ - !ruby/object:Gem::Dependency
54
+ name: will_paginate
29
55
  requirement: !ruby/object:Gem::Requirement
30
56
  requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '3.3'
31
60
  - - ">="
32
61
  - !ruby/object:Gem::Version
33
- version: 0.10.0
62
+ version: 3.3.1
34
63
  type: :development
35
64
  prerelease: false
36
65
  version_requirements: !ruby/object:Gem::Requirement
37
66
  requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.3'
38
70
  - - ">="
39
71
  - !ruby/object:Gem::Version
40
- version: 0.10.0
72
+ version: 3.3.1
73
+ - !ruby/object:Gem::Dependency
74
+ name: rspec
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '3.10'
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '3.10'
87
+ - !ruby/object:Gem::Dependency
88
+ name: grape
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '1.6'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '1.6'
41
101
  - !ruby/object:Gem::Dependency
42
102
  name: railties
43
103
  requirement: !ruby/object:Gem::Requirement
44
104
  requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '6.1'
45
108
  - - ">="
46
109
  - !ruby/object:Gem::Version
47
- version: 5.0.0
110
+ version: 6.1.4.1
48
111
  type: :development
49
112
  prerelease: false
50
113
  version_requirements: !ruby/object:Gem::Requirement
51
114
  requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '6.1'
52
118
  - - ">="
53
119
  - !ruby/object:Gem::Version
54
- version: 5.0.0
120
+ version: 6.1.4.1
55
121
  - !ruby/object:Gem::Dependency
56
122
  name: actionpack
57
123
  requirement: !ruby/object:Gem::Requirement
58
124
  requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '6.1'
59
128
  - - ">="
60
129
  - !ruby/object:Gem::Version
61
- version: 5.0.0
130
+ version: 6.1.4.1
62
131
  type: :development
63
132
  prerelease: false
64
133
  version_requirements: !ruby/object:Gem::Requirement
65
134
  requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '6.1'
66
138
  - - ">="
67
139
  - !ruby/object:Gem::Version
68
- version: 5.0.0
140
+ version: 6.1.4.1
69
141
  - !ruby/object:Gem::Dependency
70
142
  name: sequel
71
143
  requirement: !ruby/object:Gem::Requirement
72
144
  requirements:
73
- - - ">="
145
+ - - "~>"
74
146
  - !ruby/object:Gem::Version
75
- version: 4.9.0
147
+ version: '5.49'
76
148
  type: :development
77
149
  prerelease: false
78
150
  version_requirements: !ruby/object:Gem::Requirement
79
151
  requirements:
80
- - - ">="
152
+ - - "~>"
81
153
  - !ruby/object:Gem::Version
82
- version: 4.9.0
154
+ version: '5.49'
83
155
  - !ruby/object:Gem::Dependency
84
156
  name: activerecord-nulldb-adapter
85
157
  requirement: !ruby/object:Gem::Requirement
86
158
  requirements:
87
- - - ">="
159
+ - - "~>"
88
160
  - !ruby/object:Gem::Version
89
- version: 0.3.9
161
+ version: 0.7.0
90
162
  type: :development
91
163
  prerelease: false
92
164
  version_requirements: !ruby/object:Gem::Requirement
93
165
  requirements:
94
- - - ">="
166
+ - - "~>"
95
167
  - !ruby/object:Gem::Version
96
- version: 0.3.9
168
+ version: 0.7.0
97
169
  description: Link header pagination for Rails and Grape APIs
98
170
  email:
99
171
  - me@davidcel.is
@@ -126,38 +198,37 @@ homepage: https://github.com/davidcelis/api-pagination
126
198
  licenses:
127
199
  - MIT
128
200
  metadata: {}
129
- post_install_message:
201
+ post_install_message:
130
202
  rdoc_options: []
131
203
  require_paths:
132
204
  - lib
133
205
  required_ruby_version: !ruby/object:Gem::Requirement
134
206
  requirements:
135
- - - ">="
207
+ - - ">"
136
208
  - !ruby/object:Gem::Version
137
- version: '0'
209
+ version: '2.7'
138
210
  required_rubygems_version: !ruby/object:Gem::Requirement
139
211
  requirements:
140
212
  - - ">="
141
213
  - !ruby/object:Gem::Version
142
214
  version: '0'
143
215
  requirements: []
144
- rubyforge_project:
145
- rubygems_version: 2.7.6
146
- signing_key:
216
+ rubygems_version: 3.2.22
217
+ signing_key:
147
218
  specification_version: 4
148
219
  summary: Link header pagination for Rails and Grape APIs. Don't use the request body.
149
220
  test_files:
150
- - spec/spec_helper.rb
151
- - spec/api-pagination_spec.rb
152
221
  - spec/active_record_spec.rb
222
+ - spec/api-pagination_spec.rb
223
+ - spec/grape_spec.rb
224
+ - spec/rails_spec.rb
153
225
  - spec/sequel_spec.rb
154
- - spec/support/numbers_api.rb
155
- - spec/support/numbers_controller.rb
226
+ - spec/spec_helper.rb
156
227
  - spec/support/active_record/foo.rb
157
228
  - spec/support/active_record/schema.rb
229
+ - spec/support/numbers_api.rb
230
+ - spec/support/numbers_controller.rb
231
+ - spec/support/shared_examples/existing_headers.rb
158
232
  - spec/support/shared_examples/first_page.rb
159
- - spec/support/shared_examples/middle_page.rb
160
233
  - spec/support/shared_examples/last_page.rb
161
- - spec/support/shared_examples/existing_headers.rb
162
- - spec/grape_spec.rb
163
- - spec/rails_spec.rb
234
+ - spec/support/shared_examples/middle_page.rb