grape-pagy 0.3.1 → 0.4.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: 180207f3b3894998bebb7bc777378787eaf71586a4312e75cd3c60e4e960fae3
4
- data.tar.gz: a3282f12ca6025c12f22079c51e868ad8b2ca2dfbcddd84d2bdc3c97c474bf6f
3
+ metadata.gz: b587c249c2841b932ceba9be1e7fb25678ce0095345f6e07fcd0eb4231e9db0d
4
+ data.tar.gz: 427c30f87fd2b90ef082c0926198779b51bae79256b5a32ecff4772464e99fe0
5
5
  SHA512:
6
- metadata.gz: a061f3ff334f5a1872811c3789b07c8186794fd6a695b14f0acace8d2b821a10db7e31c352c5f9f078aecd1ccc888a955bb1bbe32e2df3b3fa35ff55948a6cf5
7
- data.tar.gz: 60c01e34bbd0867f74d7327f97c12fef04396903c16550cb32f5cd9bae2f6f62a00aaa1c59f54b19247bd36cc1a71affccbebcc90a6a6f89becf9c0e761bdd9e
6
+ metadata.gz: a8e59c02f4e9bd59465ae90e4f4d1d449fc66ac8eade1d1fd1774a4a675baefd89a836b202910d4bb31eb754145f2191673333eb88a81c9cfdaf9b4b31e35ede
7
+ data.tar.gz: ce49cc0544a6ce5162eaad691742b5263f221e31ffbb5a4fde39228d517dacb6adc5fca23ac7ea34039c87b723b77d6e8e54a8cc20e7e4f7576f17d40ca10afe
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby-version: ["2.6", "2.7"]
14
+ ruby-version: ["3.0"]
15
15
  steps:
16
16
  - uses: actions/checkout@v2
17
17
  - uses: ruby/setup-ruby@v1
data/.gitignore CHANGED
@@ -46,7 +46,7 @@ build-iPhoneSimulator/
46
46
  # for a library or gem, you might want to ignore these files since the code is
47
47
  # intended to run in multiple environments; otherwise, check them in:
48
48
  # Gemfile.lock
49
- # .ruby-version
49
+ .ruby-version
50
50
  # .ruby-gemset
51
51
 
52
52
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
data/.rubocop.yml CHANGED
@@ -6,7 +6,7 @@ inherit_mode:
6
6
  - Exclude
7
7
 
8
8
  AllCops:
9
- TargetRubyVersion: "2.6"
9
+ TargetRubyVersion: "3.0"
10
10
 
11
11
  Naming/FileName:
12
12
  Exclude: ["lib/grape-pagy.rb"]
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-pagy (0.3.1)
4
+ grape-pagy (0.4.0)
5
5
  grape (>= 1.5)
6
- pagy (>= 3.8, < 4.0)
6
+ pagy (>= 4.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -50,7 +50,7 @@ GEM
50
50
  ruby2_keywords (~> 0.0.1)
51
51
  mustermann-grape (1.0.1)
52
52
  mustermann (>= 1.0.0)
53
- pagy (3.13.0)
53
+ pagy (4.3.0)
54
54
  parallel (1.20.1)
55
55
  parser (3.0.1.0)
56
56
  ast (~> 2.4.1)
@@ -124,4 +124,4 @@ DEPENDENCIES
124
124
  rubocop-bsm
125
125
 
126
126
  BUNDLED WITH
127
- 2.1.4
127
+ 2.2.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.3.1'
3
+ spec.version = '0.4.0'
4
4
  spec.authors = ['Black Square Media']
5
5
  spec.email = ['info@blacksquaremedia.com']
6
6
  spec.description = 'Pagy paginator for grape API'
@@ -11,10 +11,10 @@ Gem::Specification.new do |spec|
11
11
  spec.files = `git ls-files -z`.split("\x0").reject {|f| f.start_with?('spec/') }
12
12
  spec.test_files = `git ls-files -z -- spec/*`.split("\x0")
13
13
  spec.require_paths = ['lib']
14
- spec.required_ruby_version = '>= 2.6'
14
+ spec.required_ruby_version = '>= 3.0'
15
15
 
16
16
  spec.add_runtime_dependency 'grape', '>= 1.5'
17
- spec.add_runtime_dependency 'pagy', '>= 3.8', '< 4.0'
17
+ spec.add_runtime_dependency 'pagy', '>= 4.2'
18
18
 
19
19
  spec.add_development_dependency 'bundler'
20
20
  spec.add_development_dependency 'rack-test'
data/lib/grape/pagy.rb CHANGED
@@ -13,7 +13,7 @@ module Grape
13
13
  include ::Pagy::Backend
14
14
 
15
15
  def paginate(collection, using: nil, **opts, &block)
16
- pagy_with_items(opts)
16
+ opts = pagy_countless_get_vars(nil, opts)
17
17
  using ||= if collection.respond_to?(:arel_table)
18
18
  :arel
19
19
  elsif collection.is_a?(Array)
@@ -31,9 +31,9 @@ module Grape
31
31
  module Helpers
32
32
  extend Grape::API::Helpers
33
33
 
34
- params :pagy do |items: nil, page: nil, **opts|
35
- items ||= ::Pagy::VARS[:items]
36
- page ||= ::Pagy::VARS[:page]
34
+ params :pagy do |opts|
35
+ items = opts.delete(:items) || ::Pagy::VARS[:items]
36
+ page = opts.delete(:page) || ::Pagy::VARS[:page]
37
37
  page_param = opts[:page_param] || ::Pagy::VARS[:page_param]
38
38
  items_param = opts[:items_param] || ::Pagy::VARS[:items_param]
39
39
 
@@ -45,6 +45,7 @@ module Grape
45
45
  # @param [Array|ActiveRecord::Relation] collection the collection or relation.
46
46
  def pagy(collection, **opts)
47
47
  defaults = route_setting(:pagy_options) || {}
48
+
48
49
  Wrapper.new(request, params).paginate(collection, **defaults, **opts) do |key, value|
49
50
  header key, value
50
51
  end
data/spec/spec_helper.rb CHANGED
@@ -9,11 +9,11 @@ Pagy::VARS[:max_items] = 20
9
9
 
10
10
  class TestArray < Array
11
11
  def limit(num)
12
- slice!(0, num)
12
+ self.class.new slice(0, num)
13
13
  end
14
14
 
15
15
  def offset(num)
16
- slice!(num..-1)
16
+ self.class.new slice(num..-1)
17
17
  end
18
18
  end
19
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Black Square Media
@@ -30,20 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '3.8'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '4.0'
33
+ version: '4.2'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
- version: '3.8'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '4.0'
40
+ version: '4.2'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: bundler
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -147,14 +141,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
141
  requirements:
148
142
  - - ">="
149
143
  - !ruby/object:Gem::Version
150
- version: '2.6'
144
+ version: '3.0'
151
145
  required_rubygems_version: !ruby/object:Gem::Requirement
152
146
  requirements:
153
147
  - - ">="
154
148
  - !ruby/object:Gem::Version
155
149
  version: '0'
156
150
  requirements: []
157
- rubygems_version: 3.1.4
151
+ rubygems_version: 3.2.15
158
152
  signing_key:
159
153
  specification_version: 4
160
154
  summary: ''