rbbt-util 5.21.21 → 5.21.22
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/lib/rbbt/tsv/manipulate.rb +3 -1
- data/test/rbbt/tsv/test_manipulate.rb +21 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56000e72c4833ad6fd577e035cf1118a44d10ab8
|
4
|
+
data.tar.gz: 3df3135c707ac24477818e7a7598e4c9cf461fe8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 336603c63d42b3eafd7f19b74eb02b0d0c694e488dcdf3f0bddd1899829f6dccbd10258a5502594b5e82a09d3d6da02964d7642dca73c2982e34ef126866cef9
|
7
|
+
data.tar.gz: 9ff1a15dcb8c54eb68aba7a57e836f33603692097addeb1cbeb207d82957068f98f875a70237f3342df7c45633875a4e34f40fabc654eb1205623f96ff797933
|
data/lib/rbbt/tsv/manipulate.rb
CHANGED
@@ -210,13 +210,15 @@ module TSV
|
|
210
210
|
v = value.collect{|v|
|
211
211
|
r = v[i]
|
212
212
|
r = v[0] if r.nil?
|
213
|
-
r
|
213
|
+
[r]
|
214
214
|
}
|
215
215
|
|
216
216
|
if not @unnamed
|
217
217
|
k = Misc.prepare_entity(k, traverser.new_key_field_name, entity_options)
|
218
218
|
end
|
219
|
+
|
219
220
|
v.key = k if NamedArray === v
|
221
|
+
|
220
222
|
yield k, v
|
221
223
|
|
222
224
|
end
|
@@ -39,6 +39,27 @@ row3 a C Id4
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
def test_reorder_zipped
|
43
|
+
content =<<-EOF
|
44
|
+
#Id ValueA ValueB OtherID
|
45
|
+
row1 a|aa|aaa b|bb|bbb Id1|Id2|Id3
|
46
|
+
row2 A B Id3
|
47
|
+
row3 a b_ Id1_
|
48
|
+
EOF
|
49
|
+
|
50
|
+
TmpFile.with_file(content) do |filename|
|
51
|
+
tsv = TSV.open(File.open(filename), :sep => /\s+/)
|
52
|
+
|
53
|
+
tsv1 = tsv.reorder("ValueA", nil, :zipped => true, :merge => true, :persist => true, :persist_file => '/tmp/foo.rbbt.tch')
|
54
|
+
|
55
|
+
assert_equal "ValueA", tsv1.key_field
|
56
|
+
assert_equal ["B"], tsv1["A"]["ValueB"]
|
57
|
+
assert_equal ["bb"], tsv1["aa"]["ValueB"]
|
58
|
+
assert_equal ["b","b_"], tsv1["a"]["ValueB"]
|
59
|
+
assert_equal %w(Id ValueB OtherID), tsv1.fields
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
42
63
|
def test_reorder_simple
|
43
64
|
content =<<-EOF
|
44
65
|
#Id ValueA ValueB OtherID
|