pagers 3.1.0 → 3.1.1

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
2
  SHA1:
3
- metadata.gz: 724e7f6b146b6719a0b7738c3d7ec5779ea40d48
4
- data.tar.gz: f2330ed5b923978d163599b69850651d6936b378
3
+ metadata.gz: 83f558d58e09ce7c0b66f12fd98922f84f1215da
4
+ data.tar.gz: c390e9e2bc8db538b87b780f3b3ae2fa4553d620
5
5
  SHA512:
6
- metadata.gz: 9df59fd8f65f0da8b75620454fd6a9d8b4622879277743c674a19200a78d0f298b5349a763776124071961dc2ec0b9d1920be0ec4ebb5345cb77a92ab20c2a59
7
- data.tar.gz: deb5bdeec0cd3841f9721aa2d60cff8746d6ff6f4072c1703e5fbd0011ed5ee0c8526f4bac3e6f95b16c0f355ee07a8bf13b7dfac30b7e54b48e755ccfed98f1
6
+ metadata.gz: cb5f308ff13491d392aa6b14c3af6b2231af570c4d621fe402366a90a4827c456afaf25bddd798564a3cd6eb1e9c1473fa7f4ce9780b74229bf4c470f93214a4
7
+ data.tar.gz: bffa4594b243f366f525cd4dfb603476e491fba99e25dda3687c46335b17a0db8e4d3a0f22bbeb7fe1f12562d10d600eaad3cf578eee282a98f6adbffa8b5e18
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ [![Gem Version](https://badge.fury.io/rb/pagers.svg)](http://badge.fury.io/rb/pagers) [![Code Climate](https://codeclimate.com/github/museways/pagers/badges/gpa.svg)](https://codeclimate.com/github/museways/pagers) [![Build Status](https://travis-ci.org/museways/pagers.svg?branch=3.0.3)](https://travis-ci.org/museways/pagers)
2
+
3
+ # Pagers
4
+
5
+ Minimalistic pagers inspired in kaminari and will_paginate for rails.
6
+
7
+ ## Install
8
+
9
+ Put this line in your Gemfile:
10
+ ```ruby
11
+ gem 'pagers'
12
+ ```
13
+
14
+ Then bundle:
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ ## Configuration
20
+
21
+ Generate the configuration file:
22
+ ```
23
+ rails g pagers:install
24
+ ```
25
+
26
+ The defaults values are:
27
+ ```ruby
28
+ Pagers.configure do |config|
29
+ config.length = 20
30
+ config.padding = 0
31
+ config.parameter = :page
32
+ config.pages = 5
33
+ end
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ Call the page scope from your models:
39
+ ```ruby
40
+ @collection = Model.page(1, length: 10, padding: 4)
41
+ ```
42
+
43
+ And in your views just:
44
+ ```erb
45
+ <%= paginate @collection %>
46
+ ```
47
+
48
+ NOTE: You can override the parameters in the scope and in the helper.
49
+
50
+ ## SEO
51
+
52
+ You can add the parameter to paths:
53
+ ```ruby
54
+ get 'search/:query/(:page)' => 'products#search'
55
+ ```
56
+
57
+ To produce routes like:
58
+ ```
59
+ search/sample
60
+ search/sample/2
61
+ search/sample/3
62
+ .
63
+ .
64
+ .
65
+ ```
66
+
67
+ ## Credits
68
+
69
+ This gem is maintained and funded by [museways](http://museways.com).
70
+
71
+ ## License
72
+
73
+ It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
@@ -8,8 +8,8 @@ module Pagers
8
8
  subclass.class_eval do
9
9
  if superclass == ::ActiveRecord::Base
10
10
  scope :page, ->(number, options={}) {
11
- length = options[:length] || Pagers.config.length
12
- padding = options[:padding] || Pagers.config.padding
11
+ length = (options[:length] || Pagers.config[:length])
12
+ padding = (options[:padding] || Pagers.config[:padding])
13
13
  current_page = [number.to_i, 1].max
14
14
  offset_value = (length * (current_page - 1)) + padding
15
15
  limit_value = length
@@ -1,5 +1,5 @@
1
1
  module Pagers
2
2
 
3
- VERSION = '3.1.0'
3
+ VERSION = '3.1.1'
4
4
 
5
5
  end
Binary file