frederick_api 0.4.0 → 0.4.1

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
  SHA1:
3
- metadata.gz: dcd5376c71e168c4a465fea05d201c98fdeb34a8
4
- data.tar.gz: c32d4ff431afc095213e192113857e7cf64008c7
3
+ metadata.gz: 0542bb1b524ac3beadabf3957603b706c3832f74
4
+ data.tar.gz: 27438c224828c5c883ea2bf3e0e4c35615fcd43a
5
5
  SHA512:
6
- metadata.gz: 25a914b9aa9e5d2db5cb6c0fff20e7fa3ac9fd81723bfb036dd4a17beb486ea4c1a72afc1a46e2fb40c93001a86f24859110192a8bdcd79c01fa6f12870a44c0
7
- data.tar.gz: ec3f75966e35fea113626823e6e5b8429280377ace75231a63d6ce4caf4873d3b5afe4b16426518091f80ae20463af2f1645d7c795434c065372c0efc3558935
6
+ metadata.gz: c0cdf621a912ae97709e06e1baf84c752ea794e9eaa78c6c162929bd930e223baea9f49b1e57c4dec97a06a3755a3723b78e8cf4f493b88dc7a6f6c34d7a8e40
7
+ data.tar.gz: caadf12be20a118be50925dc51ae5d3d7110d403790d2e43e32b6a439433065ba62f5e67024388241debf26119b6b1691faa7faaa0bc71cc6336f31b2e6de8b2
@@ -7,8 +7,8 @@ module FrederickAPI
7
7
  # Fixes param names for pagination
8
8
  # Also adds ability to get all records from a paginated API
9
9
  class Paginator < JsonApiClient::Paginating::Paginator
10
- self.page_param = 'page.number'
11
- self.per_page_param = 'page.size'
10
+ self.page_param = 'number'
11
+ self.per_page_param = 'size'
12
12
 
13
13
  def all_records
14
14
  current_result_set = nil
@@ -25,6 +25,28 @@ module FrederickAPI
25
25
 
26
26
  results
27
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.fetch("page.#{page_param}") do
34
+ current_page
35
+ end.to_i
36
+ else
37
+ current_page
38
+ end
39
+ end
40
+
41
+ def per_page
42
+ params.fetch("page.#{per_page_param}") do
43
+ result_set.length
44
+ end.to_i
45
+ end
46
+
47
+ def current_page
48
+ params.fetch("page.#{page_param}", 1).to_i
49
+ end
28
50
  end
29
51
  end
30
52
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module FrederickAPI
4
4
  # Current gem version
5
- VERSION = '0.4.0'
5
+ VERSION = '0.4.1'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frederick_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frederick Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-13 00:00:00.000000000 Z
11
+ date: 2017-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
19
+ version: 1.5.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.5'
26
+ version: 1.5.3
27
27
  description: Ruby client for the Frederick API
28
28
  email:
29
29
  - tech@hirefrederick.com
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  version: '0'
73
73
  requirements: []
74
74
  rubyforge_project:
75
- rubygems_version: 2.6.13
75
+ rubygems_version: 2.6.12
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: Frederick API Client