scout-gear 7.3.0 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.vimproject +44 -16
  3. data/Rakefile +6 -1
  4. data/VERSION +1 -1
  5. data/bin/scout +21 -7
  6. data/doc/lib/scout/path.md +35 -0
  7. data/doc/lib/scout/workflow/task.md +13 -0
  8. data/lib/rbbt-scout.rb +1 -0
  9. data/lib/scout/cmd.rb +24 -25
  10. data/lib/scout/concurrent_stream.rb +59 -39
  11. data/lib/scout/config.rb +1 -1
  12. data/lib/scout/exceptions.rb +10 -0
  13. data/lib/scout/log/color.rb +15 -12
  14. data/lib/scout/log/progress/report.rb +8 -6
  15. data/lib/scout/log/progress/util.rb +61 -54
  16. data/lib/scout/log/progress.rb +1 -1
  17. data/lib/scout/log/trap.rb +107 -0
  18. data/lib/scout/log.rb +115 -52
  19. data/lib/scout/meta_extension.rb +47 -6
  20. data/lib/scout/misc/digest.rb +12 -3
  21. data/lib/scout/misc/format.rb +24 -7
  22. data/lib/scout/misc/insist.rb +1 -1
  23. data/lib/scout/misc/monitor.rb +22 -0
  24. data/lib/scout/misc/system.rb +58 -0
  25. data/lib/scout/named_array.rb +73 -3
  26. data/lib/scout/offsite/ssh.rb +171 -0
  27. data/lib/scout/offsite/step.rb +83 -0
  28. data/lib/scout/offsite/sync.rb +55 -0
  29. data/lib/scout/offsite.rb +3 -0
  30. data/lib/scout/open/lock/lockfile.rb +587 -0
  31. data/lib/scout/open/lock.rb +9 -2
  32. data/lib/scout/open/remote.rb +16 -1
  33. data/lib/scout/open/stream.rb +146 -83
  34. data/lib/scout/open/util.rb +22 -3
  35. data/lib/scout/open.rb +5 -4
  36. data/lib/scout/path/find.rb +24 -11
  37. data/lib/scout/path/util.rb +40 -0
  38. data/lib/scout/persist/serialize.rb +19 -6
  39. data/lib/scout/persist.rb +29 -13
  40. data/lib/scout/resource/path.rb +57 -0
  41. data/lib/scout/resource/produce.rb +0 -8
  42. data/lib/scout/resource/util.rb +12 -5
  43. data/lib/scout/tmpfile.rb +7 -8
  44. data/lib/scout/tsv/attach.rb +177 -0
  45. data/lib/scout/tsv/change_id.rb +40 -0
  46. data/lib/scout/tsv/dumper.rb +74 -46
  47. data/lib/scout/tsv/index.rb +85 -87
  48. data/lib/scout/tsv/open.rb +160 -85
  49. data/lib/scout/tsv/parser.rb +142 -80
  50. data/lib/scout/tsv/path.rb +1 -2
  51. data/lib/scout/tsv/persist/adapter.rb +15 -45
  52. data/lib/scout/tsv/persist/fix_width_table.rb +3 -0
  53. data/lib/scout/tsv/persist/tokyocabinet.rb +6 -1
  54. data/lib/scout/tsv/persist.rb +4 -0
  55. data/lib/scout/tsv/stream.rb +204 -0
  56. data/lib/scout/tsv/transformer.rb +152 -0
  57. data/lib/scout/tsv/traverse.rb +96 -92
  58. data/lib/scout/tsv/util/filter.rb +9 -0
  59. data/lib/scout/tsv/util/reorder.rb +81 -0
  60. data/lib/scout/tsv/util/select.rb +78 -33
  61. data/lib/scout/tsv/util/unzip.rb +86 -0
  62. data/lib/scout/tsv/util.rb +60 -11
  63. data/lib/scout/tsv.rb +34 -4
  64. data/lib/scout/work_queue/socket.rb +6 -1
  65. data/lib/scout/work_queue/worker.rb +5 -2
  66. data/lib/scout/work_queue.rb +51 -20
  67. data/lib/scout/workflow/definition.rb +23 -3
  68. data/lib/scout/workflow/deployment/orchestrator.rb +245 -0
  69. data/lib/scout/workflow/deployment.rb +1 -0
  70. data/lib/scout/workflow/step/dependencies.rb +56 -10
  71. data/lib/scout/workflow/step/file.rb +5 -0
  72. data/lib/scout/workflow/step/info.rb +40 -7
  73. data/lib/scout/workflow/step/load.rb +1 -1
  74. data/lib/scout/workflow/step/provenance.rb +9 -7
  75. data/lib/scout/workflow/step/status.rb +43 -0
  76. data/lib/scout/workflow/step.rb +160 -49
  77. data/lib/scout/workflow/task/dependencies.rb +114 -0
  78. data/lib/scout/workflow/task/inputs.rb +40 -32
  79. data/lib/scout/workflow/task.rb +38 -102
  80. data/lib/scout/workflow/usage.rb +48 -18
  81. data/lib/scout/workflow.rb +4 -2
  82. data/lib/scout-gear.rb +2 -0
  83. data/lib/scout.rb +6 -0
  84. data/scout-gear.gemspec +52 -23
  85. data/scout_commands/doc +37 -0
  86. data/scout_commands/find +1 -0
  87. data/scout_commands/offsite +30 -0
  88. data/scout_commands/update +29 -0
  89. data/scout_commands/workflow/info +15 -3
  90. data/scout_commands/workflow/install +102 -0
  91. data/scout_commands/workflow/task +57 -9
  92. data/test/scout/offsite/test_ssh.rb +15 -0
  93. data/test/scout/offsite/test_step.rb +33 -0
  94. data/test/scout/offsite/test_sync.rb +36 -0
  95. data/test/scout/offsite/test_task.rb +0 -0
  96. data/test/scout/open/test_stream.rb +60 -58
  97. data/test/scout/path/test_find.rb +10 -1
  98. data/test/scout/resource/test_path.rb +6 -0
  99. data/test/scout/resource/test_produce.rb +15 -0
  100. data/test/scout/test_meta_extension.rb +25 -0
  101. data/test/scout/test_named_array.rb +24 -0
  102. data/test/scout/test_persist.rb +9 -2
  103. data/test/scout/test_tsv.rb +229 -2
  104. data/test/scout/test_work_queue.rb +65 -41
  105. data/test/scout/tsv/persist/test_tokyocabinet.rb +29 -1
  106. data/test/scout/tsv/test_attach.rb +227 -0
  107. data/test/scout/tsv/test_change_id.rb +98 -0
  108. data/test/scout/tsv/test_dumper.rb +1 -1
  109. data/test/scout/tsv/test_index.rb +49 -3
  110. data/test/scout/tsv/test_open.rb +160 -2
  111. data/test/scout/tsv/test_parser.rb +33 -2
  112. data/test/scout/tsv/test_persist.rb +2 -0
  113. data/test/scout/tsv/test_stream.rb +200 -0
  114. data/test/scout/tsv/test_transformer.rb +120 -0
  115. data/test/scout/tsv/test_traverse.rb +88 -3
  116. data/test/scout/tsv/test_util.rb +1 -0
  117. data/test/scout/tsv/util/test_reorder.rb +94 -0
  118. data/test/scout/tsv/util/test_select.rb +25 -11
  119. data/test/scout/tsv/util/test_unzip.rb +112 -0
  120. data/test/scout/work_queue/test_socket.rb +0 -1
  121. data/test/scout/workflow/deployment/test_orchestrator.rb +272 -0
  122. data/test/scout/workflow/step/test_dependencies.rb +68 -0
  123. data/test/scout/workflow/step/test_info.rb +18 -0
  124. data/test/scout/workflow/step/test_status.rb +30 -0
  125. data/test/scout/workflow/task/test_dependencies.rb +355 -0
  126. data/test/scout/workflow/task/test_inputs.rb +67 -14
  127. data/test/scout/workflow/test_definition.rb +18 -0
  128. data/test/scout/workflow/test_documentation.rb +24 -0
  129. data/test/scout/workflow/test_step.rb +112 -3
  130. data/test/scout/workflow/test_task.rb +0 -151
  131. data/test/scout/workflow/test_usage.rb +33 -6
  132. data/test/test_scout.rb +9 -0
  133. metadata +100 -8
  134. data/scout_commands/workflow/task_old +0 -706
@@ -0,0 +1,120 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/tsv'
5
+ class TestTSVTransformer < Test::Unit::TestCase
6
+ def test_traverse
7
+ content =<<-EOF
8
+ #: :sep=" "
9
+ #ID ValueA ValueB
10
+ row1 A1|A11 B1|B11
11
+ row2 A2|A22 B2|B22
12
+ EOF
13
+
14
+ TmpFile.with_file(content) do |file|
15
+ parser = TSV::Parser.new file
16
+ dumper = TSV::Dumper.new :key_field => "Key", :fields => ["Values"], type: :flat
17
+ dumper.init
18
+
19
+ trans = TSV::Transformer.new parser, dumper
20
+ dumper = trans.traverse do |k,values|
21
+ [k, values.flatten]
22
+ end
23
+
24
+ tsv = trans.tsv
25
+ assert_equal %w(A1 A11 B1 B11), tsv['row1']
26
+ end
27
+ end
28
+
29
+ def test_each
30
+ content =<<-EOF
31
+ #: :sep=" "
32
+ #ID ValueA ValueB
33
+ row1 A1|A11 B1|B11
34
+ row2 A2|A22 B2|B22
35
+ EOF
36
+
37
+ TmpFile.with_file(content) do |file|
38
+ parser = TSV::Parser.new file
39
+ dumper = TSV::Dumper.new :key_field => "Key", :fields => ["Values"], type: :flat
40
+ dumper.init
41
+
42
+ trans = TSV::Transformer.new parser, dumper
43
+ dumper = trans.each do |k,values|
44
+ values.replace values.flatten
45
+ end
46
+
47
+ trans["row3"] = %w(A3 A33)
48
+
49
+ tsv = trans.tsv
50
+ assert_equal %w(A1 A11 B1 B11), tsv['row1']
51
+ assert_equal %w(A3 A33), tsv['row3']
52
+ end
53
+ end
54
+
55
+ def test_no_dumper_no_parser
56
+ content =<<-EOF
57
+ #: :sep=" "
58
+ #ID ValueA ValueB
59
+ row1 A1|A11 B1|B11
60
+ row2 A2|A22 B2|B22
61
+ EOF
62
+
63
+ TmpFile.with_file(content) do |file|
64
+ trans = TSV::Transformer.new file
65
+ trans.key_field = "Key"
66
+ trans.fields = ["Values"]
67
+ trans.type = :flat
68
+ trans.sep = "\t"
69
+
70
+
71
+ trans["row3"] = %w(A3 A33)
72
+
73
+ trans.each do |k,values|
74
+ values.replace values.flatten
75
+ end
76
+
77
+ tsv = trans.tsv
78
+ assert_equal %w(A1 A11 B1 B11), tsv['row1']
79
+ assert_equal %w(A3 A33), tsv['row3']
80
+ end
81
+ end
82
+
83
+ def test_to_list
84
+ content =<<-EOF
85
+ #: :sep=" "
86
+ #ID ValueA ValueB
87
+ row1 A1|A11 B1|B11
88
+ row2 A2|A22 B2|B22
89
+ EOF
90
+
91
+ tsv = TSV.open(content)
92
+ assert_equal "A1", tsv.to_list["row1"]["ValueA"]
93
+ assert_equal "B2", tsv.to_list["row2"]["ValueB"]
94
+ end
95
+
96
+ def test_to_single
97
+ content =<<-EOF
98
+ #: :sep=" "
99
+ #ID ValueA ValueB
100
+ row1 A1|A11 B1|B11
101
+ row2 A2|A22 B2|B22
102
+ EOF
103
+
104
+ tsv = TSV.open(content)
105
+ assert_equal "A1", tsv.to_single["row1"]
106
+ assert_equal "A2", tsv.to_single["row2"]
107
+ end
108
+
109
+ def test_to_flat
110
+ content =<<-EOF
111
+ #: :sep=" "
112
+ #ID ValueA ValueB
113
+ row1 A1|A11 B1|B11
114
+ row2 A2|A22 B2|B22
115
+ EOF
116
+
117
+ tsv = TSV.open(content)
118
+ assert_equal %w(A1 A11 B1 B11), tsv.to_flat["row1"]
119
+ end
120
+ end
@@ -13,7 +13,6 @@ row2 A B Id3
13
13
  row2 AA BB Id33
14
14
  EOF
15
15
 
16
- sss 0
17
16
  tsv = TmpFile.with_file(content) do |filename|
18
17
  TSV.open(filename, :persist => true)
19
18
  end
@@ -31,18 +30,26 @@ row2 AA BB Id33
31
30
  assert_equal ["Id3", "B"], res["row2"]
32
31
 
33
32
  res = {}
34
- tsv.traverse "OtherID", %w(Id ValueB), one2one: true do |k,v|
33
+ tsv.traverse "OtherID", %w(Id ValueB), one2one: :strict do |k,v|
35
34
  res[k] = v
36
35
  end
37
36
  assert_equal [[nil], %w(BB)], res["Id33"]
38
37
 
39
38
  res = {}
40
- tsv.traverse "OtherID", %w(Id ValueB), one2one: true, type: :list do |k,v|
39
+ tsv.traverse "OtherID", %w(Id ValueB), one2one: :strict, type: :list do |k,v|
41
40
  res[k] = v
42
41
  end
43
42
  assert_equal ["row2", "B"], res["Id3"]
44
43
  assert_equal [nil, "BB"], res["Id33"]
45
44
 
45
+ res = {}
46
+ tsv.traverse "OtherID", %w(Id ValueB), one2one: true, type: :list do |k,v|
47
+ res[k] = v
48
+ end
49
+ assert_equal ["row2", "B"], res["Id3"]
50
+ assert_equal ["row2", "BB"], res["Id33"]
51
+
52
+
46
53
  tsv.traverse "OtherID", %w(Id ValueB), one2one: false, type: :list do |k,v|
47
54
  res[k] = v
48
55
  end
@@ -57,6 +64,36 @@ row2 AA BB Id33
57
64
  assert_equal %w(Id ValueA ValueB), field_names
58
65
  end
59
66
 
67
+ def test_tsv_traverse_all
68
+ content =<<-'EOF'
69
+ #: :sep=/\s+/#:type=:double
70
+ #Id ValueA ValueB OtherID
71
+ row1 a|aa|aaa b Id1|Id2
72
+ row2 A B Id3
73
+ row2 AA BB Id33
74
+ EOF
75
+
76
+ tsv = TmpFile.with_file(content) do |filename|
77
+ TSV.open(filename, :persist => true)
78
+ end
79
+
80
+ all_values = []
81
+ tsv.traverse "ValueA", :all do |k,v|
82
+ all_values.concat(v)
83
+ end
84
+ assert_include all_values.flatten, "row1"
85
+ assert_include all_values.flatten, "a"
86
+ assert_include all_values.flatten, "aaa"
87
+
88
+ all_values = []
89
+ tsv.traverse "Id", :all do |k,v|
90
+ all_values.concat(v)
91
+ end
92
+ assert_include all_values.flatten, "row1"
93
+ assert_include all_values.flatten, "a"
94
+ assert_include all_values.flatten, "aaa"
95
+ end
96
+
60
97
  def test_tsv_traverse_list
61
98
  content =<<-'EOF'
62
99
  #: :sep=/\s+/#:type=:list
@@ -112,5 +149,53 @@ row2 A
112
149
  end
113
150
  assert_equal [["row1"]], res["a"]
114
151
  end
152
+
153
+ def test_traverse_reorder_one2one
154
+ content =<<-'EOF'
155
+ #: :sep=" "
156
+ #ID ValueA ValueB
157
+ row1 A1|A11 B1|B11
158
+ row2 A2|A22 B2|B22
159
+ EOF
160
+
161
+ tsv = TmpFile.with_file(content) do |filename|
162
+ TSV.open(filename, :persist => true)
163
+ end
164
+
165
+ res = {}
166
+ tsv.traverse "ValueA", one2one: true do |k,v|
167
+ res[k] = v
168
+ end
169
+
170
+ assert_include res["A2"][0], "row2"
171
+
172
+ end
173
+
174
+ def test_traverse_select
175
+ content =<<-'EOF'
176
+ #: :sep=" "
177
+ #ID ValueA ValueB
178
+ row1 A1|A11 B1|B11
179
+ row2 A2|A22 B2|B22
180
+ EOF
181
+
182
+ TmpFile.with_file(content) do |filename|
183
+ tsv = TSV.open(filename, :persist => true, select: "B1")
184
+
185
+ assert_equal %w(row1), tsv.keys
186
+
187
+ tsv = TSV.open(filename, :persist => true, select: "B2")
188
+
189
+ assert_equal %w(row2), tsv.keys
190
+
191
+ tsv = TSV.open(filename, :persist => true, select: "B1")
192
+
193
+ assert_equal %w(row1), tsv.keys
194
+
195
+ tsv = TSV.open(filename, :persist => true, select: "B2")
196
+
197
+ assert_equal %w(row2), tsv.keys
198
+ end
199
+ end
115
200
  end
116
201
 
@@ -17,6 +17,7 @@ row2 a a id3
17
17
  end
18
18
  assert_equal %w(row1 row2), tsv.collect{|k,v| k }
19
19
  assert NamedArray === tsv.collect{|k,v| v }.first
20
+ assert "row1", tsv["row1"].key
20
21
  end
21
22
 
22
23
  end
@@ -0,0 +1,94 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/tsv'
5
+
6
+ class TestReorder < Test::Unit::TestCase
7
+ def test_reorder
8
+ content =<<-'EOF'
9
+ #: :sep=/\s+/#:type=:double
10
+ #Id ValueA ValueB OtherID
11
+ row1 a1|a2 b1|b2 Id1|Id2
12
+ row2 A1|A3 B1|B3 Id1|Id3
13
+ EOF
14
+
15
+ tsv = TmpFile.with_file(content) do |filename|
16
+ TSV.open(filename)
17
+ end
18
+
19
+ r = tsv.reorder "OtherID", %w(ValueB Id)
20
+
21
+ assert_equal %w(row1 row2), r["Id1"]["Id"]
22
+ assert_equal %w(row2), r["Id3"]["Id"]
23
+ end
24
+
25
+ def test_reorder_list
26
+ content =<<-'EOF'
27
+ #: :sep=/\s+/#:type=:list
28
+ #Id ValueA ValueB OtherID
29
+ row1 a1 b1 Id1
30
+ row2 A1 B1 Id1
31
+ EOF
32
+
33
+ tsv = TmpFile.with_file(content) do |filename|
34
+ TSV.open(filename)
35
+ end
36
+
37
+ r = tsv.reorder "ValueB"
38
+
39
+ assert_equal "row1", r["b1"]["Id"]
40
+ assert_equal "row2", r["B1"]["Id"]
41
+ end
42
+
43
+ def test_reorder_single
44
+ content =<<-'EOF'
45
+ #: :sep=/\s+/#:type=:single
46
+ #Id ValueA
47
+ row1 a1
48
+ row2 A1
49
+ EOF
50
+
51
+ tsv = TmpFile.with_file(content) do |filename|
52
+ TSV.open(filename)
53
+ end
54
+
55
+ r = tsv.reorder "ValueA"
56
+
57
+ assert_equal "row1", r["a1"]
58
+ assert_equal "row2", r["A1"]
59
+ end
60
+
61
+ def test_transpose
62
+ content =<<-EOF
63
+ #: :type=:list
64
+ #Row vA vB vID
65
+ row1 a b Id1
66
+ row2 A B Id3
67
+ row3 a C Id4
68
+ EOF
69
+
70
+ TmpFile.with_file(content) do |filename|
71
+ tsv = TSV.open(filename, :sep => /\s+/)
72
+
73
+ assert_equal %w(vA vB vID), tsv.transpose("Values").keys
74
+ assert_equal %w(Id1 Id3 Id4), tsv.transpose("Values")["vID"]
75
+ end
76
+ end
77
+
78
+ def test_column
79
+ content =<<-EOF
80
+ #Id ValueA ValueB ValueC
81
+ rowA A|AA B|BB C|CC
82
+ rowa a|aa b|BB C|CC
83
+ EOF
84
+
85
+ TmpFile.with_file(content) do |filename|
86
+ tsv = TSV.open(File.open(filename), :sep => /\s+/, :type => :double)
87
+ tsv = tsv.column("ValueA", cast: :downcase)
88
+ assert_equal %w(a aa), tsv["rowA"]
89
+ assert_equal %w(a aa), tsv["rowa"]
90
+ end
91
+ end
92
+
93
+ end
94
+
@@ -23,22 +23,36 @@ row2 AA BB Id33
23
23
  assert_equal ['row2'], s.keys
24
24
  end
25
25
 
26
- def test_reorder
26
+ def test_select_values
27
27
  content =<<-'EOF'
28
- #: :sep=/\s+/#:type=:double
29
- #Id ValueA ValueB OtherID
30
- row1 a1|a2 b1|b2 Id1|Id2
31
- row2 A1|A3 B1|B3 Id1|Id3
28
+ #: :sep=" "
29
+ #ID ValueA ValueB
30
+ row1 A1|A11 B1|B11
31
+ row2 A2|A22 B2|B22
32
32
  EOF
33
33
 
34
- tsv = TmpFile.with_file(content) do |filename|
35
- TSV.open(filename)
36
- end
34
+ tsv = TSV.open(content)
35
+
36
+ assert TSV.select("row1", tsv["row1"], "A1")
37
+ refute TSV.select("row2", tsv["row2"], "A1")
38
+ assert TSV.select("row2", tsv["row2"], "A2")
37
39
 
38
- r = tsv.reorder "OtherID", %w(ValueB Id)
40
+ assert TSV.select("row1", tsv["row1"], "B1")
41
+ refute TSV.select("row2", tsv["row2"], "B1")
42
+
43
+ refute TSV.select("row1", tsv["row1"], "B1", invert: true)
44
+ assert TSV.select("row2", tsv["row2"], "B1", invert: true)
45
+
46
+ assert TSV.select("row1", tsv["row1"], {"ValueB" => "B1"})
47
+ refute TSV.select("row2", tsv["row2"], {"ValueB" => "B1"})
48
+
49
+ tsv.with_unnamed do
50
+ assert TSV.select("row1", tsv["row1"], {"ValueB" => "B1"}, fields: tsv.fields)
51
+ refute TSV.select("row2", tsv["row2"], {"ValueB" => "B1"}, fields: tsv.fields)
52
+ end
39
53
 
40
- assert_equal %w(row1 row2), r["Id1"]["Id"]
41
- assert_equal %w(row2), r["Id3"]["Id"]
54
+ assert TSV.select("row1", tsv["row1"], "B1", field: "ValueB")
55
+ refute TSV.select("row2", tsv["row2"], "B1", field: "ValueB")
42
56
  end
43
57
  end
44
58
 
@@ -0,0 +1,112 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/tsv'
5
+ class TestTSVUnzip < Test::Unit::TestCase
6
+ def test_unzip
7
+ content1 =<<-EOF
8
+ #: :sep=" "
9
+ #ID ValueA ValueB
10
+ row1 A1|A11 B1|B11
11
+ row2 A2|A22 B2|B22
12
+ EOF
13
+
14
+ tsv = TSV.open(content1)
15
+ unzip = tsv.unzip("ValueA", delete: true)
16
+ assert_equal "B1", unzip["row1:A1"]["ValueB"]
17
+ assert_equal "B22", unzip["row2:A22"]["ValueB"]
18
+ end
19
+
20
+ def test_unzip_list
21
+ content1 =<<-EOF
22
+ #: :sep=" "#:type=:list
23
+ #ID ValueA ValueB
24
+ row1 A1 B1
25
+ row2 A2 B2
26
+ EOF
27
+
28
+ tsv = TSV.open(content1)
29
+ unzip = tsv.unzip("ValueA", delete: true)
30
+ assert_equal "B1", unzip["row1:A1"]["ValueB"]
31
+ assert_equal "B2", unzip["row2:A2"]["ValueB"]
32
+ end
33
+
34
+ def test_unzip_merge
35
+ content1 =<<-EOF
36
+ #: :sep=" "
37
+ #ID ValueA ValueB
38
+ row1 A1|A11|A11 B1|B11|B11.1
39
+ row2 A2|A22|A22 B2|B22|B22.2
40
+ EOF
41
+
42
+ tsv = TSV.open(content1)
43
+ unzip = tsv.unzip("ValueA", delete: true, merge: true)
44
+ assert_equal ["B1"], unzip["row1:A1"]["ValueB"]
45
+ assert_equal ["B11", "B11.1"], unzip["row1:A11"]["ValueB"]
46
+ assert_equal ["B22", "B22.2"], unzip["row2:A22"]["ValueB"]
47
+ end
48
+
49
+ def test_unzip_merge_stream
50
+ content1 =<<-EOF
51
+ #: :sep=" "
52
+ #ID ValueA ValueB
53
+ row1 A1|A11|A11 B1|B11|B11.1
54
+ row2 A2|A22|A22 B2|B22|B22.2
55
+ EOF
56
+
57
+ tsv = TSV.open(content1)
58
+ unzip = tsv.unzip("ValueA", delete: true, merge: true, target: :stream).tsv
59
+ assert_equal ["B1"], unzip["row1:A1"]["ValueB"]
60
+ assert_equal ["B11", "B11.1"], unzip["row1:A11"]["ValueB"]
61
+ assert_equal ["B22", "B22.2"], unzip["row2:A22"]["ValueB"]
62
+ end
63
+
64
+ def test_unzip_merge_stream_parser
65
+ content1 =<<-EOF
66
+ #: :sep=" "
67
+ #ID ValueA ValueB
68
+ row1 A1|A11|A11 B1|B11|B11.1
69
+ row2 A2|A22|A22 B2|B22|B22.2
70
+ EOF
71
+
72
+ TmpFile.with_file(content1) do |filename|
73
+ unzip = TSV.unzip(filename, "ValueA", delete: true, merge: true, target: :stream).tsv
74
+ assert_equal ["B1"], unzip["row1:A1"]["ValueB"]
75
+ assert_equal ["B11", "B11.1"], unzip["row1:A11"]["ValueB"]
76
+ assert_equal ["B22", "B22.2"], unzip["row2:A22"]["ValueB"]
77
+ end
78
+ end
79
+
80
+ def test_unzip_merge_stream_parser_one2many
81
+ content1 =<<-EOF
82
+ #: :sep=" "
83
+ #ID ValueA ValueB
84
+ row1 A1|A11|A11 B1|B11|B11.1
85
+ row2 A2|A22|A22 B2|B22|B22.2
86
+ EOF
87
+
88
+ TmpFile.with_file(content1) do |filename|
89
+ unzip = TSV.unzip(filename, "ValueA", delete: true, merge: true, target: :stream, one2one: false).tsv
90
+ assert_equal ["B1", "B11", "B11.1"], unzip["row1:A1"]["ValueB"].uniq
91
+ assert_equal ["B1", "B11", "B11.1"], unzip["row1:A11"]["ValueB"].uniq
92
+ end
93
+ end
94
+
95
+
96
+ def test_unzip_target
97
+ content1 =<<-EOF
98
+ #: :sep=" "
99
+ #ID ValueA ValueB
100
+ row1 A1|A11|A11 B1|B11|B11.1
101
+ row2 A2|A22|A22 B2|B22|B22.2
102
+ EOF
103
+
104
+ tsv = TSV.open(content1)
105
+ unzip = TSV.setup({}, :key_field => "Key", :fields => %w(ValueA ValueB))
106
+ tsv.unzip("ValueA", delete: true, merge: true, target: unzip)
107
+ assert_equal ["B1"], unzip["row1:A1"]["ValueB"]
108
+ assert_equal ["B11", "B11.1"], unzip["row1:A11"]["ValueB"]
109
+ assert_equal ["B22", "B22.2"], unzip["row2:A22"]["ValueB"]
110
+ end
111
+ end
112
+
@@ -22,7 +22,6 @@ class TestSocket < Test::Unit::TestCase
22
22
  end
23
23
 
24
24
  def __test_speed
25
- sss 0
26
25
  socket = WorkQueue::Socket.new
27
26
 
28
27
  num = 10_000