roku_pages 0.0.8 → 0.0.9

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: 6d213effc36f44a85e7b2c97ca98a7c02418e235
4
- data.tar.gz: 9bc7819e44721545e083e56e71c7d044b4f306a0
3
+ metadata.gz: 02f353e4f68cf40c0bd1e87f5840ec9526ebab5a
4
+ data.tar.gz: e03c44b42a6a08bd936ea9fdb3e1aa1df36509b7
5
5
  SHA512:
6
- metadata.gz: 1c81ff1be3ebbb7882df73b8284fc3868f92fbd17ae9314ba80038de71b13bbf98a9714fca553f39f1865b0ac7b70cf7d16c05370d862d056429631671699975
7
- data.tar.gz: b1264e268189fa9a1a4875fce67e525d544b73add8ae40134c2c33c7345af50c148d5eadfd98cd4e31740cdcb88b9f7310f3553c4b58ca4df87c4044b6ea2cd1
6
+ metadata.gz: 099666ba43373444030eef7c320012b45f30de91fac2b8132e7e4ca5127de19c7809db70dab80055fc15742ad0f6997c1f149a0d1f101fbf401a44f0f9a40de3
7
+ data.tar.gz: 730d8196712286cd254048c29ecd11ae0c00b20e00e0e3408d46262a0132caee692bacbaefcdd58782bb952df1357552bd4a37d36ef5c126d7b0d164562d0bcd
data/README.rdoc CHANGED
@@ -2,10 +2,13 @@
2
2
  Dumb idea for adding pagination to header.
3
3
  Only page numbers and total, no other.
4
4
 
5
+
5
6
  = Install
6
- gem 'roku_pages', '0.0.7'
7
+ gem 'roku_pages', '0.0.8'
7
8
 
8
9
  = Usage
10
+ options(paginate) > params > default method
11
+
9
12
  use <tt>params[:page]</tt> and <tt>params[:per_page]</tt>
10
13
 
11
14
  default <tt>page: 1</tt> and <tt>per_page: 25</tt>
@@ -14,15 +17,27 @@ just replace render
14
17
  paginate json: articles
15
18
 
16
19
  result
17
- Pagination:{"first":1,"prev":1,"current":1,"next":2,"last":4}
18
- Total:4
20
+ Pagination:{"first":1,"prev":1,"current":1,"next":1,"last":1,"total":"4"}
19
21
 
20
22
  you can also override by this
21
23
  paginate json: articles, page: 2, per_page: 2
22
24
 
25
+
26
+ or override the default method in controller
27
+ def paginate_page
28
+ 2
29
+ end
30
+
31
+ def paginate_per_page
32
+ 1
33
+ end
34
+
35
+ def paginate_hash
36
+ super.merge!({first: "1st"})
37
+ end
38
+
23
39
  result
24
- Pagination:{"first":1,"prev":1,"current":2,"next":2,"last":2}
25
- Total:4
40
+ Pagination:{"1st":1,"prev":1,"current":2,"next":3,"last":4,"total":"4"}
26
41
 
27
42
  you can use +json+ or +xml+
28
43
  paginate json: articles
data/lib/roku_pages.rb CHANGED
@@ -30,7 +30,7 @@ module RokuPages
30
30
  pages[pages_key[:next]] = collection.current_page + 1 < collection.total_pages ? collection.current_page + 1 : collection.total_pages
31
31
  pages[pages_key[:last]] = collection.total_pages
32
32
  pages[pages_key[:total]] = collection.total_count.to_s
33
- headers['Pagination'] = pages.to_json
33
+ headers[paginate_root] = pages.to_json
34
34
  end
35
35
 
36
36
  render options
@@ -54,6 +54,10 @@ module RokuPages
54
54
  total: :total
55
55
  }
56
56
  end
57
+
58
+ def paginate_root
59
+ "Pagination"
60
+ end
57
61
  end
58
62
  end
59
63
 
@@ -1,3 +1,3 @@
1
1
  module RokuPages
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roku_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - rokugou