pagy 3.11.0 → 3.13.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: 5cadf66aafed63e69474727fab67e77da2038ad95e9a1430d5546da2b5f9d1a2
4
- data.tar.gz: 6a716cef53d59459b3406e0e330d44536b8f5ec738d0661140d3fd805ef613ec
3
+ metadata.gz: e16e1b508c2096d675f846a898da3e1338e8535b460074535e1742cd08a3c6cb
4
+ data.tar.gz: 450a453312266d3af1f8b18a9cd0734ebc002a6533b9f6c269d7802706f66116
5
5
  SHA512:
6
- metadata.gz: 563e233579eab779aa3210751143c617369d3e0f34bd5365a7e50ed6bd07346b1aa052a3a2fec8b25b375dbc6d837836639915ab01160aff857938fbac515412
7
- data.tar.gz: 02a8a1d45a18b5ea644e24c3fa50b6d4cdb48c3fd27fb135ece5fd981ea246da568759427f1daba2cf29705fe1dbcaf6e52f97f8cca84744fd285bee0cca4338
6
+ metadata.gz: da6eccb117de48a28d0572d011b29040c7c5f17dcb8282a1a7eadc0c5d11f38aea062e6a4f8e6db40ceba2b2022a54af1deb74e7a2eeb720f0b76b4fdba11098
7
+ data.tar.gz: 873549bfee07251e7c5948eb24837f01309db20b69e512cffa53a8552e5ca6c634c60a49239d0e87480635118e83e213acc29981d9cbd0d30874a912443e4a6d
data/lib/config/pagy.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
- # Pagy initializer file (3.11.0)
4
+ # Pagy initializer file (3.13.0)
5
5
  # Customize only what you really need and notice that Pagy works also without any of the following lines.
6
6
  # Should you just cherry pick part of this file, please maintain the require-order of the extras
7
7
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  function Pagy(){}
4
4
 
5
- Pagy.version = '3.11.0';
5
+ Pagy.version = '3.13.0';
6
6
 
7
7
  Pagy.init = function(arg){
8
8
  var target = arg instanceof Event || arg === undefined ? document : arg,
@@ -0,0 +1,24 @@
1
+ # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ bs:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "stavka"
8
+ few: "stavke"
9
+ many: "stavki"
10
+ other: "stavki"
11
+
12
+ nav:
13
+ prev: "‹ Prethodna"
14
+ next: "Sljedeća  ›"
15
+ gap: "…"
16
+
17
+ info:
18
+ no_items: "Nije pronađena %{item_name}"
19
+ single_page: "Prikazuje se <b>%{count}</b> %{item_name}"
20
+ multiple_pages: "Prikaz %{item_name} <b>%{from}-%{to}</b> od <b>%{count}</b> ukupno"
21
+
22
+ combo_nav_js: "Stranica %{page_input} od %{pages}"
23
+
24
+ items_selector_js: "Prikaži %{items_input} %{item_name} po stranici"
@@ -0,0 +1,24 @@
1
+ # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ hr:
4
+ pagy:
5
+
6
+ item_name:
7
+ one: "stavka"
8
+ few: "stavke"
9
+ many: "stavki"
10
+ other: "stavki"
11
+
12
+ nav:
13
+ prev: "&lsaquo;&nbsp;Prethodna"
14
+ next: "Sljedeća &nbsp;&rsaquo;"
15
+ gap: "&hellip;"
16
+
17
+ info:
18
+ no_items: "Nije pronađena %{item_name}"
19
+ single_page: "Prikazuje se <b>%{count}</b> %{item_name}"
20
+ multiple_pages: "Prikaz %{item_name} <b>%{from}-%{to}</b> od <b>%{count}</b> ukupno"
21
+
22
+ combo_nav_js: "Stranica %{page_input} od %{pages}"
23
+
24
+ items_selector_js: "Prikaži %{items_input} %{item_name} po stranici"
@@ -0,0 +1,23 @@
1
+ # :east_slavic pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)
2
+
3
+ sr:
4
+ pagy:
5
+ item_name:
6
+ one: "ставка"
7
+ few: "ставкe"
8
+ many: "ставки"
9
+ other: "ставки"
10
+
11
+ nav:
12
+ prev: "&lsaquo;&nbsp;Претходна"
13
+ next: "Следећa &nbsp;&rsaquo;"
14
+ gap: "&hellip;"
15
+
16
+ info:
17
+ no_items: "Нema пронађених %{item_name}"
18
+ single_page: "Приказује се <b>%{count}</b> %{item_name}"
19
+ multiple_pages: "Приказ %{item_name} <b>%{from}-%{to}</b> од <b>%{count}</b> укупно"
20
+
21
+ combo_nav_js: "Страниca %{page_input} од %{pages}"
22
+
23
+ items_selector_js: "Прикажи %{items_input} %{item_name} по страниcи"
@@ -67,14 +67,17 @@ p11n = {
67
67
  # The default pluralization for locales not explicitly listed here
68
68
  # is the :one_other pluralization proc (used for English)
69
69
  plurals = Hash.new(p11n[:one_other]).tap do |hash|
70
+ hash['bs'] = p11n[:east_slavic]
70
71
  hash['cs'] = p11n[:west_slavic]
71
72
  hash['id'] = p11n[:other]
72
73
  hash['fr'] = p11n[:one_upto_two_other]
74
+ hash['hr'] = p11n[:east_slavic]
73
75
  hash['ja'] = p11n[:other]
74
76
  hash['km'] = p11n[:other]
75
77
  hash['ko'] = p11n[:other]
76
78
  hash['pl'] = p11n[:polish]
77
79
  hash['ru'] = p11n[:east_slavic]
80
+ hash['sr'] = p11n[:east_slavic]
78
81
  hash['sv'] = p11n[:one_two_other]
79
82
  hash['sv-SE'] = p11n[:one_two_other]
80
83
  hash['tr'] = p11n[:other]
data/lib/pagy.rb CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'pathname'
6
6
 
7
- class Pagy ; VERSION = '3.11.0'
7
+ class Pagy ; VERSION = '3.13.0'
8
8
 
9
9
  # Root pathname to get the path of Pagy files like templates or dictionaries
10
10
  def self.root; @root ||= Pathname.new(__FILE__).dirname.freeze end
@@ -32,18 +32,31 @@ class Pagy ; VERSION = '3.11.0'
32
32
  end
33
33
 
34
34
  # Return the array of page numbers and :gap items e.g. [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
35
- def series(size=@vars[:size])
36
- (series = []) and size.empty? and return series
37
- 4.times{|i| (size[i]>=0 rescue nil) or raise(VariableError.new(self), "expected 4 items >= 0 in :size; got #{size.inspect}")}
38
- [*0..size[0], *@page-size[1]..@page+size[2], *@last-size[3]+1..@last+1].sort!.each_cons(2) do |a, b|
39
- if a<0 || a==b || a>@last # skip out of range and duplicates
40
- elsif a+1 == b; series.push(a) # no gap -> no additions
41
- elsif a+2 == b; series.push(a, a+1) # 1 page gap -> fill with missing page
42
- else series.push(a, :gap) # n page gap -> add gap
43
- end # skip the end boundary (last+1)
44
- end # shift the start boundary (0) and
45
- series.shift; series[series.index(@page)] = @page.to_s; series # convert the current page to String
35
+ def series(size=@vars[:size])
36
+ return [] if size.empty?
37
+ raise VariableError.new(self), "expected 4 items >= 0 in :size; got #{size.inspect}" \
38
+ unless size.size == 4 && size.all?{ |num| num >= 0 rescue false }
39
+ # This algorithm (backported from pagy 4.3) is up to ~5x faster and ~2.3x lighter than the previous one
40
+ left_gap_start = 1 + size[0]
41
+ left_gap_end = @page - size[1] - 1
42
+ right_gap_start = @page + size[2] + 1
43
+ right_gap_end = @last - size[3]
44
+ left_gap_end = right_gap_end if left_gap_end > right_gap_end
45
+ right_gap_start = left_gap_start if left_gap_start > right_gap_start
46
+ series = []
47
+ start = 1
48
+ if (left_gap_end - left_gap_start) > 0
49
+ series.push(*start..(left_gap_start - 1), :gap)
50
+ start = left_gap_end + 1
46
51
  end
52
+ if (right_gap_end - right_gap_start) > 0
53
+ series.push(*start..(right_gap_start - 1), :gap)
54
+ start = right_gap_end + 1
55
+ end
56
+ series.push(*start..@last)
57
+ series[series.index(@page)] = @page.to_s
58
+ series
59
+ end
47
60
 
48
61
  end
49
62
 
@@ -8,7 +8,7 @@ class Pagy
8
8
  class Countless < Pagy
9
9
 
10
10
  # Merge and validate the options, do some simple arithmetic and set a few instance variables
11
- def initialize(vars={})
11
+ def initialize(vars={}) # rubocop:disable Lint/MissingSuper
12
12
  @vars = VARS.merge(vars.delete_if{|_,v| v.nil? || v == '' }) # default vars + cleaned vars (can be overridden)
13
13
  { items:1, outset:0, page:1 }.each do |k,min| # validate instance variables
14
14
  (@vars[k] && instance_variable_set(:"@#{k}", @vars[k].to_i) >= min) \
@@ -4,6 +4,7 @@ class Pagy
4
4
  attr_reader :pagy
5
5
 
6
6
  def initialize(pagy)
7
+ super
7
8
  @pagy = pagy
8
9
  end
9
10
 
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: 3.11.0
4
+ version: 3.13.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-02-14 00:00:00.000000000 Z
11
+ date: 2021-04-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,
@@ -22,8 +22,8 @@ files:
22
22
  - LICENSE.txt
23
23
  - lib/config/pagy.rb
24
24
  - lib/javascripts/pagy.js
25
- - lib/locales/README.md
26
25
  - lib/locales/bg.yml
26
+ - lib/locales/bs.yml
27
27
  - lib/locales/ca.yml
28
28
  - lib/locales/cs.yml
29
29
  - lib/locales/da.yml
@@ -31,6 +31,7 @@ files:
31
31
  - lib/locales/en.yml
32
32
  - lib/locales/es.yml
33
33
  - lib/locales/fr.yml
34
+ - lib/locales/hr.yml
34
35
  - lib/locales/id.yml
35
36
  - lib/locales/it.yml
36
37
  - lib/locales/ja.yml
@@ -42,6 +43,7 @@ files:
42
43
  - lib/locales/pt-BR.yml
43
44
  - lib/locales/pt.yml
44
45
  - lib/locales/ru.yml
46
+ - lib/locales/sr.yml
45
47
  - lib/locales/sv-SE.yml
46
48
  - lib/locales/sv.yml
47
49
  - lib/locales/sw.yml
@@ -93,7 +95,6 @@ files:
93
95
  - lib/templates/uikit_nav.html.erb
94
96
  - lib/templates/uikit_nav.html.haml
95
97
  - lib/templates/uikit_nav.html.slim
96
- - pagy.gemspec
97
98
  homepage: https://github.com/ddnexus/pagy
98
99
  licenses:
99
100
  - MIT
@@ -107,13 +108,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
108
  - - ">="
108
109
  - !ruby/object:Gem::Version
109
110
  version: '1.9'
111
+ - - "<"
112
+ - !ruby/object:Gem::Version
113
+ version: '3.0'
110
114
  required_rubygems_version: !ruby/object:Gem::Requirement
111
115
  requirements:
112
116
  - - ">="
113
117
  - !ruby/object:Gem::Version
114
118
  version: '0'
115
119
  requirements: []
116
- rubygems_version: 3.1.2
120
+ rubygems_version: 3.1.6
117
121
  signing_key:
118
122
  specification_version: 4
119
123
  summary: The Ultimate Pagination Ruby Gem
@@ -1,35 +0,0 @@
1
- # Pagy locales
2
-
3
- ### Please, submit your translation!
4
-
5
- If you find that some translation could be improved, please, create an issue.
6
-
7
- If you are using pagy with some language missing from the dictionary files, please, submit your translation!
8
-
9
- You can create a Pull Request for your language, and get all the help you need to correctly complete it. Here is a check list.
10
-
11
- ### Check list for a new dictionary file:
12
-
13
- - [ ] Find the pluralization rule for your language
14
-
15
- - [ ] Find the locale file you need in the [list of pluralizations](https://github.com/svenfuchs/rails-i18n/tree/master/rails/pluralization) and check the pluralization rule in it. For example it is `::RailsI18n::Pluralization::OneOther.with_locale(:en)` for `en.rb`. Note the rule part i.e. `OneOther`. In pagy that translates to the symbol `:one_other`.
16
-
17
- - [ ] If the pluralization rule of your language is not the `:one_other` default, confirm that the [p11n.rb](https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb) file already defines the pluralization rule of your dictionary file:
18
-
19
- - [ ] If the rule is not defined, you can either: a) Add the rule as a new rule/lambda entry in the `p11n` variable hash and relative tests or b) Just create an issue requesting the addition to the rule/lambda entry and tests.
20
-
21
- - [ ] Add your language to the `plurals` hash in the file.
22
-
23
- - [ ] add/edit the first line comment in the language rule in your dictionary file (e.g. `# :one_other pluralization ...`
24
-
25
- - [ ] The mandatory pluralized entry in the dictionary file is the `item_name`. Please, provide all the plurals needed by your language. E.g. if your language uses the `:east_slavic` you should provide the plurals for `one`, `few`, `many` and `other`, if it uses `:one_other`, you should provide `one` and `other` plurals. If it uses `:other` you should only provide a single value. Look into other dictionary files to get some example. Ask if in doubt.
26
-
27
- - [ ] The other entries in the dictionary file don't need any plural variant in most languages since the pluralization of the `item_name` in the sentence is enough. However, in some language, a whole sentence might need to be written in different ways for different counts. In that case you should add the different plurals for the sentence and the `count` will trigger the one that applies.
28
-
29
- Feel free to ask for help in your Pull Request.
30
-
31
- ### Useful Links
32
-
33
- * [Pagy I18n Documentation](https://ddnexus.github.io/pagy/api/frontend#i18n)
34
- * [I18n Extra](https://ddnexus.github.io/pagy/extras/i18n)
35
-
data/pagy.gemspec DELETED
@@ -1,16 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'pagy'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'pagy'
7
- s.version = Pagy::VERSION
8
- s.authors = ['Domizio Demichelis']
9
- s.email = ['dd.nexus@gmail.com']
10
- s.summary = 'The Ultimate Pagination Ruby Gem'
11
- s.description = 'Agnostic pagination in plain ruby: it works with any framework, ORM and DB type, with all kinds of collections, even pre-paginated, scopes, Arrays, JSON data... Easy, powerful, fast and light.'
12
- s.homepage = 'https://github.com/ddnexus/pagy'
13
- s.license = 'MIT'
14
- s.files = `git ls-files -z`.split("\x0").select{|f| f.start_with?('lib', 'pagy.gemspec', 'LICENSE') }
15
- s.required_ruby_version = '>= 1.9' # rubocop:disable Gemspec/RequiredRubyVersion
16
- end