page_up 0.0.7 → 0.0.8
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 +2 -2
- data/.travis.yml +2 -4
- data/Gemfile +4 -0
- data/lib/page_up.rb +2 -2
- data/lib/page_up/pages.rb +5 -4
- data/lib/page_up/version.rb +1 -1
- data/spec/page_up/pages_spec.rb +8 -3
- metadata +23 -23
- 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: 20c7439062000ee660ffbb29a6397979c0d91eb6
|
4
|
+
data.tar.gz: 3e4cf5c800a2d1829a347fb12efa7ae53f8d8799
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e88399fce698a9795283c3aebf6adab1d3decc1b3ecde3852ba6530238c8bb914ef20b501cda85d2531b4faf260eff302c9ef62ecc5b1dc355555ccd3b25db66
|
7
|
+
data.tar.gz: 44558756fc80fa5f15e60d7776402823328b526dc1e01a57715ef09bc676df0309553bbb00a5d899f91e6201b00e6c3434ee51ec96f9ee5f7b6a8a68695edd7a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
�QIt{6\� � ��`�Ң"Z�Ϯ��f�i�2�<`���^y8*�=�m~�������Yha_3g��Ka�C�SPK$ZZF%cY��l�ݵ`�=ө���
|
2
|
+
�;�T��-�Q�Sḛf+B�t&��l�v�x;�@D�.��I��� t\y���eԆ2�eqbT�����:i��|�*�2�N�ҳ9kv��C��A}f[=E/��
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/lib/page_up.rb
CHANGED
@@ -3,8 +3,8 @@ require 'page_up/fragment'
|
|
3
3
|
|
4
4
|
module PageUp
|
5
5
|
|
6
|
-
def self.[] collection, page = nil, per_page = nil
|
7
|
-
PageUp::Pages.new(collection, page, per_page)
|
6
|
+
def self.[] collection, page = nil, per_page = nil, opts = {}
|
7
|
+
PageUp::Pages.new(collection, page, per_page, opts)
|
8
8
|
end
|
9
9
|
|
10
10
|
end
|
data/lib/page_up/pages.rb
CHANGED
@@ -2,20 +2,21 @@ require 'delegate'
|
|
2
2
|
module PageUp
|
3
3
|
class Pages < SimpleDelegator
|
4
4
|
|
5
|
-
def initialize collection, page, per_page
|
5
|
+
def initialize collection, page, per_page, opts = {}
|
6
6
|
@page = parse page, 1
|
7
7
|
@per_page = parse per_page, 25
|
8
8
|
@origin = collection
|
9
|
+
@opts = opts
|
9
10
|
super collection[page_range]
|
10
11
|
end
|
11
12
|
|
12
13
|
def total_size
|
13
|
-
@origin.size
|
14
|
+
@opts.fetch(:total_size) { @origin.size }
|
14
15
|
end
|
15
16
|
|
16
17
|
def pages
|
17
|
-
if
|
18
|
-
(
|
18
|
+
if total_size > 0
|
19
|
+
(total_size.to_f / per_page).ceil
|
19
20
|
else
|
20
21
|
1
|
21
22
|
end
|
data/lib/page_up/version.rb
CHANGED
data/spec/page_up/pages_spec.rb
CHANGED
@@ -16,9 +16,10 @@ describe "pagination" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'paginates collections above page count' do
|
19
|
-
expect(PageUp[collection,1,
|
20
|
-
expect(PageUp[collection,2,
|
21
|
-
expect(PageUp[collection,3,
|
19
|
+
expect(PageUp[collection,1,3]).to eq [1, 2, 3]
|
20
|
+
expect(PageUp[collection,2,3]).to eq [4, 5, 6]
|
21
|
+
expect(PageUp[collection,3,3]).to eq [7, 8, 9]
|
22
|
+
expect(PageUp[collection,4,3]).to eq [10, 11, 12]
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'counts pages' do
|
@@ -33,6 +34,10 @@ describe "pagination" do
|
|
33
34
|
expect(PageUp[(1..100).to_a,1,5].total_size).to eq 100
|
34
35
|
end
|
35
36
|
|
37
|
+
it 'allows override of total size' do
|
38
|
+
expect(PageUp[(1..10).to_a,1,5, total_size: 100].total_size).to eq 100
|
39
|
+
end
|
40
|
+
|
36
41
|
describe 'picking the current slice' do
|
37
42
|
specify { expect(PageUp[[],1,1].current_slice).to eq 1..1 }
|
38
43
|
specify { expect(PageUp[[1,2,3],1,1].current_slice).to eq 1..3 }
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Rowe
|
@@ -10,10 +10,10 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDVjCCAj6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBRMQ4wDAYDVQQDDAVoZWxs
|
14
14
|
bzEXMBUGCgmSJomT8ixkARkWB2pvbnJvd2UxEjAQBgoJkiaJk/IsZAEZFgJjbzES
|
15
|
-
|
16
|
-
|
15
|
+
MBAGCgmSJomT8ixkARkWAnVrMB4XDTE0MDIwNjEwMjcxN1oXDTE1MDIwNjEwMjcx
|
16
|
+
N1owUTEOMAwGA1UEAwwFaGVsbG8xFzAVBgoJkiaJk/IsZAEZFgdqb25yb3dlMRIw
|
17
17
|
EAYKCZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJ1azCCASIwDQYJKoZI
|
18
18
|
hvcNAQEBBQADggEPADCCAQoCggEBAMhs6ng/SRrYfG7RtQx8liJTZs8tpz7PBnlH
|
19
19
|
qyOwuU0weJc7nh6C9C8LGyJzpkbjJJo1rfTMg7huDyL14Py82dfMDomApif8jNNI
|
@@ -21,56 +21,56 @@ cert_chain:
|
|
21
21
|
FK+c4PUV3/zBKghe0l7FuDhyQCsuLNDbWyFvDS97tPjeN6yWuszwg22vZMDdsuzN
|
22
22
|
Cj3M4LLSkbrt+AOUcysEJxI4t6uv2U1bRzHsDfAF0RI/Q7OMtUr+Dtz/2YJ47KKs
|
23
23
|
51ZRjLLGHd10XrIfFSfGyJj1dMbDgLsEBj1sFH4e6dy7gau8TaUCAwEAAaM5MDcw
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
/
|
24
|
+
CwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQu7kkfaDtECOhdpm359ut80Mj0iTAJBgNV
|
25
|
+
HRMEAjAAMA0GCSqGSIb3DQEBBQUAA4IBAQBV37l2vQhQNyZZD99dFVNhlif1klZM
|
26
|
+
kt2XEtsgos5iSSLoPgPjVWtIXukwPfFqNyKLgMXYo++UE2RK3oqpQ5oOPw+nIl88
|
27
|
+
Choh3RQAYpipItGVLkZIV4kAj/eXwrzN/7XjZs8v8FxuPl1d1K0wi6gwQYzDZcUv
|
28
|
+
ZWMLj0l0fNwqsVIpG9851WaYDXxc2g8IYHwi+/Egq3P3rhgndt+sLI9hNG8xq+/W
|
29
|
+
QJyajKbJL+NTmHrfNqMqa3U8JTGyLsV3j+8hnb0uFpBndPIWxd4/swopQHMdMcsb
|
30
|
+
bnHreBY9jQe/A4TMZVk36eIoTmlL8ZvmfFjdai1hXwvXuIoX1GzjLQUq
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rake
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
type: :development
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: bundler
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.3'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.3'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: rspec
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
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
75
|
version: 2.14.0
|
76
76
|
description: Simple paginator
|
@@ -80,8 +80,8 @@ executables: []
|
|
80
80
|
extensions: []
|
81
81
|
extra_rdoc_files: []
|
82
82
|
files:
|
83
|
-
- .gitignore
|
84
|
-
- .travis.yml
|
83
|
+
- ".gitignore"
|
84
|
+
- ".travis.yml"
|
85
85
|
- Gemfile
|
86
86
|
- LICENSE.txt
|
87
87
|
- README.md
|
@@ -103,17 +103,17 @@ require_paths:
|
|
103
103
|
- lib
|
104
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: 1.9.2
|
109
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
|
-
- -
|
111
|
+
- - ">="
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
115
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
116
|
+
rubygems_version: 2.2.2
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: Simple paginator
|
metadata.gz.sig
CHANGED
Binary file
|