smart_paginate 0.1.3 → 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
  SHA1:
3
- metadata.gz: 9243f8c82e00d6a698b211f5faf99b157a2043d1
4
- data.tar.gz: 86f6b75eecbe883132662b2a166b73a618e51e2e
3
+ metadata.gz: a422b5d489696a05ecb9768faa46ce1c41dddb59
4
+ data.tar.gz: 72ad8d70ae51904655d60fc47214db306a7fbe0a
5
5
  SHA512:
6
- metadata.gz: f5835bb0bd176338657b610a09629498024f0d54c5e21ab7812d26c661960466cd3a5af8ece7ea6e7da37d5aba32a97f8332a5891fe1eedba8c66d8d37fdd5b2
7
- data.tar.gz: dcf6088fd14c62731730bf5420b0581ab7869202f84bb99a7a79c0deda8d2c7319f604e662d87f0a6cde862dc47dc93b849405a72310b5e9878633e12971b780
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.5
6
- - 2.3.1
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
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in smart_paginate.gemspec
4
4
  gemspec
5
5
 
6
- gem 'rubocop', '~> 0.43.0', group: :test
6
+ gem 'rubocop', '~> 0.48.1', group: :test
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # SmartPaginate
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/smart_paginate.svg)](https://badge.fury.io/rb/smart_paginate)
3
4
  [![Build Status](https://travis-ci.org/ppostma/smart_paginate.svg?branch=master)](https://travis-ci.org/ppostma/smart_paginate)
5
+ [![Code Climate](https://codeclimate.com/github/ppostma/smart_paginate/badges/gpa.svg)](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
 
@@ -5,4 +5,4 @@ gemspec path: '..'
5
5
 
6
6
  gem 'activerecord', '~> 4.0.0'
7
7
 
8
- gem 'rubocop', '~> 0.43.0', group: :test
8
+ gem 'rubocop', '~> 0.48.1', group: :test
@@ -5,4 +5,4 @@ gemspec path: '..'
5
5
 
6
6
  gem 'activerecord', '~> 4.1.0'
7
7
 
8
- gem 'rubocop', '~> 0.43.0', group: :test
8
+ gem 'rubocop', '~> 0.48.1', group: :test
@@ -5,4 +5,4 @@ gemspec path: '..'
5
5
 
6
6
  gem 'activerecord', '~> 4.2.0'
7
7
 
8
- gem 'rubocop', '~> 0.43.0', group: :test
8
+ gem 'rubocop', '~> 0.48.1', group: :test
@@ -5,4 +5,4 @@ gemspec path: '..'
5
5
 
6
6
  gem 'activerecord', '~> 5.0.0'
7
7
 
8
- gem 'rubocop', '~> 0.43.0', group: :test
8
+ gem 'rubocop', '~> 0.48.1', group: :test
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in smart_paginate.gemspec
4
+ gemspec path: '..'
5
+
6
+ gem 'activerecord', '~> 5.1.0'
7
+
8
+ gem 'rubocop', '~> 0.48.1', group: :test
@@ -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
- array = self.slice(page.offset, page.per_page)
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
@@ -1,3 +1,3 @@
1
1
  module SmartPaginate
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0".freeze
3
3
  end
@@ -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.1"
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.1.3
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: 2016-10-06 00:00:00.000000000 Z
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.1'
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.1'
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.4.8
148
+ rubygems_version: 2.5.2
148
149
  signing_key:
149
150
  specification_version: 4
150
151
  summary: Simple, smart and clean pagination extension