smart_paginate 0.1.3 → 0.2.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/.rubocop.yml +10 -0
- data/.travis.yml +10 -2
- data/Gemfile +1 -1
- data/README.md +9 -2
- data/gemfiles/Gemfile.active_record-4.0 +1 -1
- data/gemfiles/Gemfile.active_record-4.1 +1 -1
- data/gemfiles/Gemfile.active_record-4.2 +1 -1
- data/gemfiles/Gemfile.active_record-5.0 +1 -1
- data/gemfiles/Gemfile.active_record-5.1 +8 -0
- data/lib/smart_paginate/paginating_array.rb +7 -1
- data/lib/smart_paginate/version.rb +1 -1
- data/smart_paginate.gemspec +2 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a422b5d489696a05ecb9768faa46ce1c41dddb59
|
4
|
+
data.tar.gz: 72ad8d70ae51904655d60fc47214db306a7fbe0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b76ca341006eebad3269b729cc36e63bc2f50799de46283b88fe523542c25d1440486889598903d656d3556b8974e352333beb10841c54f5137e3b6a55a3f0ec
|
7
|
+
data.tar.gz: 72f471156d9a0073ef4c67b794772d356a56e39ace097881d83479d852985badb079795adca0fa856a7122338d0d26fc27eb8b7289dfa00a13c3205a6649f11c
|
data/.rubocop.yml
CHANGED
@@ -6,6 +6,10 @@ AllCops:
|
|
6
6
|
- 'gemfiles/vendor/**/*'
|
7
7
|
- 'lib/smart_paginate/version.rb'
|
8
8
|
|
9
|
+
Metrics/BlockLength:
|
10
|
+
Exclude:
|
11
|
+
- 'spec/**/*.rb'
|
12
|
+
|
9
13
|
Metrics/LineLength:
|
10
14
|
Enabled: false
|
11
15
|
|
@@ -13,6 +17,9 @@ Style/BlockComments:
|
|
13
17
|
Exclude:
|
14
18
|
- 'spec/**/*.rb'
|
15
19
|
|
20
|
+
Style/ConditionalAssignment:
|
21
|
+
Enabled: false
|
22
|
+
|
16
23
|
Style/Documentation:
|
17
24
|
Enabled: false
|
18
25
|
|
@@ -27,3 +34,6 @@ Style/RedundantSelf:
|
|
27
34
|
|
28
35
|
Style/StringLiterals:
|
29
36
|
Enabled: false
|
37
|
+
|
38
|
+
Style/SymbolArray:
|
39
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -2,10 +2,18 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
- 2.2.
|
6
|
-
- 2.3.
|
5
|
+
- 2.2.7
|
6
|
+
- 2.3.4
|
7
|
+
- 2.4.1
|
7
8
|
gemfile:
|
8
9
|
- gemfiles/Gemfile.active_record-4.0
|
9
10
|
- gemfiles/Gemfile.active_record-4.1
|
10
11
|
- gemfiles/Gemfile.active_record-4.2
|
11
12
|
- gemfiles/Gemfile.active_record-5.0
|
13
|
+
- gemfiles/Gemfile.active_record-5.1
|
14
|
+
matrix:
|
15
|
+
exclude:
|
16
|
+
- rvm: 2.4.1
|
17
|
+
gemfile: gemfiles/Gemfile.active_record-4.0
|
18
|
+
- rvm: 2.4.1
|
19
|
+
gemfile: gemfiles/Gemfile.active_record-4.1
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# SmartPaginate
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/smart_paginate)
|
3
4
|
[](https://travis-ci.org/ppostma/smart_paginate)
|
5
|
+
[](https://codeclimate.com/github/ppostma/smart_paginate)
|
4
6
|
|
5
7
|
Simple, smart and clean pagination extension for Active Record and plain Ruby Arrays:
|
6
8
|
|
@@ -74,8 +76,6 @@ module PaginateHelper
|
|
74
76
|
def paginate(collection, options = {})
|
75
77
|
content_tag(:div, class: "pagination") do
|
76
78
|
if collection.present?
|
77
|
-
options = options.merge(params)
|
78
|
-
|
79
79
|
concat link_to("Previous", url_for(options.merge(per_page: collection.per_page, page: collection.previous_page)), class: "previous_page") if collection.previous_page?
|
80
80
|
concat link_to("Next", url_for(options.merge(per_page: collection.per_page, page: collection.next_page)), class: "next_page") if collection.next_page?
|
81
81
|
end
|
@@ -84,6 +84,13 @@ module PaginateHelper
|
|
84
84
|
end
|
85
85
|
```
|
86
86
|
|
87
|
+
Which you can then use in the view like this:
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
<%= paginate(@objects, params.permit) %>
|
91
|
+
```
|
92
|
+
|
93
|
+
Make sure you whitelist the allowed parameters!
|
87
94
|
|
88
95
|
## Contributing
|
89
96
|
|
@@ -7,7 +7,13 @@ module SmartPaginate
|
|
7
7
|
def paginate(options = {})
|
8
8
|
page = SmartPaginate::Paginate.new(options.fetch(:page), options[:per_page])
|
9
9
|
|
10
|
-
|
10
|
+
if page.offset <= length
|
11
|
+
array = self.slice(page.offset, page.per_page)
|
12
|
+
else
|
13
|
+
# out of bounds, just create an empty array
|
14
|
+
array = PaginatingArray.new
|
15
|
+
end
|
16
|
+
|
11
17
|
array.current_page = page.current_page
|
12
18
|
array.per_page = page.per_page
|
13
19
|
array.total_entries = length
|
data/smart_paginate.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'smart_paginate/version'
|
@@ -24,5 +25,5 @@ Gem::Specification.new do |spec|
|
|
24
25
|
spec.add_development_dependency "rspec", "~> 3.4.0", ">= 3.4.0"
|
25
26
|
spec.add_development_dependency "sqlite3", "~> 1.3", ">= 1.3.11"
|
26
27
|
|
27
|
-
spec.add_dependency "activerecord", ">= 4.0.0", "< 5.
|
28
|
+
spec.add_dependency "activerecord", ">= 4.0.0", "< 5.2"
|
28
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_paginate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Postma
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: 4.0.0
|
88
88
|
- - "<"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '5.
|
90
|
+
version: '5.2'
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -97,7 +97,7 @@ dependencies:
|
|
97
97
|
version: 4.0.0
|
98
98
|
- - "<"
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version: '5.
|
100
|
+
version: '5.2'
|
101
101
|
description: Simple, smart and clean pagination extension for Active Record and plain
|
102
102
|
Ruby Arrays.
|
103
103
|
email:
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- gemfiles/Gemfile.active_record-4.1
|
119
119
|
- gemfiles/Gemfile.active_record-4.2
|
120
120
|
- gemfiles/Gemfile.active_record-5.0
|
121
|
+
- gemfiles/Gemfile.active_record-5.1
|
121
122
|
- lib/smart_paginate.rb
|
122
123
|
- lib/smart_paginate/active_record_extension.rb
|
123
124
|
- lib/smart_paginate/paginate.rb
|
@@ -144,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
145
|
version: '0'
|
145
146
|
requirements: []
|
146
147
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.
|
148
|
+
rubygems_version: 2.5.2
|
148
149
|
signing_key:
|
149
150
|
specification_version: 4
|
150
151
|
summary: Simple, smart and clean pagination extension
|