page_up 0.0.3 → 0.0.4
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/lib/page_up/pages.rb +33 -28
- data/lib/page_up/version.rb +1 -1
- data/page_up.gemspec +1 -1
- data/spec/page_up/pages_spec.rb +3 -0
- data.tar.gz.sig +0 -0
- metadata +5 -5
- 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: a4cad306d616a594283a2dfe39bde5bd33dd6164
|
4
|
+
data.tar.gz: 33c6ac47219e9a53c08fc81e8a8f9fe0c14f641d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26ea5deee66abb0a8061674fbae44f9b571efa699069653b6e7c47922e65987f3019b34f4df10bf0e76f19e938167792a57c664f7b7c2bcad28741609ce6c1a4
|
7
|
+
data.tar.gz: 9edb21ae0a03cacdb9cd9773a6e32ab39ec5c512f2213280f450571f286eefff42d6f9786472803fe34aa485965adc27127541836085be1441775426e9e1ad3d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/page_up/pages.rb
CHANGED
@@ -8,6 +8,10 @@ module PageUp
|
|
8
8
|
super collection[page_range]
|
9
9
|
end
|
10
10
|
|
11
|
+
def total_size
|
12
|
+
@origin.size
|
13
|
+
end
|
14
|
+
|
11
15
|
def pages
|
12
16
|
if @origin.size > 0
|
13
17
|
(@origin.size.to_f / per_page).ceil
|
@@ -22,40 +26,41 @@ module PageUp
|
|
22
26
|
|
23
27
|
attr_reader :page, :per_page
|
24
28
|
|
25
|
-
|
26
|
-
def page_range
|
27
|
-
current_page...current_page+per_page
|
28
|
-
end
|
29
|
+
private
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
def page_range
|
32
|
+
current_page...current_page+per_page
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
default
|
38
|
-
end
|
35
|
+
def current_page
|
36
|
+
(page-1)*per_page
|
37
|
+
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
def parse value, default
|
40
|
+
Integer(value)
|
41
|
+
rescue TypeError
|
42
|
+
default
|
43
|
+
end
|
44
|
+
|
45
|
+
def slice_start
|
46
|
+
if page - 2 <= 0
|
47
|
+
1
|
48
|
+
elsif page + 2 > pages
|
49
|
+
pages - 4
|
50
|
+
else
|
51
|
+
page - 2
|
48
52
|
end
|
53
|
+
end
|
49
54
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
55
|
+
def slice_end
|
56
|
+
if page + 2 > pages || pages < 5
|
57
|
+
pages
|
58
|
+
elsif page - 2 <= 0
|
59
|
+
5
|
60
|
+
else
|
61
|
+
page + 2
|
58
62
|
end
|
63
|
+
end
|
59
64
|
|
60
65
|
end
|
61
66
|
end
|
data/lib/page_up/version.rb
CHANGED
data/page_up.gemspec
CHANGED
data/spec/page_up/pages_spec.rb
CHANGED
@@ -30,6 +30,9 @@ describe "pagination" do
|
|
30
30
|
expect(PageUp[[],1,5].pages).to eq 1
|
31
31
|
end
|
32
32
|
|
33
|
+
it 'exposes original size' do
|
34
|
+
expect(PageUp[(1..100).to_a,1,5].total_size).to eq 100
|
35
|
+
end
|
33
36
|
|
34
37
|
describe 'picking the current slice' do
|
35
38
|
specify { expect(PageUp[[],1,1].current_slice).to eq 1..1 }
|
data.tar.gz.sig
CHANGED
Binary file
|
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.4
|
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-
|
32
|
+
date: 2013-10-31 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rake
|
@@ -65,14 +65,14 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.14.0
|
68
|
+
version: 2.14.0
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.14.0
|
75
|
+
version: 2.14.0
|
76
76
|
description: Simple paginator
|
77
77
|
email:
|
78
78
|
- hello@jonrowe.co.uk
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.1.3
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Simple paginator
|
metadata.gz.sig
CHANGED
Binary file
|