pagy 0.23.1 → 1.0.0

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: ad93c6c0dd0077dcf253b7a4ef93e27022703e5085ec45b08f02d432db79e8ca
4
- data.tar.gz: 4db0c828b0cb890466672cb3edec16572c540c4d41de7c475bddb2f6d403c2d8
3
+ metadata.gz: 91857948aecc487fd59b4f35a1463fe0ae9fd5a3696fa831aebb23a8d79c439f
4
+ data.tar.gz: 8c867cbbe116fbd0da51072a53394aafa9a8c428d6410bc4a26edafe9605d393
5
5
  SHA512:
6
- metadata.gz: a4d0289d933016970b4320af48797e33bb7c1b1ebd819ecf7d378be94f5394772c6988e2987de5b38e2fce2e7b5ca80cdbc9eb8232b0379f240cad4d9f3805ed
7
- data.tar.gz: 39695de9f2c1f55b0fc12d76c98b21d6378eb9a96f7208eb784ad236b0e4619bebac386b80fdb9426948571ca0e6bed859273c1f7fedabd2f5d4cacb61768f3e
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
- # Out Of Range: Allow for easy handling of out of range pages
66
- # See https://ddnexus.github.io/pagy/extras/out_of_range
67
- # Pagy::VARS[:out_of_range_mode] = :last_page # default (other options: :empty_page and :exception)
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/out_of_range
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[:out_of_range_mode] = :last_page
6
+ VARS[:overflow] = :last_page
7
7
 
8
- def out_of_range?; @out_of_range end
8
+ def overflow?; @overflow end
9
9
 
10
- module OutOfRange
10
+ module Overflow
11
11
 
12
12
  def initialize(vars)
13
13
  super
14
- rescue OutOfRangeError
15
- @out_of_range = true # add the out_of_range flag
16
- case @vars[:out_of_range_mode]
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 :out_of_range_mode variable in [:last_page, :empty_page, :exception]; got #{@vars[:out_of_range_mode].inspect}"
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 OutOfRange
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.23.1'
6
+ class Pagy ; VERSION = '1.0.0'
7
7
 
8
- class OutOfRangeError < StandardError; attr_reader :pagy; def initialize(pagy) @pagy = pagy end; end
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(OutOfRangeError.new(self), "expected :page in 1..#{@last}; got #{@page.inspect}")
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.23.1
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-13 00:00:00.000000000 Z
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/out_of_range.rb
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