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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc4dafe82f5d801b24a6471c6c852e24dce7b7b8
4
- data.tar.gz: ef4e91f8807d28faf5370381b69eb0b9df4ffe98
3
+ metadata.gz: 25cee297252e1890fee9581a045870bd1078a21c
4
+ data.tar.gz: 040ff9c75bf0bca6dcc7056d8d22fc2b8cf8c119
5
5
  SHA512:
6
- metadata.gz: b82269e408155eae4e5ece5e69215f450d716998bdb7c9cbc1936fa3ec0e74d852f1407387bc75c207af577b830c292289480c0404fbc7459298dae47cdb7838
7
- data.tar.gz: ff17bb46b8a1359fa2daa6f45ebc0e1fb3cd1faf4caa9fcaff49973ea6289968d518309f5adf35c60e94b544694acb8f48fdc04454dbffc5541df08583fe556a
6
+ metadata.gz: d5d94c283e9d892987380ea389536675ac6088ce27ffb2dd5ef4af218d1e155779d96a5d138b6dedc1543abb8690c7cba16acd508c621d3b945f0b5aec694ea4
7
+ data.tar.gz: 0564ede6189738f140d0538029a98edc028a28f78ac00b8da618139ae554cdafffd1a4ec30287ac0fc298d4bdcaf9e1013a3ee021cbf5bc2d37d8146f46f017b
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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, @per_page = page, per_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
@@ -1,3 +1,3 @@
1
1
  module PageUp
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -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.5
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-05 00:00:00.000000000 Z
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