pager_api 0.2.3 → 0.2.4

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
- SHA1:
3
- metadata.gz: 272db02b4f76bb3d1c27698b101212271e0ca95a
4
- data.tar.gz: 0d2b0907296dcee0df9cd8ddbabf812ac0bda525
2
+ SHA256:
3
+ metadata.gz: 26830a930c08e28898bc2b08427937a650edbacdfa3f30ba5e772a00f106f853
4
+ data.tar.gz: 0d0ce3d051f008887e2a12056583446d3fd3eee62590928bca58635d874410ac
5
5
  SHA512:
6
- metadata.gz: 48ed3858e051626ed9b2ecb90bdb7c39e26b59fad9c0e253d9682a8729d11e17dbd3f6867c872aced89bf4056c54d3bff07985b637865ddb2278c5ce62b75707
7
- data.tar.gz: 82f236a90b30831be1c9200483679dd18c17dfe945a418fda13191ea58ef9ba67f5693192dbc2fbac110711c73454a589f1c76cdcd938ff45aac62039ba7c3d7
6
+ metadata.gz: c14e9e1d77e18b61ba966320e413746107f8e2535cbd5c57b9cca149b6578d6f65050c4a08c607bd2e91b277321adaa5a807016d63cb5329ba4e2147bda43918
7
+ data.tar.gz: 7353b9e6620269f4b87f9e01a89c3457542e89a0caf37327227e2fb4235dd9f60babc031841e638b583c2dd6c0e69068b1484e6b6a5af211e86cebaf0415188b
@@ -0,0 +1,3 @@
1
+ ### What does this PR do?
2
+
3
+ *
data/README.md CHANGED
@@ -80,15 +80,18 @@ In the controller where you are providing a paginated collection, you may have s
80
80
 
81
81
  ```ruby
82
82
  class UsersController < ApplicationController
83
-
84
- def index
85
- users = User.page(params[:page]).per(15)
86
- render json: users, meta: { pagination: {
87
- per_page: 15,
88
- total_pages: 10,
89
- total_objects: 150
90
- } }
91
- end
83
+ def index
84
+ users = User.page(params[:page]).per(15)
85
+
86
+ render json: users,
87
+ meta: {
88
+ pagination: {
89
+ per_page: 15,
90
+ total_pages: 10,
91
+ total_objects: 150
92
+ }
93
+ }
94
+ end
92
95
  end
93
96
  ```
94
97
 
@@ -96,12 +99,11 @@ With `pager_api` it is really easy to achieve the above by:
96
99
 
97
100
  ```ruby
98
101
  class UsersController < ApplicationController
99
-
100
- def index
101
- # You can have any scope for the User class in this case
102
- # You can even send the paginated collection
103
- paginate User.unscoped, per_page: 15
104
- end
102
+ def index
103
+ # You can have any scope for the User class in this case
104
+ # You can even send the paginated collection
105
+ paginate User.unscoped, per_page: 15
106
+ end
105
107
  end
106
108
  ```
107
109
 
@@ -132,8 +134,8 @@ By default it will also include a `Link` header with the following information:
132
134
 
133
135
  ```
134
136
  # Link: <http://example.com/api/v1/users?page="2">; rel="next",
135
- # <http://example.com/api/v1//users?page="5">; rel="last",
136
- # <http://example.com/api/v1//users?page="1">; rel="first",
137
+ # <http://example.com/api/v1/users?page="5">; rel="last",
138
+ # <http://example.com/api/v1/users?page="1">; rel="first",
137
139
  # <http://example.com/api/v1/users?page="1">; rel="prev",
138
140
  ```
139
141
 
@@ -16,6 +16,9 @@ PagerApi.setup do |config|
16
16
  #
17
17
  # config.include_pagination_headers = true
18
18
 
19
+ # Set the Total-Pages Header name
20
+ # config.total_pages_header = "X-Total-Pages"
21
+
19
22
  # Set the Total-Count Header name
20
23
  # config.total_count_header = "X-Total-Count"
21
24
  end
@@ -34,7 +34,8 @@ module PagerApi
34
34
  end
35
35
 
36
36
  headers['Link'] = links.join(", ") unless links.empty?
37
- headers[PagerApi.total_count_header] = collection.total_pages
37
+ headers[PagerApi.total_pages_header] = collection.total_pages
38
+ headers[PagerApi.total_count_header] = collection.total_count
38
39
 
39
40
  return nil
40
41
  end
@@ -35,7 +35,8 @@ module PagerApi
35
35
  end
36
36
 
37
37
  headers['Link'] = links.join(", ") unless links.empty?
38
- headers[PagerApi.total_count_header] = collection.total_pages
38
+ headers[PagerApi.total_pages_header] = collection.total_pages
39
+ headers[PagerApi.total_count_header] = collection.total_entries
39
40
 
40
41
  return nil
41
42
  end
@@ -1,8 +1,7 @@
1
1
  module PagerApi
2
2
  class Railtie < Rails::Railtie
3
- config.after_initialize do
3
+ initializer "pager_api.configure_pagination_helpers" do
4
4
  require 'pager_api/hooks'
5
5
  end
6
6
  end
7
7
  end
8
-
@@ -1,3 +1,3 @@
1
1
  module PagerApi
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/lib/pager_api.rb CHANGED
@@ -12,6 +12,10 @@ module PagerApi
12
12
  mattr_accessor :include_pagination_headers
13
13
  @@include_pagination_headers = true
14
14
 
15
+ # Total Pages Header name
16
+ mattr_accessor :total_pages_header
17
+ @@total_pages_header = "X-Total-Pages"
18
+
15
19
  # Total Count Header name
16
20
  mattr_accessor :total_count_header
17
21
  @@total_count_header = "X-Total-Count"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pager_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abraham Kuri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-17 00:00:00.000000000 Z
11
+ date: 2019-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -47,6 +47,7 @@ extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
49
  - ".codeclimate.yml"
50
+ - ".github/PULL_REQUEST_TEMPLATE.md"
50
51
  - ".gitignore"
51
52
  - ".rspec"
52
53
  - ".rubocop.yml"
@@ -86,8 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
- rubyforge_project:
90
- rubygems_version: 2.5.1
90
+ rubygems_version: 3.0.3
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: A Rails pagination JSON handler, perfect for API