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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +1 -0
- data/lib/page_up/pages.rb +6 -2
- data/lib/page_up/version.rb +1 -1
- data/spec/page_up/pages_spec.rb +7 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 553fdd8b2d92443f3358224b12fad52de5c6a3d2
|
4
|
+
data.tar.gz: fb43ddef6e79f50a51f5b8c663bc8c4622e47f2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dde98238736f5797f96e9581f83af8a22b74940e2f5f4a833c0de4bb078e146064acdfac2d13d1b6f57b82fc04bac3f02accb0e447271e5a93a1b5d6b7f0125
|
7
|
+
data.tar.gz: 55c243399d334a1f6378826561ba6f54b6630a7318a3a163faa35317ff8a1b5358a0ece94c3e479d074eb6999b433f793d7f7740efb71b8a42f1d9e0ab2daf2d
|
checksums.yaml.gz.sig
CHANGED
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
|
data/lib/page_up/pages.rb
CHANGED
@@ -9,7 +9,11 @@ module PageUp
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def pages
|
12
|
-
|
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
|
data/lib/page_up/version.rb
CHANGED
data/spec/page_up/pages_spec.rb
CHANGED
@@ -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.
|
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-
|
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
|