scout-gear 7.3.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.vimproject +20 -9
- data/VERSION +1 -1
- data/bin/scout +6 -3
- data/lib/rbbt-scout.rb +1 -0
- data/lib/scout/cmd.rb +1 -1
- data/lib/scout/concurrent_stream.rb +26 -23
- data/lib/scout/config.rb +1 -1
- data/lib/scout/log/color.rb +4 -1
- data/lib/scout/log/progress/report.rb +1 -1
- data/lib/scout/log/progress/util.rb +58 -54
- data/lib/scout/log/progress.rb +1 -1
- data/lib/scout/log/trap.rb +107 -0
- data/lib/scout/log.rb +56 -21
- data/lib/scout/meta_extension.rb +13 -6
- data/lib/scout/misc/digest.rb +1 -1
- data/lib/scout/misc/format.rb +12 -0
- data/lib/scout/misc/insist.rb +1 -1
- data/lib/scout/misc/monitor.rb +11 -0
- data/lib/scout/misc/system.rb +10 -0
- data/lib/scout/named_array.rb +65 -3
- data/lib/scout/open/lock/lockfile.rb +587 -0
- data/lib/scout/open/lock.rb +28 -2
- data/lib/scout/open/remote.rb +4 -0
- data/lib/scout/open/stream.rb +90 -15
- data/lib/scout/open/util.rb +13 -3
- data/lib/scout/path/find.rb +9 -1
- data/lib/scout/path/util.rb +35 -0
- data/lib/scout/persist/serialize.rb +18 -5
- data/lib/scout/persist.rb +28 -12
- data/lib/scout/resource/path.rb +53 -0
- data/lib/scout/resource/produce.rb +0 -8
- data/lib/scout/resource/util.rb +2 -1
- data/lib/scout/tmpfile.rb +7 -8
- data/lib/scout/tsv/attach.rb +177 -0
- data/lib/scout/tsv/change_id.rb +40 -0
- data/lib/scout/tsv/dumper.rb +72 -46
- data/lib/scout/tsv/index.rb +69 -13
- data/lib/scout/tsv/open.rb +138 -84
- data/lib/scout/tsv/parser.rb +135 -80
- data/lib/scout/tsv/path.rb +1 -2
- data/lib/scout/tsv/persist/adapter.rb +15 -45
- data/lib/scout/tsv/persist/fix_width_table.rb +3 -0
- data/lib/scout/tsv/persist/tokyocabinet.rb +4 -1
- data/lib/scout/tsv/persist.rb +4 -0
- data/lib/scout/tsv/transformer.rb +141 -0
- data/lib/scout/tsv/traverse.rb +96 -92
- data/lib/scout/tsv/util/filter.rb +9 -0
- data/lib/scout/tsv/util/reorder.rb +81 -0
- data/lib/scout/tsv/util/select.rb +78 -33
- data/lib/scout/tsv/util/unzip.rb +86 -0
- data/lib/scout/tsv/util.rb +60 -11
- data/lib/scout/tsv.rb +26 -3
- data/lib/scout/work_queue/socket.rb +6 -1
- data/lib/scout/work_queue/worker.rb +5 -2
- data/lib/scout/work_queue.rb +15 -8
- data/lib/scout/workflow/definition.rb +21 -2
- data/lib/scout/workflow/step/dependencies.rb +24 -4
- data/lib/scout/workflow/step/info.rb +36 -5
- data/lib/scout/workflow/step/provenance.rb +8 -7
- data/lib/scout/workflow/step/status.rb +45 -0
- data/lib/scout/workflow/step.rb +100 -34
- data/lib/scout/workflow/task/inputs.rb +14 -20
- data/lib/scout/workflow/task.rb +81 -46
- data/lib/scout/workflow/usage.rb +8 -6
- data/scout-gear.gemspec +24 -20
- data/scout_commands/workflow/task +34 -7
- data/test/scout/open/test_stream.rb +60 -58
- data/test/scout/path/test_find.rb +10 -1
- data/test/scout/resource/test_produce.rb +15 -0
- data/test/scout/test_meta_extension.rb +25 -0
- data/test/scout/test_named_array.rb +18 -0
- data/test/scout/test_persist.rb +6 -0
- data/test/scout/test_tsv.rb +212 -2
- data/test/scout/test_work_queue.rb +21 -19
- data/test/scout/tsv/persist/test_adapter.rb +1 -1
- data/test/scout/tsv/persist/test_tokyocabinet.rb +29 -1
- data/test/scout/tsv/test_attach.rb +227 -0
- data/test/scout/tsv/test_change_id.rb +98 -0
- data/test/scout/tsv/test_dumper.rb +1 -1
- data/test/scout/tsv/test_index.rb +35 -3
- data/test/scout/tsv/test_open.rb +160 -2
- data/test/scout/tsv/test_parser.rb +19 -2
- data/test/scout/tsv/test_persist.rb +2 -0
- data/test/scout/tsv/test_transformer.rb +108 -0
- data/test/scout/tsv/test_traverse.rb +88 -3
- data/test/scout/tsv/test_util.rb +1 -0
- data/test/scout/tsv/util/test_reorder.rb +94 -0
- data/test/scout/tsv/util/test_select.rb +25 -11
- data/test/scout/tsv/util/test_unzip.rb +112 -0
- data/test/scout/work_queue/test_socket.rb +0 -1
- data/test/scout/workflow/step/test_status.rb +31 -0
- data/test/scout/workflow/task/test_inputs.rb +14 -14
- data/test/scout/workflow/test_step.rb +3 -3
- data/test/scout/workflow/test_task.rb +168 -32
- data/test/scout/workflow/test_usage.rb +33 -6
- metadata +20 -6
data/scout-gear.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: scout-gear
|
5
|
+
# stub: scout-gear 8.0.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "scout-gear".freeze
|
9
|
-
s.version = "
|
9
|
+
s.version = "8.0.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Miguel Vazquez".freeze]
|
14
|
-
s.date = "2023-05-
|
14
|
+
s.date = "2023-05-23"
|
15
15
|
s.description = "Temporary files, logs, etc.".freeze
|
16
16
|
s.email = "mikisvaz@gmail.com".freeze
|
17
17
|
s.executables = ["scout".freeze]
|
@@ -45,6 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
"lib/scout/log/progress.rb",
|
46
46
|
"lib/scout/log/progress/report.rb",
|
47
47
|
"lib/scout/log/progress/util.rb",
|
48
|
+
"lib/scout/log/trap.rb",
|
48
49
|
"lib/scout/meta_extension.rb",
|
49
50
|
"lib/scout/misc.rb",
|
50
51
|
"lib/scout/misc/digest.rb",
|
@@ -57,6 +58,7 @@ Gem::Specification.new do |s|
|
|
57
58
|
"lib/scout/named_array.rb",
|
58
59
|
"lib/scout/open.rb",
|
59
60
|
"lib/scout/open/lock.rb",
|
61
|
+
"lib/scout/open/lock/lockfile.rb",
|
60
62
|
"lib/scout/open/remote.rb",
|
61
63
|
"lib/scout/open/stream.rb",
|
62
64
|
"lib/scout/open/util.rb",
|
@@ -84,6 +86,8 @@ Gem::Specification.new do |s|
|
|
84
86
|
"lib/scout/simple_opt/setup.rb",
|
85
87
|
"lib/scout/tmpfile.rb",
|
86
88
|
"lib/scout/tsv.rb",
|
89
|
+
"lib/scout/tsv/attach.rb",
|
90
|
+
"lib/scout/tsv/change_id.rb",
|
87
91
|
"lib/scout/tsv/dumper.rb",
|
88
92
|
"lib/scout/tsv/index.rb",
|
89
93
|
"lib/scout/tsv/open.rb",
|
@@ -94,11 +98,14 @@ Gem::Specification.new do |s|
|
|
94
98
|
"lib/scout/tsv/persist/fix_width_table.rb",
|
95
99
|
"lib/scout/tsv/persist/serialize.rb",
|
96
100
|
"lib/scout/tsv/persist/tokyocabinet.rb",
|
101
|
+
"lib/scout/tsv/transformer.rb",
|
97
102
|
"lib/scout/tsv/traverse.rb",
|
98
103
|
"lib/scout/tsv/util.rb",
|
99
104
|
"lib/scout/tsv/util/filter.rb",
|
100
105
|
"lib/scout/tsv/util/process.rb",
|
106
|
+
"lib/scout/tsv/util/reorder.rb",
|
101
107
|
"lib/scout/tsv/util/select.rb",
|
108
|
+
"lib/scout/tsv/util/unzip.rb",
|
102
109
|
"lib/scout/work_queue.rb",
|
103
110
|
"lib/scout/work_queue/socket.rb",
|
104
111
|
"lib/scout/work_queue/worker.rb",
|
@@ -113,6 +120,7 @@ Gem::Specification.new do |s|
|
|
113
120
|
"lib/scout/workflow/step/load.rb",
|
114
121
|
"lib/scout/workflow/step/progress.rb",
|
115
122
|
"lib/scout/workflow/step/provenance.rb",
|
123
|
+
"lib/scout/workflow/step/status.rb",
|
116
124
|
"lib/scout/workflow/task.rb",
|
117
125
|
"lib/scout/workflow/task/inputs.rb",
|
118
126
|
"lib/scout/workflow/usage.rb",
|
@@ -175,22 +183,28 @@ Gem::Specification.new do |s|
|
|
175
183
|
"test/scout/tsv/persist/test_adapter.rb",
|
176
184
|
"test/scout/tsv/persist/test_fix_width_table.rb",
|
177
185
|
"test/scout/tsv/persist/test_tokyocabinet.rb",
|
186
|
+
"test/scout/tsv/test_attach.rb",
|
187
|
+
"test/scout/tsv/test_change_id.rb",
|
178
188
|
"test/scout/tsv/test_dumper.rb",
|
179
189
|
"test/scout/tsv/test_index.rb",
|
180
190
|
"test/scout/tsv/test_open.rb",
|
181
191
|
"test/scout/tsv/test_parser.rb",
|
182
192
|
"test/scout/tsv/test_persist.rb",
|
193
|
+
"test/scout/tsv/test_transformer.rb",
|
183
194
|
"test/scout/tsv/test_traverse.rb",
|
184
195
|
"test/scout/tsv/test_util.rb",
|
185
196
|
"test/scout/tsv/util/test_filter.rb",
|
186
197
|
"test/scout/tsv/util/test_process.rb",
|
198
|
+
"test/scout/tsv/util/test_reorder.rb",
|
187
199
|
"test/scout/tsv/util/test_select.rb",
|
200
|
+
"test/scout/tsv/util/test_unzip.rb",
|
188
201
|
"test/scout/work_queue/test_socket.rb",
|
189
202
|
"test/scout/work_queue/test_worker.rb",
|
190
203
|
"test/scout/workflow/step/test_dependencies.rb",
|
191
204
|
"test/scout/workflow/step/test_info.rb",
|
192
205
|
"test/scout/workflow/step/test_load.rb",
|
193
206
|
"test/scout/workflow/step/test_provenance.rb",
|
207
|
+
"test/scout/workflow/step/test_status.rb",
|
194
208
|
"test/scout/workflow/task/test_inputs.rb",
|
195
209
|
"test/scout/workflow/test_definition.rb",
|
196
210
|
"test/scout/workflow/test_documentation.rb",
|
@@ -203,25 +217,15 @@ Gem::Specification.new do |s|
|
|
203
217
|
]
|
204
218
|
s.homepage = "http://github.com/mikisvaz/scout-gear".freeze
|
205
219
|
s.licenses = ["MIT".freeze]
|
206
|
-
s.rubygems_version = "3.
|
220
|
+
s.rubygems_version = "3.4.11".freeze
|
207
221
|
s.summary = "basic gear for scouts".freeze
|
208
222
|
|
209
|
-
|
210
|
-
s.specification_version = 4
|
211
|
-
end
|
223
|
+
s.specification_version = 4
|
212
224
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
219
|
-
else
|
220
|
-
s.add_dependency(%q<term-ansicolor>.freeze, [">= 0"])
|
221
|
-
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
222
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
223
|
-
s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
224
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
225
|
-
end
|
225
|
+
s.add_runtime_dependency(%q<term-ansicolor>.freeze, [">= 0"])
|
226
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
227
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
228
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
229
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
226
230
|
end
|
227
231
|
|
@@ -4,6 +4,9 @@ require 'scout'
|
|
4
4
|
|
5
5
|
$0 = "scout #{$previous_commands.any? ? $previous_commands*" " + " " : "" }#{ File.basename(__FILE__) }" if $previous_commands
|
6
6
|
|
7
|
+
ENV["SCOUT_NO_STREAM"] = "true" if ARGV.include? "--nostream"
|
8
|
+
ENV["SCOUT_UPDATE"] = "true" if ARGV.include? "--update"
|
9
|
+
|
7
10
|
options = SOPT.setup <<EOF
|
8
11
|
|
9
12
|
Run a workflow job
|
@@ -11,11 +14,14 @@ Run a workflow job
|
|
11
14
|
$ #{$0} [<options>] <workflow> <task>
|
12
15
|
|
13
16
|
-h--help Print this help
|
17
|
+
--nostream Disable job streaming
|
18
|
+
--update Update jobs with newer dependencies
|
14
19
|
-jn--job_name* Name to use as job identifier
|
15
20
|
-pf--print_filepath Print the file path
|
16
21
|
-prov--provenance Print the step provenance
|
17
22
|
-cl--clean Clean the last step
|
18
23
|
-rcl--recursive_clean Clean all steps
|
24
|
+
-ct--clean_task* Clean a particular task
|
19
25
|
EOF
|
20
26
|
|
21
27
|
workflow_name, task_name = ARGV
|
@@ -28,7 +34,10 @@ task = workflow.tasks[task_name.to_sym] if task_name
|
|
28
34
|
|
29
35
|
options[:help] = true if task.nil?
|
30
36
|
|
31
|
-
|
37
|
+
help, provenance, clean, recursive_clean, clean_task, jobname, print_filepath = IndiferentHash.process_options options,
|
38
|
+
:help, :provenance, :clean, :recursive_clean, :clean_task, :job_name, :print_filepath
|
39
|
+
|
40
|
+
if help
|
32
41
|
if defined? scout_usage
|
33
42
|
scout_usage
|
34
43
|
else
|
@@ -40,17 +49,35 @@ if options[:help]
|
|
40
49
|
end
|
41
50
|
|
42
51
|
job_options = task.get_SOPT(task)
|
43
|
-
job = workflow.job(task_name,
|
52
|
+
job = workflow.job(task_name, jobname, job_options)
|
53
|
+
|
54
|
+
job.recursive_clean if recursive_clean
|
55
|
+
job.clean if clean
|
56
|
+
|
57
|
+
if clean_task
|
58
|
+
ENV["SCOUT_UPDATE"] = 'true'
|
59
|
+
clean_task.split(",").each do |clean_task|
|
60
|
+
if clean_task.include? "#"
|
61
|
+
clean_workflow, clean_task = clean_task.split("#")
|
62
|
+
end
|
44
63
|
|
45
|
-
job.
|
46
|
-
|
64
|
+
job.rec_dependencies.each do |dep|
|
65
|
+
next unless dep.task_name.to_s == clean_task.to_s
|
66
|
+
next unless clean_workflow.nil? || clean_workflow == dep.workflow.to_s
|
67
|
+
dep.clean
|
68
|
+
dep.set_info :status, :cleaned
|
69
|
+
end
|
70
|
+
|
71
|
+
job.clean if job.task_name.to_s == clean_task.to_s
|
72
|
+
end
|
73
|
+
end
|
47
74
|
|
48
|
-
if
|
75
|
+
if provenance
|
49
76
|
puts Step.prov_report(job)
|
50
77
|
else
|
51
|
-
job.run unless job.done?
|
78
|
+
job.run(true) unless job.done?
|
52
79
|
|
53
|
-
if
|
80
|
+
if print_filepath
|
54
81
|
job.join
|
55
82
|
path = job.path
|
56
83
|
path = path.find if Path === path
|
@@ -334,63 +334,65 @@ row1 A B C
|
|
334
334
|
assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
|
335
335
|
end
|
336
336
|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
337
|
+
def test_collapse_stream
|
338
|
+
text=<<-EOF
|
339
|
+
row1 A B C
|
340
|
+
row1 a b c
|
341
|
+
row2 AA BB CC
|
342
|
+
row2 aa bb cc
|
343
|
+
EOF
|
344
|
+
|
345
|
+
s = StringIO.new text
|
346
|
+
stream = Open.collapse_stream(s, sep: " ")
|
347
|
+
txt = stream.read
|
348
|
+
assert_include txt, "A|a"
|
349
|
+
assert_include txt, "B|b"
|
350
|
+
assert_include txt, "C|c"
|
351
|
+
end
|
352
|
+
|
353
|
+
|
354
|
+
def test_collapse_sum
|
355
|
+
text=<<-EOF
|
356
|
+
row1 12
|
357
|
+
row1 4
|
358
|
+
row2 10
|
359
|
+
row2 6
|
360
|
+
EOF
|
361
|
+
|
362
|
+
s = StringIO.new text
|
363
|
+
stream = Open.collapse_stream(s, sep: " ") do |parts|
|
364
|
+
next nil if parts.empty?
|
365
|
+
parts.first.split("|").collect{|p| p.to_f}.inject(0){|acc,e| acc += e}.to_s
|
366
|
+
end
|
367
|
+
assert_include stream.read, "row1 16"
|
368
|
+
end
|
369
|
+
|
370
|
+
|
371
|
+
def test_collapse_stream_gap
|
372
|
+
text=<<-EOF
|
373
|
+
row2 AA BB
|
374
|
+
row2 aa bb cc
|
375
|
+
EOF
|
376
|
+
|
377
|
+
s = StringIO.new text
|
378
|
+
assert Open.collapse_stream(s, sep: " ").read =~ /\|cc$/
|
379
|
+
|
380
|
+
text=<<-EOF
|
381
|
+
row2 aa bb cc
|
382
|
+
row2 AA BB
|
383
|
+
EOF
|
384
|
+
|
385
|
+
s = StringIO.new text
|
386
|
+
assert Open.collapse_stream(s, sep: " ").read =~ /cc\|$/
|
387
|
+
|
388
|
+
text=<<-EOF
|
389
|
+
row2 AA BB
|
390
|
+
row2 aa bb cc
|
391
|
+
EOF
|
392
|
+
|
393
|
+
s = StringIO.new text
|
394
|
+
assert Open.collapse_stream(s, sep: " ").read =~ /\|cc$/
|
395
|
+
end
|
394
396
|
#
|
395
397
|
#
|
396
398
|
# def test_paste_stream
|
@@ -433,7 +435,7 @@ row1 A B C
|
|
433
435
|
# s = StringIO.new text
|
434
436
|
# sorted = Misc.sort_stream(s)
|
435
437
|
# assert_equal %w(## ## ## #Row row2 row3 row1), text.split("\n").collect{|l| l.split(" ").first}
|
436
|
-
# assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
|
438
|
+
# assert_equal %w(## ## ## #Row row1 row2 row3), sorted.read.split("\n").collect{|l| l.split(" ").first}
|
437
439
|
# end
|
438
440
|
#
|
439
441
|
# def test_sort_long_stream
|
@@ -68,7 +68,6 @@ class TestPathFind < Test::Unit::TestCase
|
|
68
68
|
p = Path.setup("/tmp/foo/bar")
|
69
69
|
assert p.located?
|
70
70
|
assert_equal_path p, p.find
|
71
|
-
|
72
71
|
end
|
73
72
|
|
74
73
|
def test_custom
|
@@ -106,5 +105,15 @@ class TestPathFind < Test::Unit::TestCase
|
|
106
105
|
assert Open.exist?(tmpdir.somefile)
|
107
106
|
end
|
108
107
|
end
|
108
|
+
|
109
|
+
def test_with_extension
|
110
|
+
dir = tmpdir.directory[__method__]
|
111
|
+
list = %w(a b)
|
112
|
+
Misc.in_dir(dir) do
|
113
|
+
file = dir.foo
|
114
|
+
Open.write(file.set_extension('list'), list * "\n")
|
115
|
+
assert_equal list, file.list
|
116
|
+
end
|
117
|
+
end
|
109
118
|
end
|
110
119
|
|
@@ -59,4 +59,19 @@ end
|
|
59
59
|
assert_include File.open(TestResource.tmp.test.work.footest.bar.find).read, "OTHER"
|
60
60
|
assert_include File.open(TestResource.tmp.test.work.footest.foo_bar.find).read, "OTHER"
|
61
61
|
end
|
62
|
+
|
63
|
+
def test_produce_with_extension
|
64
|
+
dir = tmpdir.directory[__method__]
|
65
|
+
dir.pkgdir = Scout
|
66
|
+
list = %w(a b)
|
67
|
+
|
68
|
+
Scout.claim dir["foo.list"], :proc do
|
69
|
+
list
|
70
|
+
end
|
71
|
+
|
72
|
+
Misc.in_dir(dir) do
|
73
|
+
file = dir.foo
|
74
|
+
assert_equal list, file.list
|
75
|
+
end
|
76
|
+
end
|
62
77
|
end
|
@@ -8,6 +8,13 @@ class TestMetaExtension < Test::Unit::TestCase
|
|
8
8
|
extension_attr :code, :code2
|
9
9
|
end
|
10
10
|
|
11
|
+
module ExtensionClass2
|
12
|
+
extend MetaExtension
|
13
|
+
|
14
|
+
extension_attr :code3, :code4
|
15
|
+
end
|
16
|
+
|
17
|
+
|
11
18
|
def test_setup_annotate
|
12
19
|
str = "String"
|
13
20
|
ExtensionClass.setup(str, :code)
|
@@ -51,5 +58,23 @@ class TestMetaExtension < Test::Unit::TestCase
|
|
51
58
|
assert o.extension_attr_hash.include?(:code)
|
52
59
|
assert o.extension_attr_hash.include?(:code2)
|
53
60
|
end
|
61
|
+
|
62
|
+
def test_twice
|
63
|
+
str = "String"
|
64
|
+
|
65
|
+
ExtensionClass.setup(str, :code2 => :code)
|
66
|
+
assert_equal :code, str.code2
|
67
|
+
assert_include str.instance_variable_get(:@extension_attrs), :code
|
68
|
+
|
69
|
+
str.extend ExtensionClass2
|
70
|
+
str.code3 = :code_alt
|
71
|
+
assert_equal :code, str.code2
|
72
|
+
assert_equal :code_alt, str.code3
|
73
|
+
assert_include str.instance_variable_get(:@extension_attrs), :code
|
74
|
+
assert_include str.instance_variable_get(:@extension_attrs), :code3
|
75
|
+
|
76
|
+
assert_include str.extension_attr_hash, :code
|
77
|
+
assert_include str.extension_attr_hash, :code3
|
78
|
+
end
|
54
79
|
end
|
55
80
|
|
@@ -15,5 +15,23 @@ ValueB (Entity type)
|
|
15
15
|
assert_equal 1, NamedArray.identify_name(names, "ValueB")
|
16
16
|
assert_equal 1, NamedArray.identify_name(names, 1)
|
17
17
|
end
|
18
|
+
|
19
|
+
def test_missing_field
|
20
|
+
a = NamedArray.setup([1,2], [:a, :b])
|
21
|
+
assert_equal 1, a[:a]
|
22
|
+
assert_equal nil, a[:c]
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_zip_fields
|
26
|
+
a = [%w(a b), %w(1 1)]
|
27
|
+
assert_equal [%w(a 1), %w(b 1)], NamedArray.zip_fields(a)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_add_zipped
|
31
|
+
a = [%w(a b), %w(1 1)]
|
32
|
+
NamedArray.add_zipped a, [%w(c), %w(1)]
|
33
|
+
NamedArray.add_zipped a, [%w(d), %w(1)]
|
34
|
+
assert_equal [%w(a b c d), %w(1 1 1 1)], a
|
35
|
+
end
|
18
36
|
end
|
19
37
|
|
data/test/scout/test_persist.rb
CHANGED
@@ -156,6 +156,12 @@ class TestPersist < Test::Unit::TestCase
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
+
def test_path_prefix
|
160
|
+
Persist.persist('foo', :tsv, :prefix => "TSV") do |filename|
|
161
|
+
assert File.basename(filename).start_with? "TSV"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
159
165
|
def __test_speed
|
160
166
|
times = 100_000
|
161
167
|
TmpFile.with_file do |tmpfile|
|