pagy 3.5.1 → 3.6.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 +4 -4
- data/lib/config/pagy.rb +1 -1
- data/lib/javascripts/pagy.js +1 -1
- data/lib/pagy.rb +1 -1
- data/lib/pagy/extras/arel.rb +31 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1414283eb3f96c82e975d0436ebf6dee87cdc037d91c152ed13dd97a3a2cc58
|
4
|
+
data.tar.gz: 907bc851219c314bbdfe95a373b77c562de51c81495ada5686d6c57b61be826c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a3c417007ffa03a904714ac4d807adc215645e5518429a14490a3430426374a9bac45d55882e5a0c4e3969bdd258c5a78dad2c04f7ed6f775c9d8aa43abc798
|
7
|
+
data.tar.gz: 653e0bbd6b8b8c0b71b16f9983d3c7e5d2c14b33b176a5100a2cd7e63aaca41c565dbae0589bafcc2ee6c9e5b56939047a40668b2615e4db6f53fbeaf3cbc9d0
|
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.
|
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
|
|
data/lib/javascripts/pagy.js
CHANGED
data/lib/pagy.rb
CHANGED
@@ -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.
|
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-
|
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.
|
109
|
+
rubygems_version: 3.0.6
|
109
110
|
signing_key:
|
110
111
|
specification_version: 4
|
111
112
|
summary: The Ultimate Pagination Ruby Gem
|