pagy 3.5.1 → 3.6.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: 5d5bc9d035a9a4d9f5f807a6e95cdad150a705ab17df7fc964ea3103614a7a7d
4
- data.tar.gz: 6cee7bf4ccb841d55b1d38619f4cac613f765f8040fbe2162e2cf1ec99e84655
3
+ metadata.gz: d1414283eb3f96c82e975d0436ebf6dee87cdc037d91c152ed13dd97a3a2cc58
4
+ data.tar.gz: 907bc851219c314bbdfe95a373b77c562de51c81495ada5686d6c57b61be826c
5
5
  SHA512:
6
- metadata.gz: 883c2262141419d5f1e1270ef6a443bfce351c54fa1a893a477dc8dfd00ab0af1b75c7f8670e26a1a73a406723006a1ac23667a2ba9b652390eab5b46e5964d9
7
- data.tar.gz: cdb1bd1461caf095f22407eab5de315d306dbdfb1f2cc2a733f811c92f5fdef475f1995264317e32ec8d775a019e46757b801426b8f4f7c160ff4eb9bbad799e
6
+ metadata.gz: 9a3c417007ffa03a904714ac4d807adc215645e5518429a14490a3430426374a9bac45d55882e5a0c4e3969bdd258c5a78dad2c04f7ed6f775c9d8aa43abc798
7
+ data.tar.gz: 653e0bbd6b8b8c0b71b16f9983d3c7e5d2c14b33b176a5100a2cd7e63aaca41c565dbae0589bafcc2ee6c9e5b56939047a40668b2615e4db6f53fbeaf3cbc9d0
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
- # Pagy initializer file (3.5.1)
4
+ # Pagy initializer file (3.6.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.5.1';
5
+ Pagy.version = '3.6.0';
6
6
 
7
7
  Pagy.init = function(arg){
8
8
  var target = arg instanceof Event || arg === undefined ? document : arg,
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'pathname'
6
6
 
7
- class Pagy ; VERSION = '3.5.1'
7
+ class Pagy ; VERSION = '3.6.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
@@ -0,0 +1,31 @@
1
+ # See the Pagy documentation: https://ddnexus.github.io/pagy/extras/arel
2
+ # encoding: utf-8
3
+ # frozen_string_literal: true
4
+
5
+ class Pagy
6
+ module Backend ; private
7
+
8
+ def pagy_arel(collection, vars={})
9
+ pagy = Pagy.new(pagy_arel_get_vars(collection, vars))
10
+ return pagy, pagy_get_items(collection, pagy)
11
+ end
12
+
13
+ def pagy_arel_get_vars(collection, vars)
14
+ vars[:count] ||= pagy_arel_count(collection)
15
+ vars[:page] ||= params[ vars[:page_param] || VARS[:page_param] ]
16
+ vars
17
+ end
18
+
19
+ def pagy_arel_count(collection)
20
+ if collection.group_values.empty?
21
+ # COUNT(*)
22
+ collection.count(:all)
23
+ else
24
+ # COUNT(*) OVER ()
25
+ sql = Arel.star.count.over(Arel::Nodes::Grouping.new([]))
26
+ collection.unscope(:order).limit(1).pluck(sql).first
27
+ end
28
+ end
29
+
30
+ end
31
+ 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: 3.5.1
4
+ version: 3.6.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: 2019-08-31 00:00:00.000000000 Z
11
+ date: 2019-10-06 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,
@@ -49,6 +49,7 @@ files:
49
49
  - lib/pagy/backend.rb
50
50
  - lib/pagy/countless.rb
51
51
  - lib/pagy/exceptions.rb
52
+ - lib/pagy/extras/arel.rb
52
53
  - lib/pagy/extras/array.rb
53
54
  - lib/pagy/extras/bootstrap.rb
54
55
  - lib/pagy/extras/bulma.rb
@@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  - !ruby/object:Gem::Version
106
107
  version: '0'
107
108
  requirements: []
108
- rubygems_version: 3.0.3
109
+ rubygems_version: 3.0.6
109
110
  signing_key:
110
111
  specification_version: 4
111
112
  summary: The Ultimate Pagination Ruby Gem