pagy 0.20.0 → 0.21.0

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: 575c195847961ea0480d52ab96a6a1cff02684261069c254979437596d443244
4
- data.tar.gz: 52a796fa7f8c7323a5445082f24d0ebbd77ee7931870af203836ee3fe686ab36
3
+ metadata.gz: 9bfbf0d56b4b48272f392235024917f193e34bbb503dda18ed5a22cbe26a3f31
4
+ data.tar.gz: b69e31bebaef1fa2898419c69a83b98f2b017039201336a79bc64921e13d9e62
5
5
  SHA512:
6
- metadata.gz: f907980d15f3056b660ee7acf17fa2f414ad2b1e2b0eca4538aa1c79103ffe052a7b0fa47a31e11258f68f3d74d0042768bb19683edec6e273832cea2c5bf733
7
- data.tar.gz: 444b734960e91e64fc1d115a71e50a2d729fd93f1c99da97cd6c8e364d0bfcae26bc1dd5f24b9d7c44e2aee0b19d21a0b39f3e18f7cc48554b0853f87ef9f3b1
6
+ metadata.gz: 05dbed50a79d4d124fa0c4c1220033744bfd592afeb2a0954b3f0ce6bbae364366b7dfc183dbb1756ddb49980439739d477b52112cd43561b7abd53a7111686f
7
+ data.tar.gz: dc3b2a46c2d240507ca371b03fe71ea202d10e96aaece4e29a1570cae885842376eff49cd24dd6809653e98915b392c1b3dc2368906c32c6802d517dc8229c6c
data/lib/config/pagy.rb CHANGED
@@ -12,7 +12,11 @@
12
12
  # See https://ddnexus.github.io/pagy/extras/array
13
13
  # require 'pagy/extras/array'
14
14
 
15
- # Searchkick: Paginate `Searchkick::Results` objects efficiently, avoiding expensive oject-wrapping and without overriding.
15
+ # Elasticsearch Rails: Paginate `ElasticsearchRails::Results` objects efficiently, avoiding expensive object-wrapping and without overriding.
16
+ # See https://ddnexus.github.io/pagy/extras/elasticsearch_rails
17
+ # require 'pagy/extras/elasticsearch_rails'
18
+
19
+ # Searchkick: Paginate `Searchkick::Results` objects efficiently, avoiding expensive object-wrapping and without overriding.
16
20
  # See https://ddnexus.github.io/pagy/extras/searchkick
17
21
  # require 'pagy/extras/searchkick'
18
22
 
@@ -25,8 +25,9 @@ plurals = {
25
25
  }
26
26
 
27
27
  # Languages (language/plural pairs)
28
- # Contain all the entries for all the languages defined in the pagy.yml dictionary
29
- # The default plural for missing languages is the :zero_one_other plural (used for English)
28
+ # Contain all the entries for all the languages defined in the dictionaries.
29
+ # The default plural for languages not explicitly listed here
30
+ # is the :zero_one_other plural (used for English)
30
31
  Hash.new(plurals[:zero_one_other]).tap do |languages|
31
32
  languages['en'] = plurals[:zero_one_other]
32
33
  languages['ru'] = plurals[:one_few_many_other]
data/lib/pagy.rb CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'pathname'
5
5
 
6
- class Pagy ; VERSION = '0.20.0'
6
+ class Pagy ; VERSION = '0.21.0'
7
7
 
8
8
  class OutOfRangeError < StandardError; attr_reader :pagy; def initialize(pagy) @pagy = pagy end; end
9
9
 
@@ -0,0 +1,18 @@
1
+ # See the Pagy documentation: https://ddnexus.github.io/pagy/extras/elasticsearch_rails
2
+
3
+ class Pagy
4
+ # Add specialized backend methods to paginate ElasticsearchRails::Results
5
+ module Backend ; private
6
+ # Return Pagy object and items
7
+ def pagy_elasticsearch_rails(results, vars={})
8
+ pagy = Pagy.new(pagy_elasticsearch_rails_get_vars(results, vars))
9
+ return pagy, results.offset(pagy.offset).limit(pagy.items)
10
+ end
11
+
12
+ def pagy_elasticsearch_rails_get_vars(results, vars)
13
+ # Return the merged variables to initialize the Pagy object
14
+ { count: results.total,
15
+ page: (params[:page] || 1)}.merge!(vars)
16
+ end
17
+ end
18
+ 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: 0.20.0
4
+ version: 0.21.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: 2018-10-02 00:00:00.000000000 Z
11
+ date: 2018-10-18 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,
@@ -37,6 +37,7 @@ files:
37
37
  - lib/pagy/extras/array.rb
38
38
  - lib/pagy/extras/bootstrap.rb
39
39
  - lib/pagy/extras/bulma.rb
40
+ - lib/pagy/extras/elasticsearch_rails.rb
40
41
  - lib/pagy/extras/foundation.rb
41
42
  - lib/pagy/extras/i18n.rb
42
43
  - lib/pagy/extras/items.rb