pagy 5.1.1 → 5.1.2

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: 5300f9784ba9ab19522910b10e2f100a9823b5b52c91738966e946c91a08702a
4
- data.tar.gz: 2dc3599be82ee24dba9e8074c1b84e5443d69550ddec6fd32967f66a316ecedd
3
+ metadata.gz: 4af6c795ba446552a412f0f45e76a267cf767d8f4dec3564a90096525bb298ea
4
+ data.tar.gz: 57a3f62877f0ed653ebe68f59963fb865e252e68c55e5c3a91794b9aa3b9584a
5
5
  SHA512:
6
- metadata.gz: 36b6893409fad1745593238f9a169623841dc4b55172fd2263f0bba09b3436e8c7f4e6f5ff6fc65bd56233b510daef44df60238189249547205f17087ddd69ab
7
- data.tar.gz: bddaf3afe21358ed1b9ed73de5585931f4dac9018cc37b30c268aae29cdd7f836ac4f77e4ea419f9268dc4f9f247907996ab2461cd6fc6a44d9e80467b513567
6
+ metadata.gz: 0520f9933ea293895b8d26b0a78ea0af1a61054b5b89fce3a06c1f8f292d82357f6e105f76ab7bd4665f6ee9765bc69ce284428b8fe61b8f0a6b4768136c8e4a
7
+ data.tar.gz: '0903950d58220f510b5c2700b42f23f19c5cd267bc73eb5404d918863717b816836609256ef3a340534a9bc74e50260915b8b023b502c9dbe503bb443fab968f'
data/lib/config/pagy.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (5.1.1)
3
+ # Pagy initializer file (5.1.2)
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
 
@@ -3,7 +3,7 @@
3
3
  // Container of the whole pagy stuff
4
4
  function Pagy(){}
5
5
 
6
- Pagy.version = '5.1.1'
6
+ Pagy.version = '5.1.2'
7
7
 
8
8
  // Used by the waitForMe function
9
9
  Pagy.delay = 100
@@ -3,6 +3,8 @@
3
3
 
4
4
  require 'uri'
5
5
  class Pagy
6
+ # Use pagy without any request object, nor Rack environment/gem, nor any defined params method,
7
+ # even in the irb/rails console without any app or config.
6
8
  module StandaloneExtra
7
9
  # Extracted from Rack::Utils and reformatted for rubocop
8
10
  module QueryUtils
@@ -34,15 +36,15 @@ class Pagy
34
36
  # it works exactly as the regular #pagy_url_for, relying on the params method and Rack.
35
37
  # If there is a defined pagy.vars[:url] variable it does not need the params method nor Rack.
36
38
  def pagy_url_for(pagy, page, absolute: nil)
37
- p_vars = pagy.vars
38
- return super unless (url = p_vars[:url])
39
+ vars = pagy.vars
40
+ return super unless (url = vars[:url])
39
41
 
40
- params = p_vars[:params]
41
- params[p_vars[:page_param].to_s] = page
42
- params[p_vars[:items_param].to_s] = p_vars[:items] if defined?(ItemsExtra)
42
+ params = vars[:params].clone # safe when it gets reused
43
+ params[vars[:page_param]] = page
44
+ params[vars[:items_param]] = vars[:items] if vars[:items_extra]
43
45
 
44
46
  query_string = "?#{QueryUtils.build_nested_query(pagy_massage_params(params))}"
45
- "#{url}#{query_string}#{p_vars[:fragment]}"
47
+ "#{url}#{query_string}#{vars[:fragment]}"
46
48
  end
47
49
  end
48
50
  # In ruby 3+ `UrlHelpers.prepend StandaloneExtra` would be enough instead of using the next 2 lines
@@ -7,13 +7,13 @@ class Pagy
7
7
  # It supports all Rack-based frameworks (Sinatra, Padrino, Rails, ...).
8
8
  # For non-rack environments you can use the standalone extra
9
9
  def pagy_url_for(pagy, page, absolute: nil)
10
- p_vars = pagy.vars
11
- params = request.GET.merge(p_vars[:params])
12
- params[p_vars[:page_param].to_s] = page
13
- params[p_vars[:items_param].to_s] = p_vars[:items] if defined?(ItemsExtra)
10
+ vars = pagy.vars
11
+ params = request.params.merge(vars[:params].transform_keys(&:to_s))
12
+ params[vars[:page_param].to_s] = page
13
+ params[vars[:items_param].to_s] = vars[:items] if vars[:items_extra]
14
14
 
15
15
  query_string = "?#{Rack::Utils.build_nested_query(pagy_massage_params(params))}"
16
- "#{request.base_url if absolute}#{request.path}#{query_string}#{p_vars[:fragment]}"
16
+ "#{request.base_url if absolute}#{request.path}#{query_string}#{vars[:fragment]}"
17
17
  end
18
18
 
19
19
  # Sub-method called only by #pagy_url_for: here for easy customization of params by overriding
data/lib/pagy.rb CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
5
5
 
6
6
  # Core class
7
7
  class Pagy
8
- VERSION = '5.1.1'
8
+ VERSION = '5.1.2'
9
9
 
10
10
  # Root pathname to get the path of Pagy files like templates or dictionaries
11
11
  def self.root
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.1
4
+ version: 5.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Domizio Demichelis