object_table 0.3.4 → 0.4.0
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 +4 -4
- data/.travis.yml +0 -1
- data/README.md +206 -108
- data/lib/object_table/basic_grid.rb +1 -1
- data/lib/object_table/column.rb +6 -7
- data/lib/object_table/factory.rb +46 -0
- data/lib/object_table/grouping/grid.rb +47 -0
- data/lib/object_table/grouping.rb +109 -0
- data/lib/object_table/joining.rb +71 -0
- data/lib/object_table/masked_column.rb +2 -2
- data/lib/object_table/printing.rb +69 -0
- data/lib/object_table/stacking.rb +66 -0
- data/lib/object_table/static_view.rb +2 -5
- data/lib/object_table/table_methods.rb +35 -22
- data/lib/object_table/util.rb +19 -0
- data/lib/object_table/version.rb +1 -1
- data/lib/object_table/view.rb +7 -5
- data/lib/object_table/view_methods.rb +3 -2
- data/lib/object_table.rb +8 -19
- data/object_table.gemspec +2 -0
- data/spec/object_table/column_spec.rb +2 -2
- data/spec/object_table/grouping_spec.rb +475 -0
- data/spec/object_table/static_view_spec.rb +2 -2
- data/spec/object_table/util_spec.rb +43 -0
- data/spec/object_table/view_spec.rb +6 -16
- data/spec/object_table_spec.rb +45 -3
- data/spec/subclassing_spec.rb +44 -5
- data/spec/support/joining_example.rb +171 -0
- data/spec/support/object_table_example.rb +124 -29
- data/spec/support/stacking_example.rb +111 -0
- data/spec/support/utils.rb +8 -0
- data/spec/support/view_example.rb +10 -13
- metadata +20 -12
- data/lib/object_table/group.rb +0 -10
- data/lib/object_table/grouped.rb +0 -93
- data/lib/object_table/printable.rb +0 -72
- data/lib/object_table/stacker.rb +0 -59
- data/lib/object_table/table_child.rb +0 -19
- data/spec/object_table/grouped_spec.rb +0 -351
- data/spec/support/stacker_example.rb +0 -158
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'object_table'
|
2
|
+
require_relative 'utils'
|
3
|
+
|
4
|
+
RSpec.shared_examples 'a join operation' do |all_left, all_right|
|
5
|
+
let(:total_groups) { 50 }
|
6
|
+
let(:groups) { 40 }
|
7
|
+
let(:lsize) { 10 }
|
8
|
+
let(:rsize) { 5 }
|
9
|
+
|
10
|
+
let(:key1) { (0...total_groups).map{|i| "key1_#{i}"} }
|
11
|
+
let(:key2) { (0...total_groups).map{|i| "key2_#{i}"} * 2 }
|
12
|
+
|
13
|
+
let(:__left__) do
|
14
|
+
ObjectTable.new(
|
15
|
+
key1: key1[0, groups] * lsize,
|
16
|
+
key2: key2[0, groups/2] * 2 * lsize,
|
17
|
+
lval1: NArray.object(groups * lsize).map!{rand},
|
18
|
+
lval2: NArray.object(10, groups * lsize).map!{rand},
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:__right__) do
|
23
|
+
ObjectTable.new(
|
24
|
+
key1: key1[-groups, groups] * rsize,
|
25
|
+
key2: key2[-groups, groups/2] * 2 * rsize,
|
26
|
+
rval1: NArray.object(groups * rsize).map!{rand},
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:left) { make_table(__left__, described_class) }
|
31
|
+
let(:right) { make_table(__right__, described_class) }
|
32
|
+
|
33
|
+
let(:common) { subject.where{lval1.ne(nil).and(rval1.ne(nil))}.clone }
|
34
|
+
let(:left_only) { subject.where{rval1.eq nil}.clone }
|
35
|
+
let(:right_only) { subject.where{lval1.eq nil}.clone }
|
36
|
+
|
37
|
+
let(:lkeys) { ObjectTable::Util.get_rows(left, [:key1, :key2]) }
|
38
|
+
let(:rkeys) { ObjectTable::Util.get_rows(right, [:key1, :key2]) }
|
39
|
+
|
40
|
+
let(:expected_left_only) do
|
41
|
+
mask = lkeys.map{|k| rkeys.include?(k) ? 0 : 1}
|
42
|
+
left.where{NArray.to_na(mask).to_type('byte')}
|
43
|
+
end
|
44
|
+
|
45
|
+
let(:expected_right_only) do
|
46
|
+
mask = rkeys.map{|k| lkeys.include?(k) ? 0 : 1}
|
47
|
+
right.where{NArray.to_na(mask).to_type('byte')}
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'shold have all columns' do
|
51
|
+
expect(subject.colnames).to eql [:key1, :key2, :lval1, :lval2, :rval1]
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should have the correct keys' do
|
55
|
+
join_keys = ObjectTable::Util.get_rows(subject, [:key1, :key2])
|
56
|
+
|
57
|
+
unless all_left
|
58
|
+
expect(join_keys & (lkeys - rkeys)).to be_empty
|
59
|
+
end
|
60
|
+
|
61
|
+
unless all_right
|
62
|
+
expect(join_keys & (rkeys - lkeys)).to be_empty
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should duplicate keys correctly' do
|
67
|
+
keys = lkeys & rkeys
|
68
|
+
counts = common.group_by(:key1, :key2).apply{ nrows }
|
69
|
+
expect(ObjectTable::Util.get_rows(counts, [:key1, :key2])).to match_array(keys)
|
70
|
+
expect(counts.v_0.to_a).to eq ([lsize * rsize] * keys.size)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should cross product the values' do
|
74
|
+
common.group_by(:key1, :key2).each do |grp|
|
75
|
+
filter = Proc.new{|t| t.key1.eq(grp.K.key1).and(t.key2.eq(grp.K.key2)) }
|
76
|
+
lgroup = left.where(&filter)
|
77
|
+
rgroup = right.where(&filter)
|
78
|
+
|
79
|
+
lvalues = lgroup.apply{[lval1.to_a, lval2.to_a]}.transpose
|
80
|
+
rvalues = rgroup.apply{[rval1.to_a]}.transpose
|
81
|
+
joined_values = grp.apply{[lval1, lval2, rval1]}.map(&:to_a).transpose
|
82
|
+
|
83
|
+
expected = lvalues.product(rvalues).map{|row| row.flatten(1)}
|
84
|
+
expect(joined_values).to eq expected
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'missing left keys' do
|
89
|
+
if all_right
|
90
|
+
it 'should have the right keys' do
|
91
|
+
keys = rkeys - lkeys
|
92
|
+
expect(right_only.key1.to_a).to eq keys.transpose[0]
|
93
|
+
expect(right_only.key2.to_a).to eq keys.transpose[1]
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should fill the right values with nil' do
|
97
|
+
expect(right_only.lval1.to_a).to eq [nil] * right_only.nrows
|
98
|
+
expect(right_only.lval2.to_a).to eq [[nil] * 10] * right_only.nrows
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should keep the right columns' do
|
102
|
+
right_only.pop_column(:lval1)
|
103
|
+
right_only.pop_column(:lval2)
|
104
|
+
expect(right_only).to eq expected_right_only
|
105
|
+
end
|
106
|
+
|
107
|
+
else
|
108
|
+
it 'should not have any' do
|
109
|
+
expect(right_only.nrows).to eq 0
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe 'with missing right keys' do
|
115
|
+
if all_left
|
116
|
+
it 'should have the left keys' do
|
117
|
+
keys = lkeys - rkeys
|
118
|
+
expect(left_only.key1.to_a).to eq keys.transpose[0]
|
119
|
+
expect(left_only.key2.to_a).to eq keys.transpose[1]
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should fill the right values with nil' do
|
123
|
+
expect(left_only.rval1.to_a).to eq [nil] * left_only.nrows
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should keep the left columns' do
|
127
|
+
left_only.pop_column(:rval1)
|
128
|
+
expect(left_only).to eq expected_left_only
|
129
|
+
end
|
130
|
+
|
131
|
+
else
|
132
|
+
it 'should not have any' do
|
133
|
+
expect(left_only.nrows).to eq 0
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
RSpec.shared_examples 'a table joiner' do
|
141
|
+
context 'inner join' do
|
142
|
+
let(:join_type) { 'inner' }
|
143
|
+
it_behaves_like 'a join operation', false, false
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'left join' do
|
147
|
+
let(:join_type) { 'left' }
|
148
|
+
it_behaves_like 'a join operation', true, false
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'right join' do
|
152
|
+
let(:join_type) { 'right' }
|
153
|
+
it_behaves_like 'a join operation', false, true
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'outer join' do
|
157
|
+
let(:join_type) { 'outer' }
|
158
|
+
it_behaves_like 'a join operation', true, true
|
159
|
+
end
|
160
|
+
|
161
|
+
context 'with invalid join' do
|
162
|
+
let(:left) { ObjectTable.new(key1: 1, key2: 2, value: 3) }
|
163
|
+
let(:right) { ObjectTable.new(key1: 1, key2: 2, value: 4) }
|
164
|
+
let(:join_type) { 'asklj' }
|
165
|
+
|
166
|
+
it 'should fail' do
|
167
|
+
expect{subject}.to raise_error
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
@@ -1,34 +1,11 @@
|
|
1
1
|
require 'object_table'
|
2
|
+
require_relative 'utils'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
@cls = cls
|
6
|
-
end
|
7
|
-
|
8
|
-
def _make_relevant_table(table)
|
9
|
-
if @cls == ObjectTable
|
10
|
-
table
|
11
|
-
|
12
|
-
# for views, basically add one row to the parent and mask the view
|
13
|
-
# so that it only includes the original rows
|
14
|
-
elsif @cls == ObjectTable::View
|
15
|
-
table.stack! ObjectTable::BasicGrid[table.columns.map{|k, v| [k, v.max]}]
|
16
|
-
column = table.colnames.first
|
17
|
-
table[column][-1] += 1
|
18
|
-
table.where{table[column] < table[column][-1]}
|
4
|
+
require 'support/joining_example'
|
5
|
+
require 'support/stacking_example'
|
19
6
|
|
20
|
-
|
21
|
-
|
22
|
-
column = table.colnames.first
|
23
|
-
table[column][-1] += 1
|
24
|
-
table.where{table[column] < table[column][-1]}.apply{ self }
|
25
|
-
|
26
|
-
else
|
27
|
-
nil
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
subject{ _make_relevant_table(table) }
|
7
|
+
RSpec.shared_examples 'an object table' do
|
8
|
+
subject{ make_table(table, described_class) }
|
32
9
|
|
33
10
|
describe '#inspect' do
|
34
11
|
let(:table){ ObjectTable.new(col1: 1..10, col2: 5) }
|
@@ -67,6 +44,36 @@ EOS
|
|
67
44
|
end
|
68
45
|
end
|
69
46
|
|
47
|
+
context 'with an odd number of rows' do
|
48
|
+
let(:table){ ObjectTable.new(col1: 1..5, col2: 5) }
|
49
|
+
|
50
|
+
it 'should include all the rows' do
|
51
|
+
table = subject.inspect.lines.to_a[1..-1].join + "\n"
|
52
|
+
expect(table).to eql <<EOS
|
53
|
+
col1 col2
|
54
|
+
0: 1 5
|
55
|
+
1: 2 5
|
56
|
+
2: 3 5
|
57
|
+
3: 4 5
|
58
|
+
4: 5 5
|
59
|
+
col1 col2
|
60
|
+
EOS
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'with one row' do
|
65
|
+
let(:table){ ObjectTable.new(col1: 1, col2: 5) }
|
66
|
+
|
67
|
+
it 'should include all the rows' do
|
68
|
+
table = subject.inspect.lines.to_a[1..-1].join + "\n"
|
69
|
+
expect(table).to eql <<EOS
|
70
|
+
col1 col2
|
71
|
+
0: 1 5
|
72
|
+
col1 col2
|
73
|
+
EOS
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
70
77
|
context 'with many rows' do
|
71
78
|
let(:table){ ObjectTable.new(col1: 1..100, col2: 5) }
|
72
79
|
|
@@ -354,7 +361,7 @@ EOS
|
|
354
361
|
let(:grouped){ subject.group_by &block }
|
355
362
|
|
356
363
|
it 'should return groups' do
|
357
|
-
expect(grouped).to be_a ObjectTable::
|
364
|
+
expect(grouped).to be_a ObjectTable::Grouping
|
358
365
|
expect(grouped.instance_eval('@grouper')).to eql block
|
359
366
|
end
|
360
367
|
end
|
@@ -406,4 +413,92 @@ EOS
|
|
406
413
|
end
|
407
414
|
end
|
408
415
|
|
416
|
+
describe '#each_row' do
|
417
|
+
let(:col1) { [1, 2, 3, 4] }
|
418
|
+
let(:col2) { [NArray[1, -1], NArray[2, -2], NArray[3, -3], NArray[4, -4]] }
|
419
|
+
let(:col3) { %w{ a b c d } }
|
420
|
+
|
421
|
+
let(:table) { ObjectTable.new(col1: col1, col2: col2, col3: col3) }
|
422
|
+
|
423
|
+
context 'with a block' do
|
424
|
+
it 'should yield successive rows' do
|
425
|
+
rows = []
|
426
|
+
subject.each_row{|row| rows.push row}
|
427
|
+
expect(rows.map(&:col1)).to eq col1
|
428
|
+
expect(rows.map(&:col2)).to eq col2
|
429
|
+
expect(rows.map(&:col3)).to eq col3
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
context 'without a block' do
|
434
|
+
it 'should return an enumerator' do
|
435
|
+
enum = subject.each_row
|
436
|
+
expect(enum).to be_a Enumerator
|
437
|
+
end
|
438
|
+
|
439
|
+
it 'should yield successive rows' do
|
440
|
+
rows = subject.each_row.to_a
|
441
|
+
expect(rows.map(&:col1)).to eq col1
|
442
|
+
expect(rows.map(&:col2)).to eq col2
|
443
|
+
expect(rows.map(&:col3)).to eq col3
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
context 'with specific columns' do
|
448
|
+
it 'should yield those columns' do
|
449
|
+
rows = subject.each_row(:col1, :col3).to_a.transpose
|
450
|
+
expect(rows).to eql [col1, col3]
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
context 'with an empty table' do
|
455
|
+
let(:table) { ObjectTable.new }
|
456
|
+
it 'should do nothing' do
|
457
|
+
expect(subject.each_row.to_a).to be_empty
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
context 'with a row factory' do
|
462
|
+
it 'should use the row factory' do
|
463
|
+
tmp_cls = Class.new(Struct)
|
464
|
+
subject.each_row(row_factory: tmp_cls) do |row|
|
465
|
+
expect(row).to be_a tmp_cls
|
466
|
+
end
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
end
|
471
|
+
|
472
|
+
describe '#stack' do
|
473
|
+
it_behaves_like 'a stacking operation' do
|
474
|
+
subject{ grids[0].stack *grids[1..-1] }
|
475
|
+
|
476
|
+
it 'should make a new table' do
|
477
|
+
expect(subject).to_not be grids[0]
|
478
|
+
end
|
479
|
+
|
480
|
+
it 'should duplicate the contents' do
|
481
|
+
grids.each do |chunk|
|
482
|
+
expect(subject).to_not be chunk
|
483
|
+
end
|
484
|
+
end
|
485
|
+
|
486
|
+
context 'with no arguments' do
|
487
|
+
let(:table){ ObjectTable.new(col1: 1..100, col2: 5) }
|
488
|
+
let(:grids){ [table] }
|
489
|
+
|
490
|
+
it 'should make a copy' do
|
491
|
+
expect(subject).to eql table
|
492
|
+
expect(subject).to_not be table
|
493
|
+
end
|
494
|
+
end
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
498
|
+
describe '#join' do
|
499
|
+
it_behaves_like 'a table joiner' do
|
500
|
+
subject{ left.join(right, :key1, :key2, type: join_type) }
|
501
|
+
end
|
502
|
+
end
|
503
|
+
|
409
504
|
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'object_table'
|
2
|
+
require_relative 'utils'
|
3
|
+
|
4
|
+
RSpec.shared_examples 'a stacking operation' do
|
5
|
+
|
6
|
+
let(:grids) do
|
7
|
+
[
|
8
|
+
ObjectTable.new(col1: [1, 2, 3], col2: 5),
|
9
|
+
ObjectTable.new(col1: 10, col2: 50),
|
10
|
+
ObjectTable.new(col2: [10, 30], col1: 15).where{col2.eq 10},
|
11
|
+
ObjectTable::BasicGrid[col2: [1, 2], col1: 3..4],
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
grids[0] = make_table(grids[0], described_class) unless grids.empty?
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:segment) { NArray.float(10, 10, 10).indgen }
|
20
|
+
|
21
|
+
let!(:grids_copy) { grids.map(&:clone) }
|
22
|
+
|
23
|
+
it 'should stack the tables and grids together' do
|
24
|
+
expect(subject).to be_a grids[0].__table_cls__
|
25
|
+
expect(subject).to eql grids[0].__table_cls__.new(
|
26
|
+
col1: grids_copy.flat_map{|x| x[:col1].to_a},
|
27
|
+
col2: grids_copy.flat_map{|x| x[:col2].to_a},
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with non grids/tables' do
|
32
|
+
let(:grids){ [ObjectTable.new(col1: 10, col2: 50), 'not a table'] }
|
33
|
+
|
34
|
+
it 'should fail' do
|
35
|
+
expect{subject}.to raise_error
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with extra column names' do
|
40
|
+
let(:grids){ [ObjectTable.new(col1: 10, col2: 50), ObjectTable.new(col1: 10, col2: 30, col3: 50)] }
|
41
|
+
|
42
|
+
it 'should fail' do
|
43
|
+
expect{subject}.to raise_error
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'with missing column names' do
|
48
|
+
let(:grids){ [ObjectTable.new(col1: 10, col2: 50), ObjectTable.new(col1: 10)] }
|
49
|
+
|
50
|
+
it 'should fail' do
|
51
|
+
expect{subject}.to raise_error
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'with empty tables' do
|
56
|
+
let(:grids) { [ ObjectTable.new(col1: [1, 2, 3], col2: 5), ObjectTable.new ] }
|
57
|
+
|
58
|
+
it 'should ignore empty tables' do
|
59
|
+
expect(subject).to eql grids[0]
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'with only empty tables' do
|
63
|
+
let(:grids) { [ObjectTable.new] * 3 }
|
64
|
+
|
65
|
+
it 'should return an empty table' do
|
66
|
+
expect(subject).to eql grids[0].__table_cls__.new
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'with tables with empty rows' do
|
72
|
+
let(:grids) { [ ObjectTable.new(col1: [1, 2, 3], col2: 5), ObjectTable.new(col1: [], col2: []) ] }
|
73
|
+
|
74
|
+
it 'should ignore empty tables' do
|
75
|
+
expect(subject).to eql grids_copy[0]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'with empty grids' do
|
80
|
+
let(:grids) { [ ObjectTable.new(col1: [1, 2, 3], col2: 5), ObjectTable::BasicGrid.new ] }
|
81
|
+
|
82
|
+
it 'should ignore empty grids' do
|
83
|
+
expect(subject).to eql grids_copy[0]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'with only narray segments' do
|
88
|
+
let(:grids) { [ObjectTable.new(col1: segment)] * 3 }
|
89
|
+
|
90
|
+
it 'should work' do
|
91
|
+
expect(subject.col1).to eql NArray.to_na(segment.to_a * 3)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'with a mixture of segment types' do
|
96
|
+
let(:grids) { [ObjectTable.new(col1: segment)] * 2 + [ObjectTable::BasicGrid[col1: segment.to_a]] * 3 }
|
97
|
+
|
98
|
+
it 'should work' do
|
99
|
+
expect(subject.col1).to eql NArray.to_na(segment.to_a * 5)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'with only array segments' do
|
104
|
+
let(:grids) { [ObjectTable.new(col1: segment.to_a)] * 3 }
|
105
|
+
|
106
|
+
it 'should work' do
|
107
|
+
expect(subject.col1).to eql NArray.to_na(segment.to_a * 3)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -1,24 +1,21 @@
|
|
1
1
|
require 'object_table'
|
2
2
|
|
3
|
-
RSpec.shared_examples 'a table view' do
|
4
|
-
before do
|
5
|
-
@cls = cls
|
6
|
-
end
|
3
|
+
RSpec.shared_examples 'a table view' do
|
7
4
|
|
8
|
-
def _make_relevant_view(table, block)
|
9
|
-
if
|
10
|
-
|
5
|
+
def _make_relevant_view(table, block, cls)
|
6
|
+
if cls == ObjectTable::View
|
7
|
+
cls.new(table, &block)
|
11
8
|
|
12
|
-
elsif
|
9
|
+
elsif cls == ObjectTable::StaticView
|
13
10
|
indices = table.apply(&block).where
|
14
|
-
|
11
|
+
cls.new(table, indices)
|
15
12
|
|
16
13
|
else
|
17
|
-
|
14
|
+
raise "Could not make a a #{cls.inspect} view"
|
18
15
|
end
|
19
16
|
end
|
20
17
|
|
21
|
-
subject{ _make_relevant_view(table, block) }
|
18
|
+
subject{ _make_relevant_view(table, block, described_class) }
|
22
19
|
|
23
20
|
describe '#columns' do
|
24
21
|
let(:table){ ObjectTable.new(col1: [1, 2, 3], col2: 5) }
|
@@ -52,7 +49,7 @@ RSpec.shared_examples 'a table view' do |cls|
|
|
52
49
|
describe '#set_column' do
|
53
50
|
let(:table) { ObjectTable.new(col1: [0, 1, 2, 3], col2: 5) }
|
54
51
|
let(:block) { Proc.new{col1 > 0} }
|
55
|
-
let(:view) { _make_relevant_view(table, block) }
|
52
|
+
let(:view) { _make_relevant_view(table, block, described_class) }
|
56
53
|
|
57
54
|
let(:value) { [10, 20, 30] }
|
58
55
|
let(:args) { [] }
|
@@ -189,7 +186,7 @@ RSpec.shared_examples 'a table view' do |cls|
|
|
189
186
|
describe '#pop_column' do
|
190
187
|
let(:table){ ObjectTable.new(col1: [1, 2, 3], col2: 5) }
|
191
188
|
let(:block){ Proc.new{col1 > 2} }
|
192
|
-
let(:view) { _make_relevant_view(table, block) }
|
189
|
+
let(:view) { _make_relevant_view(table, block, described_class) }
|
193
190
|
let(:name) { :col2 }
|
194
191
|
|
195
192
|
subject{ view.pop_column(name) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: object_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cheney Lin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: narray
|
@@ -97,29 +97,34 @@ files:
|
|
97
97
|
- lib/object_table.rb
|
98
98
|
- lib/object_table/basic_grid.rb
|
99
99
|
- lib/object_table/column.rb
|
100
|
-
- lib/object_table/
|
101
|
-
- lib/object_table/
|
100
|
+
- lib/object_table/factory.rb
|
101
|
+
- lib/object_table/grouping.rb
|
102
|
+
- lib/object_table/grouping/grid.rb
|
103
|
+
- lib/object_table/joining.rb
|
102
104
|
- lib/object_table/masked_column.rb
|
103
|
-
- lib/object_table/
|
104
|
-
- lib/object_table/
|
105
|
+
- lib/object_table/printing.rb
|
106
|
+
- lib/object_table/stacking.rb
|
105
107
|
- lib/object_table/static_view.rb
|
106
|
-
- lib/object_table/table_child.rb
|
107
108
|
- lib/object_table/table_methods.rb
|
109
|
+
- lib/object_table/util.rb
|
108
110
|
- lib/object_table/version.rb
|
109
111
|
- lib/object_table/view.rb
|
110
112
|
- lib/object_table/view_methods.rb
|
111
113
|
- object_table.gemspec
|
112
114
|
- spec/object_table/basic_grid_spec.rb
|
113
115
|
- spec/object_table/column_spec.rb
|
114
|
-
- spec/object_table/
|
116
|
+
- spec/object_table/grouping_spec.rb
|
115
117
|
- spec/object_table/masked_column_spec.rb
|
116
118
|
- spec/object_table/static_view_spec.rb
|
119
|
+
- spec/object_table/util_spec.rb
|
117
120
|
- spec/object_table/view_spec.rb
|
118
121
|
- spec/object_table_spec.rb
|
119
122
|
- spec/spec_helper.rb
|
120
123
|
- spec/subclassing_spec.rb
|
124
|
+
- spec/support/joining_example.rb
|
121
125
|
- spec/support/object_table_example.rb
|
122
|
-
- spec/support/
|
126
|
+
- spec/support/stacking_example.rb
|
127
|
+
- spec/support/utils.rb
|
123
128
|
- spec/support/view_example.rb
|
124
129
|
homepage: https://github.com/lincheney/ruby-object-table
|
125
130
|
licenses:
|
@@ -133,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
138
|
requirements:
|
134
139
|
- - '>='
|
135
140
|
- !ruby/object:Gem::Version
|
136
|
-
version: '0'
|
141
|
+
version: '2.0'
|
137
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
143
|
requirements:
|
139
144
|
- - '>='
|
@@ -148,13 +153,16 @@ summary: Simple data table table implementation in ruby
|
|
148
153
|
test_files:
|
149
154
|
- spec/object_table/basic_grid_spec.rb
|
150
155
|
- spec/object_table/column_spec.rb
|
151
|
-
- spec/object_table/
|
156
|
+
- spec/object_table/grouping_spec.rb
|
152
157
|
- spec/object_table/masked_column_spec.rb
|
153
158
|
- spec/object_table/static_view_spec.rb
|
159
|
+
- spec/object_table/util_spec.rb
|
154
160
|
- spec/object_table/view_spec.rb
|
155
161
|
- spec/object_table_spec.rb
|
156
162
|
- spec/spec_helper.rb
|
157
163
|
- spec/subclassing_spec.rb
|
164
|
+
- spec/support/joining_example.rb
|
158
165
|
- spec/support/object_table_example.rb
|
159
|
-
- spec/support/
|
166
|
+
- spec/support/stacking_example.rb
|
167
|
+
- spec/support/utils.rb
|
160
168
|
- spec/support/view_example.rb
|