airspace 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68fd92350f1c6274af7a30a46918f1b9037ba9d1b0e63b1a88c284a4715f432d
4
- data.tar.gz: 8b89696d66ec946c6ee807f86cacd4cdf370057b74f9a06b6cdae1bfbfa2448b
3
+ metadata.gz: 81e321a98d086d49ec21f49d48ce9f8b724a70ccd0b9ea6e3df106736b549b0c
4
+ data.tar.gz: d33b59a0dda864fe42d8a52ab64b1983ea4b1bade39826acdfe2957ed11bf7db
5
5
  SHA512:
6
- metadata.gz: 7603141412de37754499c6b148ba58c3c80ce4434d9b58f7d8d4a6e4d36de07827810cff6317281f4ab90af180d3464bf377202c4755ec62c4e330855f702fa3
7
- data.tar.gz: d0c7cb11e532003bf867fddddc36759bdadd0fd583430b4a1cdbb12e2c2da510c4263fceb824546b1ed33e37cb6a2f9bb74c626616e9f1864c479f09c4279ace
6
+ metadata.gz: d96e783bd3dc5d828d763c123d1a8bb2abafe7c92fd0651567a0f4c47bc61b0a3026630e093322209af1e19be8e5cc7d7b008dc417e46d49d553566c7fcc114d
7
+ data.tar.gz: f0f7bca65485dc3f7550ef554c6660fafc672f311782026291389ffdaafab3be5ec119b47b37f2930d71a9d37ba8a33dfedfa36aec77146c7a9237f583a5adb7
@@ -1,3 +1,10 @@
1
+ # 1.0.1 (February 22, 2019)
2
+
3
+ **Critical Bug Fix**
4
+
5
+ * Ensure Reader#page and Reader#pages work when there is a page_count of 0
6
+ * Ensure Reader#page works when number is out of bounds (out of bounds is defined as: ```number <= 0``` or ```number > page_count``` )
7
+
1
8
  # 1.0.0 (February 21, 2019)
2
9
 
3
10
  Initial Release.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- airspace (1.0.0)
4
+ airspace (1.0.1)
5
5
  redis (>= 3.3.0)
6
6
 
7
7
  GEM
@@ -66,12 +66,16 @@ module Airspace
66
66
  end
67
67
 
68
68
  def pages
69
+ return [] unless page_count.positive?
70
+
69
71
  store.chunks(key, chunk_count).map do |chunk|
70
72
  chunk.map { |r| serializer.deserialize_row(r) }
71
73
  end
72
74
  end
73
75
 
74
76
  def page(number)
77
+ return [] unless within_bounds?(number)
78
+
75
79
  page_index = number - 1
76
80
  location = chunker.locate(page_index)
77
81
  chunk = store.chunk(key, location.chunk_index)
@@ -85,6 +89,10 @@ module Airspace
85
89
 
86
90
  private
87
91
 
92
+ def within_bounds?(number)
93
+ page_count.positive? && number.positive? && number <= page_count
94
+ end
95
+
88
96
  def store
89
97
  ::Airspace::Store.new(client)
90
98
  end
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Airspace
11
- VERSION = '1.0.0'
11
+ VERSION = '1.0.1'
12
12
  end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2019-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
10
+ require './spec/spec_helper'
11
+
12
+ describe ::Airspace::Reader do
13
+ let(:client) { Redis.new }
14
+
15
+ let(:id) { 'reader-test-set' }
16
+
17
+ let(:options) { { prefix: TEST_PREFIX } }
18
+
19
+ let(:reader) { ::Airspace.get(client, id, options: options) }
20
+
21
+ subject { reader }
22
+
23
+ context 'with no pages' do
24
+ before(:each) do
25
+ ::Airspace.set(client, id: id, options: options)
26
+ end
27
+
28
+ describe '#page' do
29
+ it 'should return empty array when page_count is 0' do
30
+ expect(subject.page(1)).to eq([])
31
+ end
32
+
33
+ it 'should return empty array when number <= 0' do
34
+ expect(subject.page(-1)).to eq([])
35
+ end
36
+ end
37
+
38
+ describe '#pages' do
39
+ it 'should return empty array when page_count is 0' do
40
+ expect(subject.pages).to eq([])
41
+ end
42
+ end
43
+ end
44
+
45
+ context 'with pages' do
46
+ let(:pages) do
47
+ [
48
+ [
49
+ { 'id' => 1, 'name' => 'Matt' }
50
+ ]
51
+ ]
52
+ end
53
+
54
+ before(:each) do
55
+ ::Airspace.set(client, id: id, options: options, pages: pages)
56
+ end
57
+
58
+ describe '#page' do
59
+ it 'should return array of rows when number <= page_count' do
60
+ expect(subject.page(1)).to eq(pages[0])
61
+ end
62
+
63
+ it 'should return empty array when number > page_count' do
64
+ expect(subject.page(2)).to eq([])
65
+ end
66
+
67
+ it 'should return empty array when number <= 0' do
68
+ expect(subject.page(-1)).to eq([])
69
+ end
70
+ end
71
+
72
+ describe '#page' do
73
+ it 'should return array of pages when page_count > 0' do
74
+ expect(subject.pages).to eq(pages)
75
+ end
76
+ end
77
+ end
78
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
@@ -158,6 +158,7 @@ files:
158
158
  - lib/airspace/version.rb
159
159
  - spec/airspace/airspace_spec.rb
160
160
  - spec/airspace/chunker_spec.rb
161
+ - spec/airspace/reader_spec.rb
161
162
  - spec/airspace/store_spec.rb
162
163
  - spec/spec_helper.rb
163
164
  homepage: https://github.com/bluemarblepayroll/airspace
@@ -186,5 +187,6 @@ summary: Redis Dataset Store
186
187
  test_files:
187
188
  - spec/airspace/airspace_spec.rb
188
189
  - spec/airspace/chunker_spec.rb
190
+ - spec/airspace/reader_spec.rb
189
191
  - spec/airspace/store_spec.rb
190
192
  - spec/spec_helper.rb