pagy 5.6.0 → 5.6.1

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: 4a62cb4c6decfdc1013da6d14b38220aa361246637301a8d92b2d781440397bc
4
- data.tar.gz: 2555195198def80d6ec002928da8cef07419a76da9a196d8971d50e7fb5095e2
3
+ metadata.gz: a5d3090b61a9b11c0763a7c2d103ee36f4a36f0618e7e99b32357bab408a29bc
4
+ data.tar.gz: d5c3c376deda1c84558bbcff43809c9235cb2fc9ced7492ecdfe8df6397c873e
5
5
  SHA512:
6
- metadata.gz: f665f63cb281c25d6fcf430c12888def46ea46911e45a566fd52cb4943763efe775b094015d3b658b8322ade23a9a43a5888c60f10471bd567f000d5a67352c7
7
- data.tar.gz: 8c22ab2ad5efc0bd91b648d89217d1b71d77fbf669e1153b015954b79c2506c8f5ffe29d80e7d5988bea76b4bed35e7a76bb9c3657f60de0db3cde84b38e62e2
6
+ metadata.gz: 6591de1571e9b6bdf1a26668cf730dcbba4c83ef9f2d3727b3a1bec5f98c49a69ae2d55aab363444d85a3310e3de65fe119fb3606ca63cfdf56202c14c591568
7
+ data.tar.gz: 02fea4991aab7911107460e58e73a66f507f9fff990261f1536fddf016b9523003165ed0dfd024013282ef43fec221cb7fcfa27b7f6b23c60a742f175adc0eae
data/lib/config/pagy.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (5.6.0)
3
+ # Pagy initializer file (5.6.1)
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
 
@@ -40,22 +40,25 @@
40
40
  # See https://ddnexus.github.io/pagy/extras/array
41
41
  # require 'pagy/extras/array'
42
42
 
43
- # Calendar extra: Add pagination filtering by calendar time unit (Year, Month, Week Day)
43
+ # Calendar extra: Add pagination filtering by calendar time unit (year, quartr, month, week, day)
44
44
  # See https://ddnexus.github.io/pagy/extras/calendar
45
45
  # require 'pagy/extras/calendar'
46
46
  # Default for each unit
47
- # Pagy::Calendar::Year::DEFAULT[:order] = :asc # Time direction of pagination
48
- # Pagy::Calendar::Year::DEFAULT[:format] = '%Y' # strftime format
47
+ # Pagy::Calendar::Year::DEFAULT[:order] = :asc # Time direction of pagination
48
+ # Pagy::Calendar::Year::DEFAULT[:format] = '%Y' # strftime format
49
49
  #
50
- # Pagy::Calendar::Month::DEFAULT[:order] = :asc # Time direction of pagination
51
- # Pagy::Calendar::Month::DEFAULT[:format] = '%Y-%m' # strftime format
50
+ # Pagy::Calendar::Quarter::DEFAULT[:order] = :asc # Time direction of pagination
51
+ # Pagy::Calendar::Quarter::DEFAULT[:format] = '%Y-Q%q' # strftime format
52
52
  #
53
- # Pagy::Calendar::Week::DEFAULT[:order] = :asc # Time direction of pagination
54
- # Pagy::Calendar::Week::DEFAULT[:format] = '%Y-%W' # strftime format
55
- # Pagy::Calendar::Week::DEFAULT[:offset] = 0 # Day offset from Sunday (0: Sunday; 1: Monday;... 6: Saturday)
53
+ # Pagy::Calendar::Month::DEFAULT[:order] = :asc # Time direction of pagination
54
+ # Pagy::Calendar::Month::DEFAULT[:format] = '%Y-%m' # strftime format
56
55
  #
57
- # Pagy::Calendar::Day::DEFAULT[:order] = :asc # Time direction of pagination
58
- # Pagy::Calendar::Day::DEFAULT[:format] = '%Y-%m-%d' # strftime format
56
+ # Pagy::Calendar::Week::DEFAULT[:order] = :asc # Time direction of pagination
57
+ # Pagy::Calendar::Week::DEFAULT[:format] = '%Y-%W' # strftime format
58
+ # Pagy::Calendar::Week::DEFAULT[:offset] = 0 # Day offset from Sunday (0: Sunday; 1: Monday;... 6: Saturday)
59
+ #
60
+ # Pagy::Calendar::Day::DEFAULT[:order] = :asc # Time direction of pagination
61
+ # Pagy::Calendar::Day::DEFAULT[:format] = '%Y-%m-%d' # strftime format
59
62
  #
60
63
  # Uncomment the following block, if you need calendar localization without using the I18n extra
61
64
  # module LocalizePagyCalendar
@@ -5,7 +5,7 @@
5
5
  // Container of the whole pagy stuff
6
6
  function Pagy(){}
7
7
 
8
- Pagy.version = '5.6.0'
8
+ Pagy.version = '5.6.1'
9
9
 
10
10
  // Used by the waitForMe function
11
11
  Pagy.delay = 100
@@ -8,9 +8,16 @@ class Pagy # :nodoc:
8
8
  # Calendar quarter subclass
9
9
  class Quarter < Calendar
10
10
  DEFAULT = { order: :asc, # rubocop:disable Style/MutableConstant
11
- format: '%Y-Q%q' }
11
+ format: '%Y-Q%q' } # '%q' token
12
12
  MONTHS = 3 # number of months of the unit
13
13
  include MonthMixin
14
+
15
+ # The label for any page, with the substitution of the '%q' token
16
+ def label_for(page, opts = {})
17
+ start_time = start_for(page.to_i)
18
+ opts[:format] = (opts[:format] || @vars[:format]).gsub('%q') { (start_time.month / 4) + 1 }
19
+ localize(start_time, opts)
20
+ end
14
21
  end
15
22
  end
16
23
  end
data/lib/pagy/calendar.rb CHANGED
@@ -29,16 +29,14 @@ class Pagy # :nodoc:
29
29
  end
30
30
 
31
31
  # The label for the current page (it can pass along the I18n gem opts when it's used with the i18n extra)
32
- def label(**opts)
33
- label_for(@page, **opts)
32
+ def label(opts = {})
33
+ label_for(@page, opts)
34
34
  end
35
35
 
36
36
  # The label for any page (it can pass along the I18n gem opts when it's used with the i18n extra)
37
- def label_for(page, **opts)
37
+ def label_for(page, opts = {})
38
38
  opts[:format] ||= @vars[:format]
39
- start = start_for(page.to_i)
40
- opts[:format] = opts[:format].gsub('%q') { (start.month / 4) + 1 }
41
- localize(start, **opts)
39
+ localize(start_for(page.to_i), opts)
42
40
  end
43
41
 
44
42
  # Period of the active page (used for nested units)
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.0'
8
+ VERSION = '5.6.1'
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0
4
+ version: 5.6.1
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-11-26 00:00:00.000000000 Z
11
+ date: 2021-11-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Agnostic pagination in plain ruby. It does it all. Better.
14
14
  email: