page_up 0.0.5 → 0.0.6
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/lib/page_up/fragment.rb +5 -2
- data/lib/page_up/version.rb +1 -1
- data/spec/page_up/fragment_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: 25cee297252e1890fee9581a045870bd1078a21c
|
4
|
+
data.tar.gz: 040ff9c75bf0bca6dcc7056d8d22fc2b8cf8c119
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5d94c283e9d892987380ea389536675ac6088ce27ffb2dd5ef4af218d1e155779d96a5d138b6dedc1543abb8690c7cba16acd508c621d3b945f0b5aec694ea4
|
7
|
+
data.tar.gz: 0564ede6189738f140d0538029a98edc028a28f78ac00b8da618139ae554cdafffd1a4ec30287ac0fc298d4bdcaf9e1013a3ee021cbf5bc2d37d8146f46f017b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/page_up/fragment.rb
CHANGED
@@ -2,10 +2,13 @@ module PageUp
|
|
2
2
|
class Fragment
|
3
3
|
NullResult = 'NullResult'
|
4
4
|
|
5
|
-
def initialize fragment, page, per_page
|
6
|
-
@page
|
5
|
+
def initialize fragment, page, per_page, total = nil
|
6
|
+
@page = page
|
7
|
+
@per_page = per_page
|
8
|
+
@size = total || (fragment.size + offset)
|
7
9
|
@fragment = [].fill(NullResult, 0, offset) + fragment
|
8
10
|
end
|
11
|
+
attr_reader :size
|
9
12
|
|
10
13
|
def [] range
|
11
14
|
until covers? range
|
data/lib/page_up/version.rb
CHANGED
@@ -5,6 +5,13 @@ describe 'fragmented pages' do
|
|
5
5
|
let(:fragment) { (21..40 ).to_a }
|
6
6
|
let(:pages) { PageUp::Fragment.new fragment, 2, 20 }
|
7
7
|
|
8
|
+
it 'guesses the size based on fragment and page number' do
|
9
|
+
expect(pages.size).to eq 40
|
10
|
+
end
|
11
|
+
it 'can be configured to take a size' do
|
12
|
+
expect(PageUp::Fragment.new([], 2, 20, 60).size).to eq 60
|
13
|
+
end
|
14
|
+
|
8
15
|
context 'when the range requested is within the fragment' do
|
9
16
|
it 'returns the local results' do
|
10
17
|
expect(pages[20...40]).to eq fragment
|
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.6
|
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-11-
|
32
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rake
|
metadata.gz.sig
CHANGED
Binary file
|