folio-pagination 0.0.11 → 0.0.12

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: 9aec00730bd1236fe759cc576bf5e29eae27ff64
4
- data.tar.gz: 4d626f686033e152725a4baaf69186260b377ce7
3
+ metadata.gz: 1a0d73a4c15184fbb37db68d3bb6c6ae6558a852
4
+ data.tar.gz: d7e6bfda606da39dbacda3c54f5df7d617525df9
5
5
  SHA512:
6
- metadata.gz: 2e37ead5e804b5e9ad40fafe7b2676f57b3ea8bb8736ea962b3d7c1a0c8466383bc10b9d8bdf84981bb12bf49e1c1488c5dbb4e75571dee37f8e4dd92dbf4336
7
- data.tar.gz: 91c2dce2d25f1e590b913be8f534739f63f43f88fdf7c87dc171bcca369fedf097456ee30bd94595eae4364afcacbaf0775875da3d28f4019dc5b136132b19e7
6
+ metadata.gz: f3a9e950c8f51452dd1a77a722ee93509558a2e6d7fc587f45ae8f067f1816bb5865f76f2b82774917d91ad1f04b9a76a00cf3140b917dbb699645605d699e34
7
+ data.tar.gz: 1f41f9b7fac962d8b61912269ee5d4b9b84d4cab5f25b20b1bac0a4126903669b8f12a434debe28f1ad3d9360faefe4f1bd61096bf93e1b95a8147f9af33b020
data/Gemfile CHANGED
@@ -7,10 +7,10 @@ group :development do
7
7
  end
8
8
 
9
9
  group :will_paginate do
10
- gem 'rails', '>= 3.0', '< 4.1'
10
+ gem 'rails', '>= 3.0', '< 5.1'
11
11
  # this isn't in the gemspec because folio/rails.rb loads only part of
12
12
  # will_paginate, and only if folio/rails.rb is required. see the README.
13
- gem 'will_paginate', '~> 3.0.7'
13
+ gem 'will_paginate', '~> 3.0'
14
14
  end
15
15
 
16
16
  group :test do
@@ -31,6 +31,10 @@ module Folio
31
31
  # page identifier addressing the first page within the folio.
32
32
  attr_accessor :first_page
33
33
 
34
+ def initialize
35
+ @last_page = nil
36
+ end
37
+
34
38
  # page identifier addressing the final page within the folio, if
35
39
  # known.
36
40
  def last_page=(value)
@@ -7,7 +7,7 @@ module Folio
7
7
  def per_page(*args)
8
8
  raise ArgumentError if args.size > 1
9
9
  @per_page = (args.first && args.first.to_i) if args.size > 0
10
- @per_page ? @per_page : default_per_page
10
+ instance_variable_defined?(:@per_page) ? @per_page || default_per_page : default_per_page
11
11
  end
12
12
 
13
13
  alias_method :per_page=, :per_page
@@ -1,3 +1,3 @@
1
1
  module Folio
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -130,8 +130,13 @@ module Folio
130
130
  # total_entries left to an auto-count, but the relation being
131
131
  # paginated has a grouping. we need to do a special count, lest
132
132
  # self.count give us a hash instead of the integer we expect.
133
- if scope.having_values.empty? && group_values.length == 1 # multi-column distinct counts are broken right now (as of rails 4.2.5) :(
134
- options[:total_entries] = except(:group, :select).select(group_values).uniq.count
133
+ having_clause_empty = Rails.version < '5' ? scope.having_values.empty? : scope.having_clause.empty?
134
+ if having_clause_empty && group_values.length == 1 # multi-column distinct counts are broken right now (as of rails 4.2.5) :(
135
+ if Rails.version < '5'
136
+ options[:total_entries] = except(:group, :select).select(group_values).uniq.count
137
+ else
138
+ options[:total_entries] = except(:group, :select).select(group_values).distinct.count
139
+ end
135
140
  else
136
141
  options[:total_entries] = unscoped.from("(#{to_sql}) a").count
137
142
  end
@@ -68,6 +68,7 @@ describe Folio do
68
68
  end
69
69
 
70
70
  it "should populate current_page and per_page before passing it to fill_page" do
71
+ @klass.send(:remove_method, :fill_page)
71
72
  @klass.send(:define_method, :fill_page) do |page|
72
73
  page.current_page.wont_be_nil
73
74
  page.per_page.wont_be_nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: folio-pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Fugal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-22 00:00:00.000000000 Z
11
+ date: 2017-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 2.4.7
120
+ rubygems_version: 2.6.10
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Folio is a library for pagination. It's meant to be nearly compatible with
@@ -138,4 +138,3 @@ test_files:
138
138
  - test/folio/will_paginate/view_helpers_test.rb
139
139
  - test/folio_test.rb
140
140
  - test/setup/active_record.rb
141
- has_rdoc: