pagy 4.10.2 → 4.11.0

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
  SHA256:
3
- metadata.gz: af9dd0bcf50c1a54209d29f8a13318fc72f0cb76f07a1ff4e5df04c42e2a0712
4
- data.tar.gz: 16ec5ce47444e7ef5adc3a3db977dbdf9a518cbec5da0e3d0454c1e33433faae
3
+ metadata.gz: ed7987ef93f9d2d45f8b37c7d8c62546bb08b658699d4fdacf7e06b2e5abdefe
4
+ data.tar.gz: d2330d05cbf068d938425ed64ec3a0b0a16cf86d36cd2a2b2d8fc2568942a2d3
5
5
  SHA512:
6
- metadata.gz: eb9bcf0b26ef773511e98ab5985a9ce0b4639e79deb60ca2a45ed79cbf6beca5145e032d30907cd4453085a6f2b8072580c4ec4fabd8a788c61037d243e51dc0
7
- data.tar.gz: 2219496ad2c296a6fe3a93b7380696b29b7c77e16a6b4731d5322aa9df4be0bbf3433355f8780122be72c3149242d52afb617328d14c53522ec1b2f697b39323
6
+ metadata.gz: c938d41fae6e33cfd0d569655b134f2d239fe44f6fc5cdcfc76234e20d5c6a9e2650e6bd6f3230044783353ba65dde5afb24867af8df4c59189eee67dda25fea
7
+ data.tar.gz: 585446ab8b45078fcb666dc9a406516eeac7f715cca90118d5927f5d89acf0cc51056aa75aebed9885c3e5b25f61f9e4baad75869f2d244ab01a359919493b98
data/lib/config/pagy.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (4.10.2)
3
+ # Pagy initializer file (4.11.0)
4
4
  # Customize only what you really need and notice that Pagy works also without any of the following lines.
5
5
  # Should you just cherry pick part of this file, please maintain the require-order of the extras
6
6
 
@@ -42,6 +42,7 @@
42
42
  # Countless extra: Paginate without any count, saving one query per rendering
43
43
  # See https://ddnexus.github.io/pagy/extras/countless
44
44
  # require 'pagy/extras/countless'
45
+ # Pagy::VARS[:countless_minimal] = false # default (eager loading)
45
46
 
46
47
  # Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects
47
48
  # See https://ddnexus.github.io/pagy/extras/elasticsearch_rails
@@ -2,7 +2,7 @@
2
2
 
3
3
  function Pagy(){}
4
4
 
5
- Pagy.version = '4.10.2'
5
+ Pagy.version = '4.11.0'
6
6
 
7
7
  Pagy.delay = 100
8
8
 
data/lib/pagy.rb CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
5
5
 
6
6
  # main class
7
7
  class Pagy
8
- VERSION = '4.10.2'
8
+ VERSION = '4.11.0'
9
9
 
10
10
  # Root pathname to get the path of Pagy files like templates or dictionaries
11
11
  def self.root
@@ -11,6 +11,8 @@ class Pagy
11
11
  # Merge and validate the options, do some simple arithmetic and set a few instance variables
12
12
  def initialize(vars={}) # rubocop:disable Lint/MissingSuper
13
13
  @vars = VARS.merge(vars.delete_if{|_,v| v.nil? || v == '' }) # default vars + cleaned vars (can be overridden)
14
+ @vars[:fragment] = Pagy.deprecated_var(:anchor, @vars[:anchor], :fragment, @vars[:fragment]) if @vars[:anchor]
15
+
14
16
  INSTANCE_VARS_MIN.each do |k,min| # validate instance variables
15
17
  raise VariableError.new(self), "expected :#{k} >= #{min}; got #{@vars[k].inspect}" \
16
18
  unless @vars[k] && instance_variable_set(:"@#{k}", @vars[k].to_i) >= min
@@ -5,6 +5,8 @@ require 'pagy/countless'
5
5
 
6
6
  class Pagy
7
7
 
8
+ VARS[:countless_minimal] = false
9
+
8
10
  module Backend
9
11
  private # the whole module is private so no problem with including it in a controller
10
12
 
@@ -17,13 +19,15 @@ class Pagy
17
19
  # Sub-method called only by #pagy_countless: here for easy customization of variables by overriding
18
20
  def pagy_countless_get_vars(_collection, vars)
19
21
  pagy_set_items_from_params(vars) if defined?(UseItemsExtra)
20
- vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
22
+ vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
21
23
  vars
22
24
  end
23
25
 
24
26
  # Sub-method called only by #pagy_countless: here for easy customization of record-extraction by overriding
25
27
  def pagy_countless_get_items(collection, pagy)
26
28
  # This should work with ActiveRecord, Sequel, Mongoid...
29
+ return collection.offset(pagy.offset).limit(pagy.items) if pagy.vars[:countless_minimal]
30
+
27
31
  items = collection.offset(pagy.offset).limit(pagy.items + 1).to_a
28
32
  items_size = items.size
29
33
  items.pop if items_size == pagy.items + 1
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: 4.10.2
4
+ version: 4.11.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: 2021-08-18 00:00:00.000000000 Z
11
+ date: 2021-08-20 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,