pagelux 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71e370b775e3f741c799079db211a151e684ed4b
4
- data.tar.gz: bc64214d693c26bbb172534a91af47ad75dd7b2f
3
+ metadata.gz: db493f43c8dd8b9d479aaf0afe5a224643889c5a
4
+ data.tar.gz: 3ef1f90aed47b5035d339b57df08c1970cabf904
5
5
  SHA512:
6
- metadata.gz: 8173fc58874fae1ac61bcde84bdbb8306208994aa1bf0bdcd0553925c79b5f41de2ef6fdbf66bd410689171fc01af056c0a3341ace02c0883b1a3bc606506de6
7
- data.tar.gz: 7721ba2cf925c31074241d3a1679e034ba70d88850f11a292d38e0d83dbc67226ac106cec9bf8cfba61a24724f72b835fcd1ba7b812c90e6c4fc18260b8c6728
6
+ metadata.gz: 5b30e0228b5d71c66e5684c136b3e7790462d0308559d3da36cefeaae6c85bfe3c55a391312203756f355ac23052f300bc325b27ab284d95855587fe75f49e25
7
+ data.tar.gz: 565d8cbe3e5cd9473dbb0ef9808729311fdbbb122f531e98b706ec7571ea57372aed169515af432f4cbe2f921e5caa0698754618d6151cf04336a3dc1732931d
@@ -9,10 +9,20 @@ module Pagelux
9
9
  end
10
10
 
11
11
  def paginate(params)
12
- @pagination_data = PaginationData.new(params[:page], params[:limit], base_query.count)
12
+ @pagination_data = PaginationData.new(
13
+ params[:page], params[:limit], total
14
+ )
13
15
  limit_query
14
16
  end
15
17
 
18
+ def total
19
+ query_total.is_a?(Hash) ? base_query.to_a.size : query_total
20
+ end
21
+
22
+ def query_total
23
+ @query_total ||= base_query.count
24
+ end
25
+
16
26
  def limit_query
17
27
  base_query.offset((page-1) * limit).limit(limit)
18
28
  end
@@ -1,3 +1,3 @@
1
1
  module Pagelux
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -9,7 +9,6 @@ describe Pagelux::QueryPaginator do
9
9
  Query.all
10
10
  }
11
11
  let(:paginator) { Pagelux::QueryPaginator.new(query) }
12
- # let(:results) { paginator.paginate(params) }
13
12
 
14
13
  describe 'normalizing pagination values' do
15
14
  let(:params) { {} }
@@ -95,4 +94,22 @@ describe Pagelux::QueryPaginator do
95
94
  end
96
95
  end
97
96
  end
97
+
98
+ context 'when query count results in grouped set' do
99
+ let(:page) { 1 }
100
+
101
+ let(:query) {
102
+ (1..13).to_a.each do |n|
103
+ Query.create!(n: n)
104
+ end
105
+
106
+ Query.all.select('n').group(:n)
107
+ }
108
+
109
+ let(:results) { paginator.paginate({page: page, limit: 5}).map(&:n) }
110
+
111
+ it "still return the right number (and does not blow up)" do
112
+ results.size.should == 5
113
+ end
114
+ end
98
115
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagelux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rae Bonfanti
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-12-21 00:00:00.000000000 Z
14
+ date: 2014-02-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activerecord