pagy 0.9.0 → 0.9.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
  SHA256:
3
- metadata.gz: 8867ae39673157a4e3256e40bb71a435d4bc45418ece6c510ac4913fc8d2c917
4
- data.tar.gz: f5cd6d9d8becbdd00c9878f4c10472302e2813b3163fe33bc21bd71c240544e3
3
+ metadata.gz: ac035613ae9e5c82b9d358f4e88f6d04dbad6bf665e58e9d24fbcbbc62038064
4
+ data.tar.gz: 0216c586e299a80f12a390726ff6246f18e251b3a3d7903faab91f295b2b40de
5
5
  SHA512:
6
- metadata.gz: 27619900377812a56104aa89542ebe6b6ab2201231b725ca1e708b3b02e0f540265d525e2bbe9647fa993338e6fe0003a0380818daaabc7405671910215fa064
7
- data.tar.gz: 726345048bbd3056b6612d4acbe11bdf76e6abb515b3948cf165668da05dc99071d2086ec235466281be1543b344f81de4f6422941db883d537534b9369499ac
6
+ metadata.gz: fdc2a76ae6492bf5d983ffb7899805d51c3b17e083742ad6f19c1d9f2c854dd47cb685ce018590ec0482ba62fac30957eccfe9f49b8921e4cd612f60aa3d8a52
7
+ data.tar.gz: 335243eccb83babf430f3d63a899384e01f01d05d6229775742157c873f08579783aec0136e52e5b591801a0154a2b358af3df758ff0417666b8adae96eab35a
data/lib/pagy.rb CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  require 'pathname'
4
4
 
5
- class Pagy ; VERSION = '0.9.0'
5
+ class Pagy ; VERSION = '0.9.1'
6
6
 
7
- class OutOfRangeError < StandardError; end
7
+ class OutOfRangeError < StandardError; attr_reader :pagy; def initialize(pagy) @pagy = pagy end; end
8
8
 
9
9
  # Root pathname to get the path of Pagy files like templates or dictionaries
10
10
  def self.root; Pathname.new(__FILE__).dirname end
11
11
 
12
12
  # default vars
13
- VARS = { page:1, items:20, outset:0, size:[1,4,4,1], page_param: :page, params: {}, anchor: ''.freeze, link_extra: ''.freeze, item_path: 'pagy.info.item_name'.freeze }
13
+ VARS = { page:1, items:20, outset:0, size:[1,4,4,1], page_param: :page, params:{}, anchor:''.freeze, link_extra:''.freeze, item_path:'pagy.info.item_name'.freeze }
14
14
 
15
15
  attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :from, :to, :prev, :next
16
16
 
@@ -22,7 +22,7 @@ class Pagy ; VERSION = '0.9.0'
22
22
  or raise(ArgumentError, "expected :#{k} >= #{min}; got #{instance_variable_get(:"@#{k}").inspect}")
23
23
  end
24
24
  @pages = @last = [(@count.to_f / @items).ceil, 1].max # cardinal and ordinal meanings
25
- @page >= 1 && @page <= @last or raise(OutOfRangeError, "expected :page in 1..#{@last}; got #{@page.inspect}")
25
+ @page >= 1 && @page <= @last or raise(OutOfRangeError.new(self), "expected :page in 1..#{@last}; got #{@page.inspect}")
26
26
  @offset = @items * (@page - 1) + @outset # pagination offset + outset (initial offset)
27
27
  @items = @count - ((@pages-1) * @items) if @page == @last # adjust items for last page
28
28
  @from = @count == 0 ? 0 : @offset+1 - @outset # page begins from item
@@ -35,13 +35,16 @@
35
35
 
36
36
 
37
37
  # Pagy Variables
38
- # All the Pagy::VARS here are set for all the Pagy instances but can be
39
- # overridden by just passing them to Pagy.new or the #pagy controller method
38
+ # See https://ddnexus.github.io/pagy/api/pagy#variables
39
+ # All the Pagy::VARS are set for all the Pagy instances but can be overridden
40
+ # per instance by just passing them to Pagy.new or the #pagy controller method
40
41
 
41
- # Instance variables (See https://ddnexus.github.io/pagy/api/pagy#instance-variables)
42
+ # Instance variables
43
+ # See https://ddnexus.github.io/pagy/api/pagy#instance-variables
42
44
  # Pagy::VARS[:items] = 20 # default
43
45
 
44
- # Other Variables (See https://ddnexus.github.io/pagy/api/pagy#other-variables)
46
+ # Other Variables
47
+ # See https://ddnexus.github.io/pagy/api/pagy#other-variables
45
48
  # Pagy::VARS[:size] = [1,4,4,1] # default
46
49
  # Pagy::VARS[:page_param] = :page # default
47
50
  # Pagy::VARS[:params] = {} # default
@@ -49,12 +52,13 @@
49
52
  # Pagy::VARS[:link_extra] = 'data-remote="true"' # example
50
53
  # Pagy::VARS[:item_path] = 'activerecord.models.product' # example
51
54
 
55
+
52
56
  # Pagy::Frontend::I18N Constant
53
57
  # See https://ddnexus.github.io/pagy/api/frontend#i18n
54
58
  # Pagy::Frontend::I18N[:plurals] = -> (c) {([:zero, :one][c] || :other).to_s # default
55
59
  # Pagy::Frontend::I18N.load_file('path/to/dictionary.yml') # load a custom file
56
60
 
57
61
 
58
- # Rails: extras assets path required by compact, items qnd responsive extras
59
- # See https://ddnexus.github.io/pagy/extras/compact and https://ddnexus.github.io/pagy/extras/responsive
62
+ # Rails: extras assets path required by compact, items and responsive extras
63
+ # See https://ddnexus.github.io/pagy/extras
60
64
  # Rails.application.config.assets.paths << Pagy.root.join('pagy', 'extras', 'javascripts')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-17 00:00:00.000000000 Z
11
+ date: 2018-06-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Agnostic pagination in plain ruby: it works with any framework, ORM
14
14
  and DB type, with all kinds of collections, even pre-paginated, scopes, Arrays,