page_up 0.0.2 → 0.0.3

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: f7345295fb84db01754653b39976ffaee5765a95
4
- data.tar.gz: f783bdec5654e1c50d0825d1dfe69e7460ef7e4b
3
+ metadata.gz: 553fdd8b2d92443f3358224b12fad52de5c6a3d2
4
+ data.tar.gz: fb43ddef6e79f50a51f5b8c663bc8c4622e47f2f
5
5
  SHA512:
6
- metadata.gz: a07d4689de5c566761b81fd6b4131b7df3a9a4becf56403e7459f40176a84c35706beb5179e3c9688ba6bbacc78e8e2cdc6ce77def280f95896bbd7c452be02e
7
- data.tar.gz: 473bf60755ba27ec468ce343e3f798725f89146a862139947fe347348f8661c5448d1749809d9a04c734202a61d541d2a8f9f0fc571ea3a1bb3793cfd55e4314
6
+ metadata.gz: 0dde98238736f5797f96e9581f83af8a22b74940e2f5f4a833c0de4bb078e146064acdfac2d13d1b6f57b82fc04bac3f02accb0e447271e5a93a1b5d6b7f0125
7
+ data.tar.gz: 55c243399d334a1f6378826561ba6f54b6630a7318a3a163faa35317ff8a1b5358a0ece94c3e479d074eb6999b433f793d7f7740efb71b8a42f1d9e0ab2daf2d
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # PageUp
2
+ [![Build Status](https://secure.travis-ci.org/JonRowe/page_up.png)](http://travis-ci.org/JonRowe/page_up) [![Code Climate](https://codeclimate.com/github/JonRowe/page_up.png)](https://codeclimate.com/github/JonRowe/page_up)
2
3
 
3
4
  PageUp is a simple pagination gem, the idea being to use composition and
4
5
  decoration of objects (rather than mixing into ActiveRecord) to divy up a
@@ -9,7 +9,11 @@ module PageUp
9
9
  end
10
10
 
11
11
  def pages
12
- (@origin.size.to_f / per_page).ceil
12
+ if @origin.size > 0
13
+ (@origin.size.to_f / per_page).ceil
14
+ else
15
+ 1
16
+ end
13
17
  end
14
18
 
15
19
  def current_slice
@@ -44,7 +48,7 @@ module PageUp
44
48
  end
45
49
 
46
50
  def slice_end
47
- if page + 2 > pages
51
+ if page + 2 > pages || pages < 5
48
52
  pages
49
53
  elsif page - 2 <= 0
50
54
  5
@@ -1,3 +1,3 @@
1
1
  module PageUp
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -26,7 +26,14 @@ describe "pagination" do
26
26
  expect(PageUp[collection,1,5].pages).to eq 3
27
27
  end
28
28
 
29
+ it 'handles no pages as 1 empty page' do
30
+ expect(PageUp[[],1,5].pages).to eq 1
31
+ end
32
+
33
+
29
34
  describe 'picking the current slice' do
35
+ specify { expect(PageUp[[],1,1].current_slice).to eq 1..1 }
36
+ specify { expect(PageUp[[1,2,3],1,1].current_slice).to eq 1..3 }
30
37
  specify { expect(PageUp[collection,1,1].current_slice).to eq 1..5 }
31
38
  specify { expect(PageUp[collection,2,1].current_slice).to eq 1..5 }
32
39
  specify { expect(PageUp[collection,3,1].current_slice).to eq 1..5 }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Rowe
@@ -29,7 +29,7 @@ cert_chain:
29
29
  2feWfO4gCNmvfFjULOAYHq9JHEjN5SLSXvj5HdSnDcCyIfJKn5Ya3JahWQaWIsXf
30
30
  /NPE/mB57TOwj+d7XUa2NC4HUadF8R51IYEcIB0PpIEzJlKtfXFcOZxO
31
31
  -----END CERTIFICATE-----
32
- date: 2013-07-05 00:00:00.000000000 Z
32
+ date: 2013-07-22 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rake
metadata.gz.sig CHANGED
Binary file