grape-pagy 0.5.0 → 0.5.1

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: 5cf4286de9e78c7b5a4f4f9ea1fdf9ad8c5e688a64b44e4551c26e300509d42c
4
- data.tar.gz: ca06ad206ff3fb7dadc9dcf9f37848afd58645d35f9b8af0dbe7819182694c1e
3
+ metadata.gz: ca339ac7f54bf525cd93e7df3da9e4d881ab83825c28e500afcb1774ad6a7991
4
+ data.tar.gz: 5bd4e7028e53d7b6ed9770d08298fe21b6e2253edc006906c652f2227b645cf2
5
5
  SHA512:
6
- metadata.gz: 0b6094898f98b12b1bf636963d9e3254efa554469f6a179c0ea047022955c9f716c01c1961756d31b53a77f18947026d1929e4eaea80352de47771c2f92769c9
7
- data.tar.gz: 8141124754f358828ae5c248fac72acd3dcd4788aac64b3db54e9afbcbbc7b7e366739227c0e081b5249d6e010e6596293f18f06e1dfe5286241bc46b0ed4ac7
6
+ metadata.gz: 31f94b19fbf94f33622333385075376149a694653da7297864945f6cb9afd11a38b355fc63dd426e0d887b5b8b295f4c4969826aad07b7ced9fdf32048f556db
7
+ data.tar.gz: 8126538a4b3592a3eb259ebdbe597add3749ab9297a08494414dc571231ea5ebc2370b4fc9ad4aeac8bbafbfee8566fd447b4f3a6b67baa10b961d3c73d998d6
@@ -11,9 +11,9 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby-version: ["3.0"]
14
+ ruby-version: ["3.0", "3.1"]
15
15
  steps:
16
- - uses: actions/checkout@v2
16
+ - uses: actions/checkout@v3
17
17
  - uses: ruby/setup-ruby@v1
18
18
  with:
19
19
  ruby-version: ${{ matrix.ruby-version }}
data/Gemfile.lock CHANGED
@@ -1,32 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-pagy (0.5.0)
4
+ grape-pagy (0.5.1)
5
5
  grape (>= 1.5)
6
6
  pagy (>= 5.4)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (6.1.3.1)
11
+ activesupport (7.0.3.1)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 1.6, < 2)
14
14
  minitest (>= 5.1)
15
15
  tzinfo (~> 2.0)
16
- zeitwerk (~> 2.3)
17
16
  ast (2.4.2)
18
17
  builder (3.2.4)
19
- concurrent-ruby (1.1.8)
20
- diff-lcs (1.4.4)
21
- dry-configurable (0.13.0)
18
+ concurrent-ruby (1.1.10)
19
+ diff-lcs (1.5.0)
20
+ dry-container (0.10.0)
22
21
  concurrent-ruby (~> 1.0)
23
- dry-core (~> 0.6)
24
- dry-container (0.9.0)
22
+ dry-core (0.8.0)
25
23
  concurrent-ruby (~> 1.0)
26
- dry-configurable (~> 0.13, >= 0.13.0)
27
- dry-core (0.7.1)
28
- concurrent-ruby (~> 1.0)
29
- dry-inflector (0.2.1)
24
+ dry-inflector (0.3.0)
30
25
  dry-logic (1.2.0)
31
26
  concurrent-ruby (~> 1.0)
32
27
  dry-core (~> 0.5, >= 0.5)
@@ -36,81 +31,77 @@ GEM
36
31
  dry-core (~> 0.5, >= 0.5)
37
32
  dry-inflector (~> 0.1, >= 0.1.2)
38
33
  dry-logic (~> 1.0, >= 1.0.2)
39
- grape (1.6.0)
34
+ grape (1.6.2)
40
35
  activesupport
41
36
  builder
42
37
  dry-types (>= 1.1)
43
38
  mustermann-grape (~> 1.0.0)
44
39
  rack (>= 1.3.0)
45
40
  rack-accept
46
- i18n (1.8.10)
41
+ i18n (1.12.0)
47
42
  concurrent-ruby (~> 1.0)
48
- minitest (5.14.4)
49
- mustermann (1.1.1)
43
+ json (2.6.2)
44
+ minitest (5.16.2)
45
+ mustermann (2.0.1)
50
46
  ruby2_keywords (~> 0.0.1)
51
- mustermann-grape (1.0.1)
47
+ mustermann-grape (1.0.2)
52
48
  mustermann (>= 1.0.0)
53
- pagy (5.4.0)
54
- parallel (1.20.1)
55
- parser (3.0.1.0)
49
+ pagy (5.10.1)
50
+ activesupport
51
+ parallel (1.22.1)
52
+ parser (3.1.2.0)
56
53
  ast (~> 2.4.1)
57
- rack (2.2.3)
54
+ rack (2.2.4)
58
55
  rack-accept (0.4.5)
59
56
  rack (>= 0.4)
60
- rack-test (1.1.0)
61
- rack (>= 1.0, < 3)
62
- rainbow (3.0.0)
63
- rake (13.0.3)
64
- regexp_parser (2.1.1)
57
+ rack-test (2.0.2)
58
+ rack (>= 1.3)
59
+ rainbow (3.1.1)
60
+ rake (13.0.6)
61
+ regexp_parser (2.5.0)
65
62
  rexml (3.2.5)
66
- rspec (3.10.0)
67
- rspec-core (~> 3.10.0)
68
- rspec-expectations (~> 3.10.0)
69
- rspec-mocks (~> 3.10.0)
70
- rspec-core (3.10.1)
71
- rspec-support (~> 3.10.0)
72
- rspec-expectations (3.10.1)
63
+ rspec (3.11.0)
64
+ rspec-core (~> 3.11.0)
65
+ rspec-expectations (~> 3.11.0)
66
+ rspec-mocks (~> 3.11.0)
67
+ rspec-core (3.11.0)
68
+ rspec-support (~> 3.11.0)
69
+ rspec-expectations (3.11.0)
73
70
  diff-lcs (>= 1.2.0, < 2.0)
74
- rspec-support (~> 3.10.0)
75
- rspec-mocks (3.10.2)
71
+ rspec-support (~> 3.11.0)
72
+ rspec-mocks (3.11.1)
76
73
  diff-lcs (>= 1.2.0, < 2.0)
77
- rspec-support (~> 3.10.0)
78
- rspec-support (3.10.2)
79
- rubocop (1.13.0)
74
+ rspec-support (~> 3.11.0)
75
+ rspec-support (3.11.0)
76
+ rubocop (1.31.2)
77
+ json (~> 2.3)
80
78
  parallel (~> 1.10)
81
- parser (>= 3.0.0.0)
79
+ parser (>= 3.1.0.0)
82
80
  rainbow (>= 2.2.2, < 4.0)
83
81
  regexp_parser (>= 1.8, < 3.0)
84
- rexml
85
- rubocop-ast (>= 1.2.0, < 2.0)
82
+ rexml (>= 3.2.5, < 4.0)
83
+ rubocop-ast (>= 1.18.0, < 2.0)
86
84
  ruby-progressbar (~> 1.7)
87
85
  unicode-display_width (>= 1.4.0, < 3.0)
88
- rubocop-ast (1.4.1)
89
- parser (>= 2.7.1.5)
90
- rubocop-bsm (0.5.8)
86
+ rubocop-ast (1.19.1)
87
+ parser (>= 3.1.1.0)
88
+ rubocop-bsm (0.6.0)
91
89
  rubocop (~> 1.0)
92
90
  rubocop-performance
93
- rubocop-rails
94
91
  rubocop-rake
95
92
  rubocop-rspec
96
- rubocop-performance (1.10.2)
97
- rubocop (>= 0.90.0, < 2.0)
93
+ rubocop-performance (1.14.3)
94
+ rubocop (>= 1.7.0, < 2.0)
98
95
  rubocop-ast (>= 0.4.0)
99
- rubocop-rails (2.9.1)
100
- activesupport (>= 4.2.0)
101
- rack (>= 1.1)
102
- rubocop (>= 0.90.0, < 2.0)
103
- rubocop-rake (0.5.1)
104
- rubocop
105
- rubocop-rspec (2.2.0)
96
+ rubocop-rake (0.6.0)
106
97
  rubocop (~> 1.0)
107
- rubocop-ast (>= 1.1.0)
98
+ rubocop-rspec (2.12.1)
99
+ rubocop (~> 1.31)
108
100
  ruby-progressbar (1.11.0)
109
101
  ruby2_keywords (0.0.5)
110
- tzinfo (2.0.4)
102
+ tzinfo (2.0.5)
111
103
  concurrent-ruby (~> 1.0)
112
- unicode-display_width (2.0.0)
113
- zeitwerk (2.4.2)
104
+ unicode-display_width (2.2.0)
114
105
 
115
106
  PLATFORMS
116
107
  ruby
@@ -124,4 +115,4 @@ DEPENDENCIES
124
115
  rubocop-bsm
125
116
 
126
117
  BUNDLED WITH
127
- 2.2.21
118
+ 2.3.16
data/grape-pagy.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'grape-pagy'
3
- spec.version = '0.5.0'
3
+ spec.version = '0.5.1'
4
4
  spec.authors = ['Black Square Media']
5
5
  spec.email = ['info@blacksquaremedia.com']
6
6
  spec.description = 'Pagy paginator for grape API'
@@ -9,7 +9,6 @@ Gem::Specification.new do |spec|
9
9
  spec.license = 'Apache-2.0'
10
10
 
11
11
  spec.files = `git ls-files -z`.split("\x0").reject {|f| f.start_with?('spec/') }
12
- spec.test_files = `git ls-files -z -- spec/*`.split("\x0")
13
12
  spec.require_paths = ['lib']
14
13
  spec.required_ruby_version = '>= 3.0'
15
14
 
@@ -21,4 +20,5 @@ Gem::Specification.new do |spec|
21
20
  spec.add_development_dependency 'rake'
22
21
  spec.add_development_dependency 'rspec'
23
22
  spec.add_development_dependency 'rubocop-bsm'
23
+ spec.metadata['rubygems_mfa_required'] = 'true'
24
24
  end
data/lib/grape/pagy.rb CHANGED
@@ -36,10 +36,11 @@ module Grape
36
36
  page = opts.delete(:page) || ::Pagy::DEFAULT[:page]
37
37
  page_param = opts[:page_param] || ::Pagy::DEFAULT[:page_param]
38
38
  items_param = opts[:items_param] || ::Pagy::DEFAULT[:items_param]
39
+ max_items = opts[:max_items] || ::Pagy::DEFAULT[:max_items]
39
40
 
40
41
  @api.route_setting(:pagy_options, opts)
41
42
  optional page_param, type: Integer, default: page, desc: 'Page offset to fetch.'
42
- optional items_param, type: Integer, default: items, desc: 'Number of items to return per page.'
43
+ optional items_param, type: Integer, default: items, desc: "Number of items to return per page. Maximum value: #{max_items}"
43
44
  end
44
45
 
45
46
  # @param [Array|ActiveRecord::Relation] collection the collection or relation.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Black Square Media
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-19 00:00:00.000000000 Z
11
+ date: 2022-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -127,12 +127,11 @@ files:
127
127
  - grape-pagy.gemspec
128
128
  - lib/grape-pagy.rb
129
129
  - lib/grape/pagy.rb
130
- - spec/grape/pagy_spec.rb
131
- - spec/spec_helper.rb
132
130
  homepage: ''
133
131
  licenses:
134
132
  - Apache-2.0
135
- metadata: {}
133
+ metadata:
134
+ rubygems_mfa_required: 'true'
136
135
  post_install_message:
137
136
  rdoc_options: []
138
137
  require_paths:
@@ -148,10 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
147
  - !ruby/object:Gem::Version
149
148
  version: '0'
150
149
  requirements: []
151
- rubygems_version: 3.2.15
150
+ rubygems_version: 3.3.3
152
151
  signing_key:
153
152
  specification_version: 4
154
153
  summary: ''
155
- test_files:
156
- - spec/grape/pagy_spec.rb
157
- - spec/spec_helper.rb
154
+ test_files: []
@@ -1,94 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Grape::Pagy do
4
- include Rack::Test::Methods
5
-
6
- let(:app) { TestAPI }
7
-
8
- it 'paginates' do
9
- get '/'
10
- expect(last_response.status).to eq(200)
11
- expect(last_response.headers).to include(
12
- 'Current-Page' => '1',
13
- 'Link' => '<http://example.org/?page=1&items=5>; rel="first", ' \
14
- '<http://example.org/?page=2&items=5>; rel="next", ' \
15
- '<http://example.org/?page=3&items=5>; rel="last"',
16
- 'Page-Items' => '5',
17
- 'Total-Count' => '12',
18
- 'Total-Pages' => '3',
19
- )
20
- expect(last_response.body).to eq(%([1, 2, 3, 4, 5]))
21
- end
22
-
23
- it 'accepts page and items parameters' do
24
- get '/?page=2&items=3'
25
- expect(last_response.status).to eq(200)
26
- expect(last_response.headers).to include(
27
- 'Current-Page' => '2',
28
- 'Page-Items' => '3',
29
- 'Total-Count' => '12',
30
- 'Total-Pages' => '4',
31
- )
32
- expect(last_response.body).to eq(%([4, 5, 6]))
33
- end
34
-
35
- it 'caps items' do
36
- get '/?items=10'
37
- expect(last_response.headers).to include('Page-Items' => '6')
38
- expect(last_response.body).to eq(%([1, 2, 3, 4, 5, 6]))
39
-
40
- get '/?items=3'
41
- expect(last_response.headers).to include('Page-Items' => '3')
42
- expect(last_response.body).to eq(%([1, 2, 3]))
43
- end
44
-
45
- it 'ignores overflow' do
46
- get '/?page=99'
47
- expect(last_response.status).to eq(200)
48
- expect(last_response.headers).to include(
49
- 'Current-Page' => '99',
50
- 'Total-Pages' => '3',
51
- )
52
- expect(last_response.body).to eq(%([]))
53
- end
54
-
55
- it 'allows countless mode' do
56
- get '/countless?page=2'
57
- expect(last_response.status).to eq(200)
58
- expect(last_response.headers).to include(
59
- 'Current-Page' => '2',
60
- 'Page-Items' => '3',
61
- 'Link' => [
62
- %(<http://example.org/countless?page=1&items=3>; rel="first"),
63
- %(<http://example.org/countless?page=1&items=3>; rel="prev"),
64
- %(<http://example.org/countless?page=3&items=3>; rel="next"),
65
- ].join(', '),
66
- )
67
- expect(last_response.headers).not_to include(
68
- 'Total-Count',
69
- 'Total-Pages',
70
- )
71
- expect(last_response.body).to eq(%([4, 5, 6]))
72
- end
73
-
74
- it 'inherits helper' do
75
- get '/sub'
76
- expect(last_response.status).to eq(200)
77
- expect(last_response.headers).to include(
78
- 'Current-Page' => '1',
79
- 'Page-Items' => '10',
80
- 'Total-Count' => '13',
81
- 'Total-Pages' => '2',
82
- )
83
- expect(last_response.body).to eq(%([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
84
-
85
- get '/sub?per_page=20'
86
- expect(last_response.status).to eq(200)
87
- expect(last_response.headers).to include(
88
- 'Current-Page' => '1',
89
- 'Page-Items' => '20',
90
- 'Total-Count' => '13',
91
- 'Total-Pages' => '1',
92
- )
93
- end
94
- end
data/spec/spec_helper.rb DELETED
@@ -1,50 +0,0 @@
1
- ENV['RACK_ENV'] ||= 'test'
2
-
3
- require 'rspec'
4
- require 'grape/pagy'
5
- require 'rack/test'
6
-
7
- Pagy::DEFAULT[:items] = 10
8
- Pagy::DEFAULT[:max_items] = 20
9
-
10
- class TestArray < Array
11
- def limit(num)
12
- self.class.new slice(0, num)
13
- end
14
-
15
- def offset(num)
16
- self.class.new slice(num..-1)
17
- end
18
- end
19
-
20
- class TestAPI < Grape::API
21
- helpers Grape::Pagy::Helpers
22
-
23
- params do
24
- use :pagy, items: 5, max_items: 6
25
- end
26
- get '' do
27
- pagy (1..12).to_a
28
- end
29
-
30
- params do
31
- use :pagy, items: 3
32
- end
33
- get '/countless' do
34
- pagy TestArray.new((1..12).to_a), using: :countless
35
- end
36
-
37
- resource :sub do
38
- params do
39
- use :pagy, items_param: :per_page
40
- end
41
- get '/' do
42
- pagy (1..12).to_a, count: 13
43
- end
44
- end
45
- end
46
-
47
- RSpec.configure do |config|
48
- config.include Rack::Test::Methods
49
- config.raise_errors_for_deprecations!
50
- end