pagy 5.6.4 → 5.6.5
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 +4 -4
- data/lib/config/pagy.rb +1 -1
- data/lib/javascripts/pagy.js +1 -1
- data/lib/pagy/backend.rb +1 -1
- data/lib/pagy/calendar.rb +2 -2
- data/lib/pagy/extras/arel.rb +3 -0
- data/lib/pagy/extras/array.rb +1 -1
- data/lib/pagy/extras/calendar.rb +3 -1
- data/lib/pagy/extras/i18n.rb +2 -2
- data/lib/pagy/frontend.rb +1 -1
- data/lib/pagy/i18n.rb +2 -1
- data/lib/pagy.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bc0ec346bfde6c907da343d7c3f7ad611cbb69f4ed8e36aa09b69b48276ecb6
|
4
|
+
data.tar.gz: 9d936c804c00f7eb530c9a7f5d1ecf763704daf84e35b9a3288eae2f88d3e3be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2e92a735ed04def206a2cdd81577ff39042cc03f98a4343b6e8889c008bb5ba8277bd76168b1d3f39067bc68b9e9b4b1805721cac9a12cded2a491b106023db
|
7
|
+
data.tar.gz: 825ad4c0c076d4dae52ba69772b0c827662181ddd9bd077c41ec5a167b0da506bf7153493a99ab5a704043f08918b1d0e460430c8fa7ee08d0675b1f3d1a5619
|
data/lib/config/pagy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Pagy initializer file (5.6.
|
3
|
+
# Pagy initializer file (5.6.5)
|
4
4
|
# Customize only what you really need and notice that the core 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
|
|
data/lib/javascripts/pagy.js
CHANGED
data/lib/pagy/backend.rb
CHANGED
data/lib/pagy/calendar.rb
CHANGED
@@ -41,7 +41,7 @@ class Pagy # :nodoc:
|
|
41
41
|
|
42
42
|
protected
|
43
43
|
|
44
|
-
# Base class method for the setup of the unit variables
|
44
|
+
# Base class method for the setup of the unit variables (subclasses must implement it and call super)
|
45
45
|
def setup_unit_vars
|
46
46
|
raise VariableError.new(self, :format, 'to be a strftime format', @vars[:format]) unless @vars[:format].is_a?(String)
|
47
47
|
raise VariableError.new(self, :order, 'to be in [:asc, :desc]', @order) \
|
@@ -85,6 +85,6 @@ class Pagy # :nodoc:
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
88
|
-
|
88
|
+
# Require the subclass files in UNITS (no custom unit at this point yet)
|
89
89
|
Calendar::UNITS.each { |unit| require "pagy/calendar/#{unit}" }
|
90
90
|
end
|
data/lib/pagy/extras/arel.rb
CHANGED
@@ -6,11 +6,13 @@ class Pagy # :nodoc:
|
|
6
6
|
module ArelExtra
|
7
7
|
private
|
8
8
|
|
9
|
+
# Return Pagy object and paginated collection/results
|
9
10
|
def pagy_arel(collection, vars = {})
|
10
11
|
pagy = Pagy.new(pagy_arel_get_vars(collection, vars))
|
11
12
|
[pagy, pagy_get_items(collection, pagy)]
|
12
13
|
end
|
13
14
|
|
15
|
+
# Sub-method called only by #pagy_arel: here for easy customization of variables by overriding
|
14
16
|
def pagy_arel_get_vars(collection, vars)
|
15
17
|
pagy_set_items_from_params(vars) if defined?(ItemsExtra)
|
16
18
|
vars[:count] ||= pagy_arel_count(collection)
|
@@ -18,6 +20,7 @@ class Pagy # :nodoc:
|
|
18
20
|
vars
|
19
21
|
end
|
20
22
|
|
23
|
+
# Count using Arel when grouping
|
21
24
|
def pagy_arel_count(collection)
|
22
25
|
if collection.group_values.empty?
|
23
26
|
# COUNT(*)
|
data/lib/pagy/extras/array.rb
CHANGED
data/lib/pagy/extras/calendar.rb
CHANGED
@@ -26,7 +26,9 @@ class Pagy # :nodoc:
|
|
26
26
|
|
27
27
|
# Setup and return the calendar objects and the filtered collection
|
28
28
|
def pagy_setup_calendar(collection, conf)
|
29
|
-
units
|
29
|
+
units = Calendar::UNITS & conf.keys # get the units in time length desc order
|
30
|
+
raise ArgumentError, 'no calendar unit found in pagy_calendar configuration' if units.empty?
|
31
|
+
|
30
32
|
page_param = conf[:pagy][:page_param] || DEFAULT[:page_param]
|
31
33
|
units.each do |unit| # set all the :page_param vars for later deletion
|
32
34
|
unit_page_param = :"#{unit}_#{page_param}"
|
data/lib/pagy/extras/i18n.rb
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
class Pagy # :nodoc:
|
5
5
|
# Use ::I18n gem
|
6
6
|
module I18nExtra
|
7
|
-
# Frontend overriding
|
7
|
+
# Frontend overriding for translation
|
8
8
|
module Frontend
|
9
9
|
def pagy_t(key, **opts)
|
10
10
|
::I18n.t(key, **opts)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
# Calendar overriding
|
14
|
+
# Calendar overriding for localization (see also the block in the calendar section of the config/pagy.rb initializer)
|
15
15
|
module Calendar
|
16
16
|
def localize(time, opts)
|
17
17
|
::I18n.l(time, **opts)
|
data/lib/pagy/frontend.rb
CHANGED
@@ -77,7 +77,7 @@ class Pagy
|
|
77
77
|
# Similar to I18n.t: just ~18x faster using ~10x less memory
|
78
78
|
# (@pagy_locale explicitly initialized in order to avoid warning)
|
79
79
|
def pagy_t(key, opts = {})
|
80
|
-
Pagy::I18n.
|
80
|
+
Pagy::I18n.translate(@pagy_locale ||= nil, key, opts)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
data/lib/pagy/i18n.rb
CHANGED
@@ -153,11 +153,12 @@ class Pagy
|
|
153
153
|
end
|
154
154
|
|
155
155
|
# Translate and pluralize the key with the locale DATA
|
156
|
-
def
|
156
|
+
def translate(locale, key, opts = {})
|
157
157
|
data, pluralize = DATA[locale]
|
158
158
|
translation = data[key] || (opts[:count] && data[key += ".#{pluralize.call(opts[:count])}"]) \
|
159
159
|
or return %([translation missing: "#{key}"])
|
160
160
|
translation.gsub(/%{[^}]+?}/) { |match| opts[:"#{match[2..-2]}"] || match }
|
161
161
|
end
|
162
|
+
alias t translate
|
162
163
|
end
|
163
164
|
end
|
data/lib/pagy.rb
CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
|
|
5
5
|
|
6
6
|
# Core class
|
7
7
|
class Pagy
|
8
|
-
VERSION = '5.6.
|
8
|
+
VERSION = '5.6.5'
|
9
9
|
|
10
10
|
# Root pathname to get the path of Pagy files like templates or dictionaries
|
11
11
|
def self.root
|
@@ -76,6 +76,7 @@ class Pagy
|
|
76
76
|
page.to_s
|
77
77
|
end
|
78
78
|
|
79
|
+
# Allow the customization of the output (overridden by the calendar extra)
|
79
80
|
def label
|
80
81
|
@page.to_s
|
81
82
|
end
|
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: 5.6.
|
4
|
+
version: 5.6.5
|
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-12-
|
11
|
+
date: 2021-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Agnostic pagination in plain ruby. It does it all. Better.
|
14
14
|
email:
|