pagy 0.23.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/config/pagy.rb +3 -3
- data/lib/pagy/extras/{out_of_range.rb → overflow.rb} +9 -9
- data/lib/pagy.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91857948aecc487fd59b4f35a1463fe0ae9fd5a3696fa831aebb23a8d79c439f
|
4
|
+
data.tar.gz: 8c867cbbe116fbd0da51072a53394aafa9a8c428d6410bc4a26edafe9605d393
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35aa754fd0ab91e77054e850f0d5b0b545300bf0dc20c768351345ebbb81e2e2846aabc648cbe9e80121f7523051f677d29b4b384fe64927b26779c13702a7df
|
7
|
+
data.tar.gz: f7d926209081fa8b7f250bb2183d30f41a432524750dc2e832ec656473e0bf1e313b251caf054283535a515746740e619190f66ecb91a816091963fa531c9e79
|
data/lib/config/pagy.rb
CHANGED
@@ -62,9 +62,9 @@
|
|
62
62
|
# Pagy::VARS[:items_param] = :items # default
|
63
63
|
# Pagy::VARS[:max_items] = 100 # default
|
64
64
|
|
65
|
-
#
|
66
|
-
# See https://ddnexus.github.io/pagy/extras/
|
67
|
-
# Pagy::VARS[:
|
65
|
+
# Overflow: Allow for easy handling of overflowing pages
|
66
|
+
# See https://ddnexus.github.io/pagy/extras/overflow
|
67
|
+
# Pagy::VARS[:overflow] = :last_page # default (other options: :empty_page and :exception)
|
68
68
|
|
69
69
|
# Trim: Remove the page=1 param from links
|
70
70
|
# See https://ddnexus.github.io/pagy/extras/trim
|
@@ -1,19 +1,19 @@
|
|
1
|
-
# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/
|
1
|
+
# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/overflow
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
class Pagy
|
5
5
|
|
6
|
-
VARS[:
|
6
|
+
VARS[:overflow] = :last_page
|
7
7
|
|
8
|
-
def
|
8
|
+
def overflow?; @overflow end
|
9
9
|
|
10
|
-
module
|
10
|
+
module Overflow
|
11
11
|
|
12
12
|
def initialize(vars)
|
13
13
|
super
|
14
|
-
rescue
|
15
|
-
@
|
16
|
-
case @vars[:
|
14
|
+
rescue OverflowError
|
15
|
+
@overflow = true # add the overflow flag
|
16
|
+
case @vars[:overflow]
|
17
17
|
when :exception
|
18
18
|
raise # same as without the extra
|
19
19
|
when :last_page
|
@@ -25,7 +25,7 @@ class Pagy
|
|
25
25
|
@prev = @last # prev relative to the actual page
|
26
26
|
extend(Series) # special series for :empty_page
|
27
27
|
else
|
28
|
-
raise ArgumentError, "expected :
|
28
|
+
raise ArgumentError, "expected :overflow variable in [:last_page, :empty_page, :exception]; got #{@vars[:overflow].inspect}"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -43,6 +43,6 @@ class Pagy
|
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
-
prepend
|
46
|
+
prepend Overflow
|
47
47
|
|
48
48
|
end
|
data/lib/pagy.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
|
4
4
|
require 'pathname'
|
5
5
|
|
6
|
-
class Pagy ; VERSION = '0.
|
6
|
+
class Pagy ; VERSION = '1.0.0'
|
7
7
|
|
8
|
-
class
|
8
|
+
class OverflowError < StandardError; attr_reader :pagy; def initialize(pagy) @pagy = pagy end; end
|
9
9
|
|
10
10
|
# Root pathname to get the path of Pagy files like templates or dictionaries
|
11
11
|
def self.root; Pathname.new(__FILE__).dirname end
|
@@ -23,7 +23,7 @@ class Pagy ; VERSION = '0.23.1'
|
|
23
23
|
or raise(ArgumentError, "expected :#{k} >= #{min}; got #{@vars[k].inspect}")
|
24
24
|
end
|
25
25
|
@pages = @last = [(@count.to_f / @items).ceil, 1].max # cardinal and ordinal meanings
|
26
|
-
@page <= @last or raise(
|
26
|
+
@page <= @last or raise(OverflowError.new(self), "expected :page in 1..#{@last}; got #{@page.inspect}")
|
27
27
|
@offset = @items * (@page - 1) + @outset # pagination offset + outset (initial offset)
|
28
28
|
@items = @count - ((@pages-1) * @items) if @page == @last && @count > 0 # adjust items for last non-empty page
|
29
29
|
@from = @count == 0 ? 0 : @offset+1 - @outset # page begins from item
|
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.
|
4
|
+
version: 1.0.0
|
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-11-
|
11
|
+
date: 2018-11-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,
|
@@ -45,7 +45,7 @@ files:
|
|
45
45
|
- lib/pagy/extras/items.rb
|
46
46
|
- lib/pagy/extras/materialize.rb
|
47
47
|
- lib/pagy/extras/navs.rb
|
48
|
-
- lib/pagy/extras/
|
48
|
+
- lib/pagy/extras/overflow.rb
|
49
49
|
- lib/pagy/extras/searchkick.rb
|
50
50
|
- lib/pagy/extras/semantic.rb
|
51
51
|
- lib/pagy/extras/shared.rb
|