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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb8ac318e3df020ef112bcfd9a44fef6883519682be6501de014e745148b4046
4
- data.tar.gz: 7d69dea71a15bf728052cdfe80341e24b2ac32b0bc93bf5ab3f3b0891bd66b4f
3
+ metadata.gz: 1eda61f9a3bdd341677d3af689ecb14815ec276f83bfe771a7da256d8ac22a97
4
+ data.tar.gz: 6cd7fe9d4ac34e185bf52fdd1b5fdd4ca752585900f2bfa7b11241122e2e80b6
5
5
  SHA512:
6
- metadata.gz: f60342818d52bce7432752e19d852f47a8cb28ca2a9d5216b39175e1ba47e9f71b9f2a8bb970751cc59a162c3d6af140dce2e95bfed5fcea53605b1b2b0e0c09
7
- data.tar.gz: 86a0b7432ee2cefb13aad7b9e9d13ca1e2d35f60e93ebc58b798a2700816810be09c5b5580f26c10a6144664483aea9877108f1dea44983a20de647dc1c05c95
6
+ metadata.gz: 8f39ca31c34c31ae6afc77772749c385e99a9660c04f3052736b64367b69424dc7e89d58dfc24c888c1bbc8a776bd4deab3249aaf5eb7869eaa9b41fe4440a75
7
+ data.tar.gz: 3401fa08caffcac8e17b555436e1275b1a982a1484104ed8c7608666c813890f826d197e77110eb83c94bde84cf7b3a8f3686ac5483a13aa2e7d3dd2721d04df
@@ -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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paged_groups (1.0.0)
4
+ paged_groups (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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(*data).all
65
+ pages = PagedGroups.builder(page_size: 3).add(data).all
66
66
  ````
67
67
 
68
- *Note:* We are using the splat (asterisk) operator to indicate each group is an argument.
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(*data)
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(*data)
156
- .add(*other_data, force: true)
155
+ .add(data)
156
+ .add(other_data, force: true)
157
157
  .all
158
158
  ````
159
159
 
@@ -26,7 +26,9 @@ module PagedGroups
26
26
  clear
27
27
  end
28
28
 
29
- def add(*groups, force: false)
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) }
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module PagedGroups
11
- VERSION = '1.0.0'
11
+ VERSION = '2.0.0'
12
12
  end
@@ -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(*data).all
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(*data)
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(*data)
122
- .add(*other_data, force: true)
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: 1.0.0
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-27 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard-rspec