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 +4 -4
- data/lib/json_api_paginator.rb +6 -58
- data/lib/productive/version.rb +1 -1
- data/productive.gemspec +1 -2
- metadata +10 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b0581cbf5e2dd654905d5cbfb67e5cceca461b3db48757e0e1cae3a569e9a17
|
4
|
+
data.tar.gz: 1771d2708b58d47c891bbc63cd6ab59a17109d6cfbc476b97c8d63928f2ded18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 180bc3286195bac1465b0997353e104c88dbec6a2b98590b791f4799c70548d9236e4aba6509c92116bcfea74dbc7b0962919db03e5f07b4434641d0a1d5c580
|
7
|
+
data.tar.gz: 2969164942aa23e8e6e7b0cd6666a6a273045d0306b8b2e822ea67d711961951fb1db1bae7e1c1ba855cbc1a41d387948b56bdeab734d45b5095dd054dcfa534
|
data/lib/json_api_paginator.rb
CHANGED
@@ -1,67 +1,15 @@
|
|
1
|
-
|
1
|
+
class JsonApiPaginator < JsonApiClient::Paginating::NestedParamPaginator
|
2
|
+
self.page_param = 'number'
|
3
|
+
self.per_page_param = 'size'
|
2
4
|
|
3
|
-
|
4
|
-
attr_reader :params, :result_set, :links, :meta
|
5
|
+
attr_reader :meta
|
5
6
|
|
6
7
|
def initialize(result_set, data)
|
7
|
-
|
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 ||
|
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
|
data/lib/productive/version.rb
CHANGED
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 '
|
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.
|
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-
|
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.
|
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.
|
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
|