grape-kaminari 0.1.3 → 0.1.5

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: 39b9d10952bfee243f89be38b9e6af5719e8ca22
4
- data.tar.gz: e01b8109a433341d6793016933eadc25e8c6d70d
3
+ metadata.gz: b08eab293223b2ad7369fe8c005894a97d6a674a
4
+ data.tar.gz: bb86d66fc3b9e8b013d9c34f0de183bcdb84a01b
5
5
  SHA512:
6
- metadata.gz: ae5c59b3b36412709143aa530463290842e937060c1581bc8b42ca51002dad01f07c58f8182a472d25cde9c365ea82bd0ab97329dec1be5eb7cb122d7d405839
7
- data.tar.gz: 3ed3761cdf18785e129fb22250567fe83af2e2735af4ad96b40ad452debf1b5844da4ea48a6d80c9234fa9140762975b9ab39a56f8aa102f7f4f33bb481efa2f
6
+ metadata.gz: e293e4e23a6d4ba7c3e024fa0112c2c012add6efe86ec578a581887a40a9b42b6c8776d9b19f30790ae0a447898860faf6c3595b55e552d53c63e322db93e0c4
7
+ data.tar.gz: 0c1330a4d198b4221c7c5a88924dabb678c467055afb118bdd3b3087b98316178d8eb37a4900be6890609503dc05aa57f4a67f3c18c38bdc10cc9a8e525b176f
data/README.md CHANGED
@@ -50,10 +50,14 @@ class MyApi < Grape::API
50
50
  end
51
51
  ```
52
52
 
53
- Now you can make a HTTP request to your endpoint with `page` (and `per_page`) params
53
+ Now you can make a HTTP request to your endpoint with the following parameters
54
+
55
+ - `page`: your current page (default: 1)
56
+ - `per_page`: how many to record in a page (default: 10)
57
+ - `offset`: the offset to start from (default: 0)
54
58
 
55
59
  ```
56
- curl -v http://host.dev/api/posts?page=3
60
+ curl -v http://host.dev/api/posts?page=3&offset=10
57
61
  ```
58
62
 
59
63
  and the response will be paginated and also will include pagination headers
@@ -65,6 +69,7 @@ X-Page: 3
65
69
  X-Per-Page: 10
66
70
  X-Next-Page: 4
67
71
  X-Prev-Page: 2
72
+ X-Offset: 10
68
73
  ```
69
74
 
70
75
  ## Contributing
@@ -8,13 +8,14 @@ module Grape
8
8
  base.class_eval do
9
9
  helpers do
10
10
  def paginate(collection)
11
- collection.page(params[:page]).per(params[:per_page]).tap do |data|
11
+ collection.page(params[:page]).per(params[:per_page]).padding(params[:offset]).tap do |data|
12
12
  header "X-Total", data.total_count.to_s
13
13
  header "X-Total-Pages", data.num_pages.to_s
14
14
  header "X-Per-Page", params[:per_page].to_s
15
15
  header "X-Page", data.current_page.to_s
16
16
  header "X-Next-Page", data.next_page.to_s
17
17
  header "X-Prev-Page", data.prev_page.to_s
18
+ header "X-Offset", params[:offset].to_s
18
19
  end
19
20
  end
20
21
  end
@@ -30,6 +31,7 @@ module Grape
30
31
  optional :per_page, type: Integer, default: options[:per_page],
31
32
  desc: 'Number of results to return per page.',
32
33
  max_value: options[:max_per_page]
34
+ optional :offset, type: Integer, default: 0
33
35
  end
34
36
  end
35
37
  end
@@ -1,5 +1,5 @@
1
1
  module Grape
2
2
  module Kaminari
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-kaminari
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tymon Tobolski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-21 00:00:00.000000000 Z
11
+ date: 2014-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape