paged_groups 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -5
- data/lib/paged_groups/builder.rb +3 -1
- data/lib/paged_groups/version.rb +1 -1
- data/spec/paged_groups/builder_spec.rb +7 -7
- data/spec/paged_groups/paged_groups_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eda61f9a3bdd341677d3af689ecb14815ec276f83bfe771a7da256d8ac22a97
|
4
|
+
data.tar.gz: 6cd7fe9d4ac34e185bf52fdd1b5fdd4ca752585900f2bfa7b11241122e2e80b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f39ca31c34c31ae6afc77772749c385e99a9660c04f3052736b64367b69424dc7e89d58dfc24c888c1bbc8a776bd4deab3249aaf5eb7869eaa9b41fe4440a75
|
7
|
+
data.tar.gz: 3401fa08caffcac8e17b555436e1275b1a982a1484104ed8c7608666c813890f826d197e77110eb83c94bde84cf7b3a8f3686ac5483a13aa2e7d3dd2721d04df
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 2.0.0 (January 29th, 2019)
|
2
|
+
|
3
|
+
* Breaking Change: Builder#add signature changed from groups splat operator to two-dimensional array. Splat operator introduces an under-the-hood copy and can impact performance with large argument lists.
|
4
|
+
|
1
5
|
# 1.0.0 (January 26th, 2019)
|
2
6
|
|
3
7
|
Initial Release
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -62,10 +62,10 @@ data = [
|
|
62
62
|
Let's use max page size of three for this example. In the real-world a max page size of three is most likely too small but it fits our example data set above for illustration purpose; you should be able to extrapolate this out with larger sets and larger max page sizes. To page this set we would execute:
|
63
63
|
|
64
64
|
````ruby
|
65
|
-
pages = PagedGroups.builder(page_size: 3).add(
|
65
|
+
pages = PagedGroups.builder(page_size: 3).add(data).all
|
66
66
|
````
|
67
67
|
|
68
|
-
*Note:*
|
68
|
+
*Note:* Add accepts a two-dimensional array with the first dimension being the group and the second dimension being the record.
|
69
69
|
|
70
70
|
our ````pages```` variable should now contain a two-dimensional array where dimension one is page and dimension two is record and would be:
|
71
71
|
|
@@ -103,7 +103,7 @@ There may be merit in placing *separator* record in between groups in the same p
|
|
103
103
|
|
104
104
|
````ruby
|
105
105
|
pages = PagedGroups.builder(page_size: 3, space: true, spacer: { id: nil, name: '' })
|
106
|
-
.add(
|
106
|
+
.add(data)
|
107
107
|
.all
|
108
108
|
````
|
109
109
|
|
@@ -152,8 +152,8 @@ other_data = [
|
|
152
152
|
]
|
153
153
|
]
|
154
154
|
pages = PagedGroups.builder(page_size: 3, space: true, spacer: { id: nil, name: '' })
|
155
|
-
.add(
|
156
|
-
.add(
|
155
|
+
.add(data)
|
156
|
+
.add(other_data, force: true)
|
157
157
|
.all
|
158
158
|
````
|
159
159
|
|
data/lib/paged_groups/builder.rb
CHANGED
@@ -26,7 +26,9 @@ module PagedGroups
|
|
26
26
|
clear
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
# Groups should be a two-dimensional array with the first dimension being the group and
|
30
|
+
# the second dimension being the record.
|
31
|
+
def add(groups, force: false)
|
30
32
|
dirty!
|
31
33
|
|
32
34
|
groups.each { |group| insert(Array(group), force: force) }
|
data/lib/paged_groups/version.rb
CHANGED
@@ -28,28 +28,28 @@ describe ::PagedGroups::Builder do
|
|
28
28
|
|
29
29
|
describe '#add and #all' do
|
30
30
|
it 'should page groups' do
|
31
|
-
page_builder.add(hundred_rows)
|
31
|
+
page_builder.add([hundred_rows])
|
32
32
|
|
33
33
|
expect(page_builder.all.length).to eq(1)
|
34
34
|
|
35
|
-
page_builder.add(twenty_rows)
|
36
|
-
page_builder.add(twenty_rows)
|
35
|
+
page_builder.add([twenty_rows])
|
36
|
+
page_builder.add([twenty_rows])
|
37
37
|
|
38
38
|
expect(page_builder.all.length).to eq(2)
|
39
39
|
|
40
|
-
page_builder.add(twenty_rows)
|
40
|
+
page_builder.add([twenty_rows])
|
41
41
|
|
42
42
|
expect(page_builder.all.length).to eq(3)
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should force add and space' do
|
46
|
-
page_builder.add(hundred_rows)
|
46
|
+
page_builder.add([hundred_rows])
|
47
47
|
|
48
48
|
expect(page_builder.all.length).to eq(1)
|
49
49
|
expect(page_builder.all.first.length).to eq(100)
|
50
50
|
|
51
|
-
page_builder.add(twenty_rows, force: true)
|
52
|
-
page_builder.add(twenty_rows, force: true)
|
51
|
+
page_builder.add([twenty_rows], force: true)
|
52
|
+
page_builder.add([twenty_rows], force: true)
|
53
53
|
|
54
54
|
expect(page_builder.all.length).to eq(1)
|
55
55
|
expect(page_builder.all.first.length).to eq(100 + 20 * 2 + 2)
|
@@ -46,7 +46,7 @@ describe ::PagedGroups do
|
|
46
46
|
let(:spacer) { { id: nil, name: '' } }
|
47
47
|
|
48
48
|
specify 'Standard use-case example works as advertised' do
|
49
|
-
pages = PagedGroups.builder(page_size: page_size).add(
|
49
|
+
pages = PagedGroups.builder(page_size: page_size).add(data).all
|
50
50
|
|
51
51
|
expected_pages = [
|
52
52
|
[
|
@@ -77,7 +77,7 @@ describe ::PagedGroups do
|
|
77
77
|
|
78
78
|
specify 'Spacing customization example works as advertised' do
|
79
79
|
pages = PagedGroups.builder(page_size: page_size, space: true, spacer: spacer)
|
80
|
-
.add(
|
80
|
+
.add(data)
|
81
81
|
.all
|
82
82
|
|
83
83
|
expected_pages = [
|
@@ -118,8 +118,8 @@ describe ::PagedGroups do
|
|
118
118
|
]
|
119
119
|
|
120
120
|
pages = PagedGroups.builder(page_size: page_size, space: true, spacer: spacer)
|
121
|
-
.add(
|
122
|
-
.add(
|
121
|
+
.add(data)
|
122
|
+
.add(other_data, force: true)
|
123
123
|
.all
|
124
124
|
|
125
125
|
expected_pages = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paged_groups
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard-rspec
|