pagy 4.7.1 → 4.8.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: 67bf0b9d4c13c5ca1e0698f6e4fd928e07eaad4fd3e8dfe2ef8d95612e5eb8d9
4
- data.tar.gz: 40fae4aadf56256885e813847a0df296bb857ea48ed629a49d6fd20092fe4dbf
3
+ metadata.gz: 487fac817e4547394310b019c71487100912f052b625708349f85bbae35d4ff4
4
+ data.tar.gz: 8965c695260c137926ff3cbaf1dbded460bb89cdeb95885af10e083ee61cdf89
5
5
  SHA512:
6
- metadata.gz: c2408b52d3e5cf97ea5d32cc2da809f2e9e38802767555b3ecd94a7947d9e52adf45e623c992acf2c1a12dcacf081f01823bc0e59fd97a6c980d68d08af1b8ea
7
- data.tar.gz: d0ffa69cc1cff5e0d5eb767e77d8abe63fe1df47f19c6535677c481c87ea3bd0fdc81042571fb02b3015b72377d9a7b9aa738bce0353d8e8ec62120608927ffe
6
+ metadata.gz: 2b51db8c041d553a42248e503ed2824056dcd582d6b805cc531d741208e47ba812fc086a4783ef4b1f8f5140788d3bda179740cc7341427a8708de44f5f0bb51
7
+ data.tar.gz: 052426c9f52caa3727bfd967f60b2a861379e95ef49f0074c61c6c1ee4369ec01e2b6fbc73f2ec4d57f2b4125da522f13a76ef5efea779892aaef11a874c290a
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017-2020 Domizio Demichelis
3
+ Copyright (c) 2017-2021 Domizio Demichelis
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/lib/config/pagy.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Pagy initializer file (4.7.1)
3
+ # Pagy initializer file (4.8.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
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  function Pagy(){}
4
4
 
5
- Pagy.version = '4.7.1'
5
+ Pagy.version = '4.8.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.7.1'
8
+ VERSION = '4.8.0'
9
9
 
10
10
  # Root pathname to get the path of Pagy files like templates or dictionaries
11
11
  def self.root
@@ -16,7 +16,9 @@ class Pagy
16
16
  Regexp.last_match(1)&.to_sym
17
17
  end
18
18
 
19
- def value = pagy.vars[variable]
19
+ def value
20
+ pagy.vars[variable]
21
+ end
20
22
  end
21
23
 
22
24
  # specific overflow error
@@ -66,7 +66,7 @@ class Pagy
66
66
  private
67
67
 
68
68
  def pagy_bulma_prev_next_html(pagy, link)
69
- html = if (p_prev = pagy.prev)
69
+ html = +if (p_prev = pagy.prev)
70
70
  link.call p_prev, pagy_t('pagy.nav.prev'), 'class="pagination-previous" aria-label="previous page"'
71
71
  else
72
72
  %(<a class="pagination-previous" disabled>#{pagy_t 'pagy.nav.prev'}</a>)
@@ -25,10 +25,10 @@ class Pagy
25
25
  rels = { 'first' => 1, 'prev' => pagy.prev, 'next' => pagy.next }
26
26
  rels['last'] = pagy.last unless countless
27
27
  url_str = pagy_url_for(pagy, PAGE_PLACEHOLDER, absolute: true)
28
- hash = { 'Link' => rels.filter_map do |rel, num|
28
+ hash = { 'Link' => rels.map do |rel, num| # filter_map if ruby >=2.7
29
29
  next unless num
30
30
  [ rel, url_str.sub(PAGE_PLACEHOLDER, num.to_s) ]
31
- end.to_h }
31
+ end.compact.to_h }
32
32
  headers = pagy.vars[:headers]
33
33
  hash[headers[:page]] = pagy.page.to_s if headers[:page]
34
34
  hash[headers[:items]] = pagy.vars[:items].to_s if headers[:items]
@@ -14,7 +14,9 @@ class Pagy
14
14
  end
15
15
 
16
16
  module UseI18nGem
17
- def pagy_t(key, **opts) = ::I18n.t(key, **opts)
17
+ def pagy_t(key, **opts)
18
+ ::I18n.t(key, **opts)
19
+ end
18
20
  end
19
21
  prepend UseI18nGem
20
22
 
@@ -40,7 +40,7 @@ class Pagy
40
40
  link = pagy_marked_link(pagy_link_proc(pagy, link_extra: link_extra))
41
41
  p_vars[:items] = p_items # restore the items
42
42
 
43
- html = %(<span#{p_id} class="pagy-items-selector-js" #{pagy_json_attr pagy, :items_selector, pagy.from, link}>)
43
+ html = +%(<span#{p_id} class="pagy-items-selector-js" #{pagy_json_attr pagy, :items_selector, pagy.from, link}>)
44
44
  input = %(<input type="number" min="1" max="#{p_vars[:max_items]}" value="#{p_items}" style="padding: 0; text-align: center; width: #{p_items.to_s.length+1}rem;">)
45
45
  html << pagy_t('pagy.items_selector_js', item_name: item_name || pagy_t(i18n_key || p_vars[:i18n_key], count: p_items),
46
46
  items_input: input,
@@ -6,7 +6,9 @@ class Pagy
6
6
  module UseOverflowExtra
7
7
  VARS[:overflow] = :empty_page
8
8
 
9
- def overflow? = @overflow
9
+ def overflow?
10
+ @overflow
11
+ end
10
12
 
11
13
  def initialize(vars)
12
14
  @overflow ||= false # don't override if :last_page re-run the method after an overflow
@@ -46,7 +46,11 @@ class Pagy
46
46
  "#{url_string}#{query_string}#{p_vars[:fragment]}"
47
47
  end
48
48
  end
49
- Helpers.prepend UseStandaloneExtra
49
+
50
+ # single line in order to avoid complicating simplecov already tested with other GitHub Actions
51
+ Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') \
52
+ && Helpers.prepend(UseStandaloneExtra) \
53
+ || ( Frontend.prepend(UseStandaloneExtra); Backend.prepend(UseStandaloneExtra) if defined?(Pagy::Backend::METADATA) ) # rubocop:disable Style/Semicolon
50
54
 
51
55
  # defines a dummy #params method if not already defined in the including module
52
56
  module Backend
@@ -12,7 +12,7 @@ class Pagy
12
12
  link_proc = super(pagy, link_extra: link_extra)
13
13
  return link_proc unless pagy.vars[:enable_trim_extra]
14
14
  lambda do |num, text=num, extra=''|
15
- link = link_proc.call(num, text, extra)
15
+ link = +link_proc.call(num, text, extra)
16
16
  return link unless num == 1
17
17
  link.sub!(/[?&]#{pagy.vars[:page_param]}=1\b(?!&)|\b#{pagy.vars[:page_param]}=1&/, '')
18
18
  end
@@ -11,7 +11,7 @@ class Pagy
11
11
  p_id = %( id="#{pagy_id}") if pagy_id
12
12
  link = pagy_link_proc(pagy, link_extra: link_extra)
13
13
 
14
- html = %(<ul#{p_id} class="pagy-uikit-nav uk-pagination uk-flex-center">#{pagy_uikit_prev_html pagy, link})
14
+ html = +%(<ul#{p_id} class="pagy-uikit-nav uk-pagination uk-flex-center">#{pagy_uikit_prev_html pagy, link})
15
15
  pagy.series.each do |item|
16
16
  html << case item
17
17
  when Integer then %(<li>#{link.call item}</li>)
data/lib/pagy/frontend.rb CHANGED
@@ -25,7 +25,9 @@ class Pagy
25
25
  end
26
26
 
27
27
  # Sub-method called only by #pagy_url_for: here for easy customization of params by overriding
28
- def pagy_get_params(params) = params
28
+ def pagy_get_params(params)
29
+ params
30
+ end
29
31
  end
30
32
 
31
33
  # All the code here has been optimized for performance: it may not look very pretty
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.7.1
4
+ version: 4.8.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-05-13 00:00:00.000000000 Z
11
+ date: 2021-06-08 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,
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - ">="
112
112
  - !ruby/object:Gem::Version
113
- version: '3.0'
113
+ version: '2.5'
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ">="