pagy-extras 0.1.2 → 0.2.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: 92a12e4d92cdb183028f474da6cdc2e0468a2957a217f41d79fe24e8070126ce
4
- data.tar.gz: a67240b6affeed1565773b7dfb403a8da43b159f1678b2aa9b7b014eadceb3bb
3
+ metadata.gz: fa656cb77955cd1b8611091aaf7bf5767e54dd1a633da8d0075a875c12dfbe92
4
+ data.tar.gz: 0caa1e1b0b77b91aa16f8df85a17931a8ae735a9624d51e732c62d8b897b7c37
5
5
  SHA512:
6
- metadata.gz: 1b06fb2e67cdb66f5c6baf234f03b131caa169e3411f2245edad0a54ac62855844a24db1da95bfbea6a6034023cd6f0356499eb411b2e900f72b849c4244fe49
7
- data.tar.gz: d3cccfbbb924e54d859e1a367896ad7d0999797fa78fa911e438509e973ac03f446318caf99bcfe032b18ed7b314249a9f2af4df1658b1a6407fac3523a619e9
6
+ metadata.gz: d8ae5f7c4d335e25cdd148f19c42a976d3e67d2eca800d8b578191e919af5b1db9e9f976587172ba5f9638dc7fec4261bfaccbc3c6cfa88ff9cc8a05b9b0940c
7
+ data.tar.gz: 581f8bfdf48c7cececb12dbd44a6b31b007698424e654a1bab75fc23f04d65ef9ff6fbee9e539cfe2bc66af8aea1f4502765abcff44ce9f39824ef286aa26c6c
data/lib/pagy-extras.rb CHANGED
@@ -9,4 +9,4 @@ end
9
9
  require 'pagy-extras/bootstrap'
10
10
  require 'pagy-extras/compact'
11
11
  require 'pagy-extras/responsive'
12
-
12
+ require 'pagy-extras/array'
@@ -0,0 +1,20 @@
1
+ # See the Pagy Extras documentation: https://ddnexus.github.io/pagy/pagy-extras
2
+
3
+ class Pagy
4
+ # Add specialized backend methods to paginate array collections
5
+ module Backend ; private
6
+
7
+ # return pagy object and items
8
+ def pagy_array(array, vars=nil)
9
+ pagy = Pagy.new(vars ? pagy_array_get_vars(array).merge!(vars) : pagy_array_get_vars(array)) # conditional merge is faster and saves memory
10
+ return pagy, array[pagy.offset, pagy.items]
11
+ end
12
+
13
+ # sub-method called only by #pagy_array: here for easy customization of variables by overriding
14
+ def pagy_array_get_vars(array)
15
+ # return the variables to initialize the pagy object
16
+ { count: array.count, page: params[:page] }
17
+ end
18
+
19
+ end
20
+ end
@@ -1,6 +1,7 @@
1
1
  # See the Pagy Extras documentation: https://ddnexus.github.io/pagy/pagy-extras
2
2
 
3
3
  class Pagy
4
+ # Add nav helper for bootstrap pagination
4
5
  module Frontend
5
6
 
6
7
  # Pagination for bootstrap: it returns the html with the series of links to the pages
@@ -1,7 +1,7 @@
1
1
  # See the Pagy Extras documentation: https://ddnexus.github.io/pagy/pagy-extras
2
2
 
3
3
  class Pagy
4
-
4
+ # Add nav helpers for compact pagination
5
5
  module Frontend
6
6
 
7
7
  # Generic compact pagination: it returns the html with the series of links to the pages
@@ -4,6 +4,7 @@ require 'json'
4
4
 
5
5
  class Pagy
6
6
 
7
+ # default :breakpoints
7
8
  VARS[:breakpoints] = { 0 => [1,4,4,1] }
8
9
 
9
10
  # Helper for building the page_nav with javascript. For example:
@@ -26,7 +27,7 @@ class Pagy
26
27
  end
27
28
  end
28
29
 
29
-
30
+ # Add nav helpers for responsive pagination
30
31
  module Frontend
31
32
 
32
33
  # Generic responsive pagination: it returns the html with the series of links to the pages
data/pagy-extras.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'date'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'pagy-extras'
8
- s.version = '0.1.2'
8
+ s.version = '0.2.0'
9
9
  s.authors = ['Domizio Demichelis']
10
10
  s.email = ['dd.nexus@gmail.com']
11
11
  s.date = Date.today.to_s
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = `git ls-files -z`.split("\x0").select{|f| f.start_with?('lib', 'pagy-extras.gemspec', 'LICENSE') }
20
20
 
21
21
 
22
- s.add_dependency 'pagy', '~> 0.6.0'
22
+ s.add_dependency 'pagy', '~> 0.6'
23
23
 
24
24
  s.add_development_dependency 'bundler', '~> 1.16'
25
25
  s.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagy-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.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-05-21 00:00:00.000000000 Z
11
+ date: 2018-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pagy
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.0
19
+ version: '0.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.6.0
26
+ version: '0.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -63,6 +63,7 @@ files:
63
63
  - lib/javascripts/pagy-compact.js
64
64
  - lib/javascripts/pagy-responsive.js
65
65
  - lib/pagy-extras.rb
66
+ - lib/pagy-extras/array.rb
66
67
  - lib/pagy-extras/bootstrap.rb
67
68
  - lib/pagy-extras/compact.rb
68
69
  - lib/pagy-extras/responsive.rb