productive 0.6.59 → 0.6.60

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: c977425e19aa039f3141c9c9820e79bc9899bf7bee60672a7075360e5fe6fb31
4
- data.tar.gz: 931e85b9bfec1e7ce396906043fc7b358afc2309a9494db7fae8bd268664cba1
3
+ metadata.gz: 7b0581cbf5e2dd654905d5cbfb67e5cceca461b3db48757e0e1cae3a569e9a17
4
+ data.tar.gz: 1771d2708b58d47c891bbc63cd6ab59a17109d6cfbc476b97c8d63928f2ded18
5
5
  SHA512:
6
- metadata.gz: 40950a5478f66abf477f960bd655ab2e4a62881fe6ff2bb5ed37d484bdd67d6abca4c476be40833f16ef92bef8a48b056e66c82a545c8fc26496f405b81b4af9
7
- data.tar.gz: 4cc670d8b290a89721428db68ec1ca5b957dc3774b042153d214ef191f822964fe04b20d5bcb17631b8a65285f5651c802a4580fff9af5981f31e84b974940c8
6
+ metadata.gz: 180bc3286195bac1465b0997353e104c88dbec6a2b98590b791f4799c70548d9236e4aba6509c92116bcfea74dbc7b0962919db03e5f07b4434641d0a1d5c580
7
+ data.tar.gz: 2969164942aa23e8e6e7b0cd6666a6a273045d0306b8b2e822ea67d711961951fb1db1bae7e1c1ba855cbc1a41d387948b56bdeab734d45b5095dd054dcfa534
@@ -1,67 +1,15 @@
1
- require 'rack'
1
+ class JsonApiPaginator < JsonApiClient::Paginating::NestedParamPaginator
2
+ self.page_param = 'number'
3
+ self.per_page_param = 'size'
2
4
 
3
- class JsonApiPaginator
4
- attr_reader :params, :result_set, :links, :meta
5
+ attr_reader :meta
5
6
 
6
7
  def initialize(result_set, data)
7
- @params = params_for_uri(result_set.uri)
8
- @result_set = result_set
9
- @links = data['links'] || {}
8
+ super
10
9
  @meta = data['meta'] || {}
11
10
  end
12
11
 
13
- def next
14
- links['next'] ? result_set.links.fetch_link('next') : nil
15
- end
16
-
17
- def prev
18
- links['prev'] ? result_set.links.fetch_link('prev') : nil
19
- end
20
-
21
- def first
22
- links['first'] ? result_set.links.fetch_link('first') : nil
23
- end
24
-
25
- def last
26
- links['last'] ? result_set.links.fetch_link('last') : nil
27
- end
28
-
29
- def total_pages
30
- if links['last']
31
- uri = result_set.links.link_url_for('last')
32
- last_params = params_for_uri(uri)
33
- last_params['page']['number'].to_i
34
- else
35
- current_page
36
- end
37
- end
38
-
39
12
  def total_entries
40
- meta['total_count'].to_i || per_page * total_pages
41
- end
42
- alias_method :total_count, :total_entries
43
-
44
- def per_page
45
- params['page']['size'].to_i
46
- end
47
-
48
- def current_page
49
- (params['page']['number'] || 1).to_i
50
- end
51
-
52
- def previous_page
53
- current_page > 1 ? (current_page - 1) : nil
54
- end
55
-
56
- def next_page
57
- current_page < total_pages ? (current_page + 1) : nil
58
- end
59
-
60
- private
61
-
62
- def params_for_uri(uri)
63
- return {} unless uri
64
- uri = Addressable::URI.parse(uri)
65
- Rack::Utils.parse_nested_query(uri.query || '')
13
+ meta['total_count'].to_i || super
66
14
  end
67
15
  end
@@ -1,3 +1,3 @@
1
1
  module Productive
2
- VERSION = '0.6.59'.freeze
2
+ VERSION = '0.6.60'.freeze
3
3
  end
data/productive.gemspec CHANGED
@@ -13,7 +13,6 @@ Gem::Specification.new do |s|
13
13
  s.license = 'MIT'
14
14
  s.files = `git ls-files`.split("\n")
15
15
 
16
- s.add_dependency 'rack'
17
- s.add_dependency 'json_api_client', '>= 1.5.2'
16
+ s.add_dependency 'json_api_client', '>= 1.13.0', "<= 1.21.0"
18
17
  s.add_dependency 'request_store', '~> 1.3'
19
18
  end
metadata CHANGED
@@ -1,43 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: productive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.59
4
+ version: 0.6.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josip Bišćan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-03 00:00:00.000000000 Z
11
+ date: 2022-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rack
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: json_api_client
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: 1.5.2
19
+ version: 1.13.0
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.21.0
34
23
  type: :runtime
35
24
  prerelease: false
36
25
  version_requirements: !ruby/object:Gem::Requirement
37
26
  requirements:
38
27
  - - ">="
39
28
  - !ruby/object:Gem::Version
40
- version: 1.5.2
29
+ version: 1.13.0
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.21.0
41
33
  - !ruby/object:Gem::Dependency
42
34
  name: request_store
43
35
  requirement: !ruby/object:Gem::Requirement