adsp 1.0.6 → 1.0.9

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: 30860551943717e9021665e6b9a7579a2a2b51998515dd66bddfbe4a61803dda
4
- data.tar.gz: eab7e3ece3ff8153ac5a6e47abdd9cccba8622beb6a04d387c3d214bac35611e
3
+ metadata.gz: 76986bd130e6f8be968c9eae50c27fa1553fbab26d5b700fddba8ce6aa1961b0
4
+ data.tar.gz: 3f121ccf11e15403ceb6ef8094a02bbf290f10a7e6ee432b62a755dd011fbc7d
5
5
  SHA512:
6
- metadata.gz: ef45beb65c047e2c55cdcd68700aa0cfa456fa0b77653fda659c0c6d093d9e5b82e7ef7bcdff13d9d7c084da4e7490f29c5c2f8dcfcb83c1acc65013ec4d33ec
7
- data.tar.gz: 685e128e4d17c3d875135bca4ab169004d2f15d03b3a50bef45998b213517a040dff8892b19143672f1eefcd6ddf0642792728d5db8904e748fcb05cc3780724
6
+ metadata.gz: 001ac1c10e745c59ef0fc09ab7abffd6a69efdddd59eab469fbe133e09258fce077bce35e6601c0567fbfe3677a82b495b742dc4efc91420119864ab316f50ae
7
+ data.tar.gz: eb84851b4c42596d45ff5c7b682d1dd0482032fd26a31bb8b3b3928442050d858983049da33e25420498816fa327d316706f414570bb7efd822313cfddaa5eed
@@ -5,8 +5,6 @@ require "parallel"
5
5
  require "securerandom"
6
6
  require "tempfile"
7
7
 
8
- require_relative "coverage_helper"
9
-
10
8
  module ADSP
11
9
  module Test
12
10
  # ADSP::Test::Common module.
@@ -14,8 +14,8 @@ module ADSP
14
14
  module Test
15
15
  # ADSP::Test::File class.
16
16
  class File < Minitest::Test
17
- Option = Test::Option
18
17
  Target = Mock::File
18
+ Option = Test::Option
19
19
 
20
20
  SOURCE_PATH = Common::SOURCE_PATH
21
21
  ARCHIVE_PATH = Common::ARCHIVE_PATH
@@ -32,31 +32,31 @@ module ADSP
32
32
  def test_invalid_arguments
33
33
  Validation::INVALID_STRINGS.each do |invalid_path|
34
34
  assert_raises ValidateError do
35
- Target.compress invalid_path, ARCHIVE_PATH
35
+ target.compress invalid_path, ARCHIVE_PATH
36
36
  end
37
37
 
38
38
  assert_raises ValidateError do
39
- Target.compress SOURCE_PATH, invalid_path
39
+ target.compress SOURCE_PATH, invalid_path
40
40
  end
41
41
 
42
42
  assert_raises ValidateError do
43
- Target.decompress invalid_path, SOURCE_PATH
43
+ target.decompress invalid_path, SOURCE_PATH
44
44
  end
45
45
 
46
46
  assert_raises ValidateError do
47
- Target.decompress ARCHIVE_PATH, invalid_path
47
+ target.decompress ARCHIVE_PATH, invalid_path
48
48
  end
49
49
  end
50
50
 
51
51
  get_invalid_compressor_options do |invalid_options|
52
52
  assert_raises ValidateError do
53
- Target.compress SOURCE_PATH, ARCHIVE_PATH, invalid_options
53
+ target.compress SOURCE_PATH, ARCHIVE_PATH, invalid_options
54
54
  end
55
55
  end
56
56
 
57
57
  get_invalid_decompressor_options do |invalid_options|
58
58
  assert_raises ValidateError do
59
- Target.decompress ARCHIVE_PATH, SOURCE_PATH, invalid_options
59
+ target.decompress ARCHIVE_PATH, SOURCE_PATH, invalid_options
60
60
  end
61
61
  end
62
62
  end
@@ -68,10 +68,10 @@ module ADSP
68
68
 
69
69
  TEXTS.each do |text|
70
70
  ::File.write source_path, text, :mode => "wb"
71
- Target.compress source_path, archive_path, compressor_options
71
+ target.compress source_path, archive_path, compressor_options
72
72
 
73
73
  get_compatible_decompressor_options compressor_options do |decompressor_options|
74
- Target.decompress archive_path, source_path, decompressor_options
74
+ target.decompress archive_path, source_path, decompressor_options
75
75
 
76
76
  decompressed_text = ::File.read source_path, :mode => "rb"
77
77
  decompressed_text.force_encoding text.encoding
@@ -88,8 +88,8 @@ module ADSP
88
88
  archive_path = Common.get_path ARCHIVE_PATH, worker_index
89
89
 
90
90
  ::File.write source_path, text, :mode => "wb"
91
- Target.compress source_path, archive_path
92
- Target.decompress archive_path, source_path
91
+ target.compress source_path, archive_path
92
+ target.decompress archive_path, source_path
93
93
 
94
94
  decompressed_text = ::File.read source_path, :mode => "rb"
95
95
  decompressed_text.force_encoding text.encoding
@@ -101,19 +101,27 @@ module ADSP
101
101
  # -----
102
102
 
103
103
  def get_invalid_compressor_options(&block)
104
- self.class::Option.get_invalid_compressor_options BUFFER_LENGTH_NAMES, &block
104
+ option.get_invalid_compressor_options BUFFER_LENGTH_NAMES, &block
105
105
  end
106
106
 
107
107
  def get_invalid_decompressor_options(&block)
108
- self.class::Option.get_invalid_decompressor_options BUFFER_LENGTH_NAMES, &block
108
+ option.get_invalid_decompressor_options BUFFER_LENGTH_NAMES, &block
109
109
  end
110
110
 
111
111
  def parallel_compressor_options(&block)
112
- Common.parallel_options self.class::Option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
112
+ Common.parallel_options option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
113
113
  end
114
114
 
115
115
  def get_compatible_decompressor_options(compressor_options, &block)
116
- self.class::Option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
116
+ option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
117
+ end
118
+
119
+ protected def target
120
+ self.class::Target
121
+ end
122
+
123
+ protected def option
124
+ self.class::Option
117
125
  end
118
126
  end
119
127
  end
@@ -1,6 +1,8 @@
1
1
  # Abstract data stream processor.
2
2
  # Copyright (c) 2021 AUTHORS, MIT License.
3
3
 
4
+ require "stringio"
5
+
4
6
  require_relative "abstract"
5
7
  require_relative "../../common"
6
8
  require_relative "../../mock/stream/raw/compressor"
@@ -16,6 +18,7 @@ module ADSP
16
18
  # ADSP::Test::Stream::Raw::Compressor class.
17
19
  class Compressor < Abstract
18
20
  Target = Mock::Stream::Raw::Compressor
21
+ Option = Test::Option
19
22
  String = Mock::String
20
23
 
21
24
  TEXTS = Common::TEXTS
@@ -29,13 +32,13 @@ module ADSP
29
32
  def test_invalid_initialize
30
33
  get_invalid_compressor_options do |invalid_options|
31
34
  assert_raises ValidateError do
32
- Target.new invalid_options
35
+ target.new invalid_options
33
36
  end
34
37
  end
35
38
  end
36
39
 
37
40
  def test_invalid_write
38
- compressor = Target.new
41
+ compressor = target.new
39
42
 
40
43
  Validation::INVALID_STRINGS.each do |invalid_string|
41
44
  assert_raises ValidateError do
@@ -62,7 +65,7 @@ module ADSP
62
65
  compressed_buffer.set_encoding ::Encoding::BINARY
63
66
 
64
67
  writer = proc { |portion| compressed_buffer << portion }
65
- compressor = Target.new compressor_options
68
+ compressor = target.new compressor_options
66
69
 
67
70
  begin
68
71
  source = "".b
@@ -116,7 +119,7 @@ module ADSP
116
119
  compressed_buffer.set_encoding ::Encoding::BINARY
117
120
 
118
121
  writer = proc { |portion| compressed_buffer << portion }
119
- compressor = Target.new
122
+ compressor = target.new
120
123
 
121
124
  begin
122
125
  source = "".b
@@ -148,15 +151,19 @@ module ADSP
148
151
  # -----
149
152
 
150
153
  def get_invalid_compressor_options(&block)
151
- Option.get_invalid_compressor_options BUFFER_LENGTH_NAMES, &block
154
+ option.get_invalid_compressor_options BUFFER_LENGTH_NAMES, &block
152
155
  end
153
156
 
154
157
  def parallel_compressor_options(&block)
155
- Common.parallel_options Option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
158
+ Common.parallel_options option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
156
159
  end
157
160
 
158
161
  def get_compatible_decompressor_options(compressor_options, &block)
159
- Option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
162
+ option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
163
+ end
164
+
165
+ def option
166
+ self.class::Option
160
167
  end
161
168
  end
162
169
  end
@@ -1,6 +1,8 @@
1
1
  # Abstract data stream processor.
2
2
  # Copyright (c) 2021 AUTHORS, MIT License.
3
3
 
4
+ require "stringio"
5
+
4
6
  require_relative "abstract"
5
7
  require_relative "../../common"
6
8
  require_relative "../../mock/stream/raw/decompressor"
@@ -16,6 +18,7 @@ module ADSP
16
18
  # ADSP::Test::Stream::Raw::Decompressor class.
17
19
  class Decompressor < Abstract
18
20
  Target = Mock::Stream::Raw::Decompressor
21
+ Option = Test::Option
19
22
  String = Mock::String
20
23
 
21
24
  TEXTS = Common::TEXTS
@@ -29,13 +32,13 @@ module ADSP
29
32
  def test_invalid_initialize
30
33
  get_invalid_decompressor_options do |invalid_options|
31
34
  assert_raises ValidateError do
32
- Target.new invalid_options
35
+ target.new invalid_options
33
36
  end
34
37
  end
35
38
  end
36
39
 
37
40
  def test_invalid_read
38
- decompressor = Target.new
41
+ decompressor = target.new
39
42
 
40
43
  Validation::INVALID_STRINGS.each do |invalid_string|
41
44
  assert_raises ValidateError do
@@ -65,7 +68,7 @@ module ADSP
65
68
  decompressed_buffer.set_encoding ::Encoding::BINARY
66
69
 
67
70
  writer = proc { |portion| decompressed_buffer << portion }
68
- decompressor = Target.new decompressor_options
71
+ decompressor = target.new decompressor_options
69
72
 
70
73
  begin
71
74
  source = "".b
@@ -118,7 +121,7 @@ module ADSP
118
121
  decompressed_buffer.set_encoding ::Encoding::BINARY
119
122
 
120
123
  writer = proc { |portion| decompressed_buffer << portion }
121
- decompressor = Target.new
124
+ decompressor = target.new
122
125
 
123
126
  begin
124
127
  source = "".b
@@ -148,15 +151,19 @@ module ADSP
148
151
  # -----
149
152
 
150
153
  def get_invalid_decompressor_options(&block)
151
- Option.get_invalid_decompressor_options BUFFER_LENGTH_NAMES, &block
154
+ option.get_invalid_decompressor_options BUFFER_LENGTH_NAMES, &block
152
155
  end
153
156
 
154
157
  def parallel_compressor_options(&block)
155
- Common.parallel_options Option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
158
+ Common.parallel_options option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
156
159
  end
157
160
 
158
161
  def get_compatible_decompressor_options(compressor_options, &block)
159
- Option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
162
+ option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
163
+ end
164
+
165
+ def option
166
+ self.class::Option
160
167
  end
161
168
  end
162
169
  end
@@ -19,6 +19,7 @@ module ADSP
19
19
  # ADSP::Test::Stream::Reader class.
20
20
  class Reader < Abstract
21
21
  Target = Mock::Stream::Reader
22
+ Option = Test::Option
22
23
  String = Mock::String
23
24
 
24
25
  ARCHIVE_PATH = Common::ARCHIVE_PATH
@@ -329,7 +330,7 @@ module ADSP
329
330
  end
330
331
 
331
332
  def test_eof
332
- compressed_text = String.compress "ab"
333
+ compressed_text = string.compress "ab"
333
334
  instance = target.new ::StringIO.new(compressed_text)
334
335
 
335
336
  refute_predicate instance, :eof?
@@ -580,7 +581,7 @@ module ADSP
580
581
 
581
582
  protected def nonblock_test(server, text, portion_length, compressor_options = {}, &_block)
582
583
  port = server.addr[1]
583
- compressed_text = String.compress text, compressor_options
584
+ compressed_text = string.compress text, compressor_options
584
585
 
585
586
  processor = proc do |decompressor_options|
586
587
  decompressed_text = ::TCPSocket.open "localhost", port do |socket|
@@ -617,24 +618,32 @@ module ADSP
617
618
  # -----
618
619
 
619
620
  protected def get_archive(text, compressor_options = {})
620
- String.compress text, compressor_options
621
+ string.compress text, compressor_options
621
622
  end
622
623
 
623
624
  protected def write_archive(archive_path, text, compressor_options = {})
624
- compressed_text = String.compress text, compressor_options
625
+ compressed_text = string.compress text, compressor_options
625
626
  ::File.write archive_path, compressed_text, :mode => "wb"
626
627
  end
627
628
 
628
629
  def get_invalid_decompressor_options(&block)
629
- Option.get_invalid_decompressor_options BUFFER_LENGTH_NAMES, &block
630
+ option.get_invalid_decompressor_options BUFFER_LENGTH_NAMES, &block
630
631
  end
631
632
 
632
633
  def parallel_compressor_options(&block)
633
- Common.parallel_options Option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
634
+ Common.parallel_options option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
634
635
  end
635
636
 
636
637
  def get_compatible_decompressor_options(compressor_options, &block)
637
- Option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
638
+ option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
639
+ end
640
+
641
+ def option
642
+ self.class::Option
643
+ end
644
+
645
+ def string
646
+ self.class::String
638
647
  end
639
648
  end
640
649
  end
@@ -18,6 +18,7 @@ module ADSP
18
18
  # ADSP::Test::Stream::ReaderHelpers class.
19
19
  class ReaderHelpers < Minitest::Test
20
20
  Target = Mock::Stream::Reader
21
+ Option = Test::Option
21
22
  String = Mock::String
22
23
 
23
24
  ARCHIVE_PATH = Common::ARCHIVE_PATH
@@ -53,7 +54,7 @@ module ADSP
53
54
  write_archive archive_path, text, compressor_options
54
55
 
55
56
  get_compatible_decompressor_options compressor_options do |decompressor_options|
56
- Target.open archive_path, decompressor_options do |instance|
57
+ target.open archive_path, decompressor_options do |instance|
57
58
  # getbyte
58
59
 
59
60
  byte = instance.getbyte
@@ -101,7 +102,7 @@ module ADSP
101
102
  write_archive archive_path, text, compressor_options
102
103
 
103
104
  get_compatible_decompressor_options compressor_options do |decompressor_options|
104
- Target.open archive_path, decompressor_options do |instance|
105
+ target.open archive_path, decompressor_options do |instance|
105
106
  # getc
106
107
 
107
108
  char = instance.getc
@@ -142,7 +143,7 @@ module ADSP
142
143
  target_text = text.encode internal_encoding, **TRANSCODE_OPTIONS
143
144
 
144
145
  get_compatible_decompressor_options compressor_options do |decompressor_options|
145
- Target.open archive_path, decompressor_options do |instance|
146
+ target.open archive_path, decompressor_options do |instance|
146
147
  instance.set_encoding external_encoding, internal_encoding, TRANSCODE_OPTIONS
147
148
 
148
149
  # getc
@@ -225,7 +226,7 @@ module ADSP
225
226
  end
226
227
 
227
228
  get_compatible_decompressor_options compressor_options do |decompressor_options|
228
- Target.open archive_path, decompressor_options do |instance|
229
+ target.open archive_path, decompressor_options do |instance|
229
230
  # lineno
230
231
 
231
232
  assert_equal 0, instance.lineno
@@ -313,7 +314,7 @@ module ADSP
313
314
  end
314
315
 
315
316
  get_compatible_decompressor_options compressor_options do |decompressor_options|
316
- Target.open archive_path, decompressor_options do |instance|
317
+ target.open archive_path, decompressor_options do |instance|
317
318
  instance.set_encoding external_encoding, internal_encoding, TRANSCODE_OPTIONS
318
319
 
319
320
  # gets
@@ -358,13 +359,13 @@ module ADSP
358
359
  def test_invalid_open
359
360
  Validation::INVALID_STRINGS.each do |invalid_string|
360
361
  assert_raises ValidateError do
361
- Target.open(invalid_string) {} # no-op
362
+ target.open(invalid_string) {} # no-op
362
363
  end
363
364
  end
364
365
 
365
366
  # Proc is required.
366
367
  assert_raises ValidateError do
367
- Target.open ARCHIVE_PATH
368
+ target.open ARCHIVE_PATH
368
369
  end
369
370
  end
370
371
 
@@ -376,7 +377,7 @@ module ADSP
376
377
  write_archive archive_path, text, compressor_options
377
378
 
378
379
  get_compatible_decompressor_options compressor_options do |decompressor_options|
379
- decompressed_text = Target.open archive_path, decompressor_options, &:read
380
+ decompressed_text = target.open archive_path, decompressor_options, &:read
380
381
  decompressed_text.force_encoding text.encoding
381
382
 
382
383
  assert_equal text, decompressed_text
@@ -390,7 +391,7 @@ module ADSP
390
391
  archive_path = Common.get_path ARCHIVE_PATH, worker_index
391
392
  write_archive archive_path, text
392
393
 
393
- decompressed_text = Target.open archive_path, &:read
394
+ decompressed_text = target.open archive_path, &:read
394
395
  decompressed_text.force_encoding text.encoding
395
396
 
396
397
  assert_equal text, decompressed_text
@@ -400,21 +401,29 @@ module ADSP
400
401
  # -----
401
402
 
402
403
  protected def write_archive(archive_path, text, compressor_options = {})
403
- compressed_text = String.compress text, compressor_options
404
+ compressed_text = string.compress text, compressor_options
404
405
  ::File.write archive_path, compressed_text, :mode => "wb"
405
406
  end
406
407
 
407
408
  def parallel_compressor_options(&block)
408
- Common.parallel_options Option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
409
+ Common.parallel_options option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
409
410
  end
410
411
 
411
412
  def get_compatible_decompressor_options(compressor_options, &block)
412
- Option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
413
+ option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
413
414
  end
414
415
 
415
416
  protected def target
416
417
  self.class::Target
417
418
  end
419
+
420
+ protected def option
421
+ self.class::Option
422
+ end
423
+
424
+ protected def string
425
+ self.class::String
426
+ end
418
427
  end
419
428
  end
420
429
  end
@@ -18,6 +18,7 @@ module ADSP
18
18
  # ADSP::Test::Stream::Writer class.
19
19
  class Writer < Abstract
20
20
  Target = Mock::Stream::Writer
21
+ Option = Test::Option
21
22
  String = Mock::String
22
23
 
23
24
  ARCHIVE_PATH = Common::ARCHIVE_PATH
@@ -586,22 +587,30 @@ module ADSP
586
587
  end
587
588
 
588
589
  protected def check_text(text, compressed_text, decompressor_options = {})
589
- decompressed_text = String.decompress compressed_text, decompressor_options
590
+ decompressed_text = string.decompress compressed_text, decompressor_options
590
591
  decompressed_text.force_encoding text.encoding
591
592
 
592
593
  assert_equal text, decompressed_text
593
594
  end
594
595
 
595
596
  def get_invalid_compressor_options(&block)
596
- Option.get_invalid_compressor_options BUFFER_LENGTH_NAMES, &block
597
+ option.get_invalid_compressor_options BUFFER_LENGTH_NAMES, &block
597
598
  end
598
599
 
599
600
  def parallel_compressor_options(&block)
600
- Common.parallel_options Option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
601
+ Common.parallel_options option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
601
602
  end
602
603
 
603
604
  def get_compatible_decompressor_options(compressor_options, &block)
604
- Option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
605
+ option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
606
+ end
607
+
608
+ protected def option
609
+ self.class::Option
610
+ end
611
+
612
+ protected def string
613
+ self.class::String
605
614
  end
606
615
  end
607
616
  end
@@ -18,6 +18,7 @@ module ADSP
18
18
  # ADSP::Test::Stream::WriterHelpers class.
19
19
  class WriterHelpers < Minitest::Test
20
20
  Target = Mock::Stream::Writer
21
+ Option = Test::Option
21
22
  String = Mock::String
22
23
 
23
24
  ARCHIVE_PATH = Common::ARCHIVE_PATH
@@ -37,7 +38,7 @@ module ADSP
37
38
  PORTION_LENGTHS.each do |portion_length|
38
39
  sources = get_sources text, portion_length
39
40
 
40
- Target.open archive_path, compressor_options do |instance|
41
+ target.open archive_path, compressor_options do |instance|
41
42
  sources.each { |current_source| instance << current_source }
42
43
  end
43
44
 
@@ -65,7 +66,7 @@ module ADSP
65
66
  sources.each { |source| target_text << (source + field_separator) }
66
67
  target_text << record_separator
67
68
 
68
- Target.open archive_path, compressor_options do |instance|
69
+ target.open archive_path, compressor_options do |instance|
69
70
  keyword_args = { :field_separator => field_separator, :record_separator => record_separator }
70
71
  instance.print(*sources, **keyword_args)
71
72
  end
@@ -88,7 +89,7 @@ module ADSP
88
89
  PORTION_LENGTHS.each do |portion_length|
89
90
  sources = get_sources text, portion_length
90
91
 
91
- Target.open archive_path, compressor_options do |instance|
92
+ target.open archive_path, compressor_options do |instance|
92
93
  sources.each { |source| instance.printf "%s", source }
93
94
  end
94
95
 
@@ -117,7 +118,7 @@ module ADSP
117
118
  archive_path = Common.get_path ARCHIVE_PATH, worker_index
118
119
 
119
120
  TEXTS.each do |text|
120
- Target.open archive_path, compressor_options do |instance|
121
+ target.open archive_path, compressor_options do |instance|
121
122
  # Putc should process numbers and strings.
122
123
  text.chars.each.with_index do |char, index|
123
124
  if index.even?
@@ -154,7 +155,7 @@ module ADSP
154
155
  target_text = "".encode text.encoding
155
156
  sources.each { |source| target_text << (source + newline) }
156
157
 
157
- Target.open archive_path, compressor_options do |instance|
158
+ target.open archive_path, compressor_options do |instance|
158
159
  # Puts should ignore additional newlines and process arrays.
159
160
  args = sources.map.with_index do |source, index|
160
161
  if index.even?
@@ -180,13 +181,13 @@ module ADSP
180
181
  def test_invalid_open
181
182
  Validation::INVALID_STRINGS.each do |invalid_string|
182
183
  assert_raises ValidateError do
183
- Target.open(invalid_string) {} # no-op
184
+ target.open(invalid_string) {} # no-op
184
185
  end
185
186
  end
186
187
 
187
188
  # Proc is required.
188
189
  assert_raises ValidateError do
189
- Target.open ARCHIVE_PATH
190
+ target.open ARCHIVE_PATH
190
191
  end
191
192
  end
192
193
 
@@ -195,7 +196,7 @@ module ADSP
195
196
  archive_path = Common.get_path ARCHIVE_PATH, worker_index
196
197
 
197
198
  TEXTS.each do |text|
198
- Target.open(archive_path, compressor_options) { |instance| instance.write text }
199
+ target.open(archive_path, compressor_options) { |instance| instance.write text }
199
200
 
200
201
  compressed_text = ::File.read archive_path, :mode => "rb"
201
202
 
@@ -220,7 +221,7 @@ module ADSP
220
221
 
221
222
  sources = get_sources text, portion_length
222
223
 
223
- Target.open archive_path do |instance|
224
+ target.open archive_path do |instance|
224
225
  sources.each { |source| instance.write source }
225
226
  end
226
227
 
@@ -244,23 +245,31 @@ module ADSP
244
245
  end
245
246
 
246
247
  protected def check_text(text, compressed_text, decompressor_options)
247
- decompressed_text = String.decompress compressed_text, decompressor_options
248
+ decompressed_text = string.decompress compressed_text, decompressor_options
248
249
  decompressed_text.force_encoding text.encoding
249
250
 
250
251
  assert_equal text, decompressed_text
251
252
  end
252
253
 
253
254
  def parallel_compressor_options(&block)
254
- Common.parallel_options Option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
255
+ Common.parallel_options option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
255
256
  end
256
257
 
257
258
  def get_compatible_decompressor_options(compressor_options, &block)
258
- Option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
259
+ option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
259
260
  end
260
261
 
261
262
  protected def target
262
263
  self.class::Target
263
264
  end
265
+
266
+ protected def option
267
+ self.class::Option
268
+ end
269
+
270
+ protected def string
271
+ self.class::String
272
+ end
264
273
  end
265
274
  end
266
275
  end
@@ -14,8 +14,8 @@ module ADSP
14
14
  module Test
15
15
  # ADSP::Test::String class.
16
16
  class String < Minitest::Test
17
- Option = Test::Option
18
17
  Target = Mock::String
18
+ Option = Test::Option
19
19
 
20
20
  TEXTS = Common::TEXTS
21
21
  LARGE_TEXTS = Common::LARGE_TEXTS
@@ -26,23 +26,23 @@ module ADSP
26
26
  def test_invalid_arguments
27
27
  Validation::INVALID_STRINGS.each do |invalid_string|
28
28
  assert_raises ValidateError do
29
- Target.compress invalid_string
29
+ target.compress invalid_string
30
30
  end
31
31
 
32
32
  assert_raises ValidateError do
33
- Target.decompress invalid_string
33
+ target.decompress invalid_string
34
34
  end
35
35
  end
36
36
 
37
37
  get_invalid_compressor_options do |invalid_options|
38
38
  assert_raises ValidateError do
39
- Target.compress "", invalid_options
39
+ target.compress "", invalid_options
40
40
  end
41
41
  end
42
42
 
43
43
  get_invalid_decompressor_options do |invalid_options|
44
44
  assert_raises ValidateError do
45
- Target.decompress "", invalid_options
45
+ target.decompress "", invalid_options
46
46
  end
47
47
  end
48
48
  end
@@ -50,10 +50,10 @@ module ADSP
50
50
  def test_texts
51
51
  parallel_compressor_options do |compressor_options|
52
52
  TEXTS.each do |text|
53
- compressed_text = Target.compress text, compressor_options
53
+ compressed_text = target.compress text, compressor_options
54
54
 
55
55
  get_compatible_decompressor_options compressor_options do |decompressor_options|
56
- decompressed_text = Target.decompress compressed_text, decompressor_options
56
+ decompressed_text = target.decompress compressed_text, decompressor_options
57
57
  decompressed_text.force_encoding text.encoding
58
58
 
59
59
  assert_equal text, decompressed_text
@@ -64,9 +64,9 @@ module ADSP
64
64
 
65
65
  def test_large_texts
66
66
  Common.parallel LARGE_TEXTS do |text|
67
- compressed_text = Target.compress text
67
+ compressed_text = target.compress text
68
68
 
69
- decompressed_text = Target.decompress compressed_text
69
+ decompressed_text = target.decompress compressed_text
70
70
  decompressed_text.force_encoding text.encoding
71
71
 
72
72
  assert_equal text, decompressed_text
@@ -76,19 +76,27 @@ module ADSP
76
76
  # -----
77
77
 
78
78
  def get_invalid_compressor_options(&block)
79
- self.class::Option.get_invalid_compressor_options BUFFER_LENGTH_NAMES, &block
79
+ option.get_invalid_compressor_options BUFFER_LENGTH_NAMES, &block
80
80
  end
81
81
 
82
82
  def get_invalid_decompressor_options(&block)
83
- self.class::Option.get_invalid_decompressor_options BUFFER_LENGTH_NAMES, &block
83
+ option.get_invalid_decompressor_options BUFFER_LENGTH_NAMES, &block
84
84
  end
85
85
 
86
86
  def parallel_compressor_options(&block)
87
- Common.parallel_options self.class::Option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
87
+ Common.parallel_options option.get_compressor_options_generator(BUFFER_LENGTH_NAMES), &block
88
88
  end
89
89
 
90
90
  def get_compatible_decompressor_options(compressor_options, &block)
91
- self.class::Option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
91
+ option.get_compatible_decompressor_options compressor_options, BUFFER_LENGTH_MAPPING, &block
92
+ end
93
+
94
+ protected def target
95
+ self.class::Target
96
+ end
97
+
98
+ protected def option
99
+ self.class::Option
92
100
  end
93
101
  end
94
102
  end
data/lib/adsp/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
 
4
4
  module ADSP
5
5
  # Abstract data stream processor version.
6
- VERSION = "1.0.6".freeze
6
+ VERSION = "1.0.9".freeze
7
7
  end
@@ -13,6 +13,8 @@ if ENV["CI"]
13
13
  )
14
14
 
15
15
  SimpleCov.start do
16
- add_filter %r{^/test/}
16
+ track_files "lib/*.rb"
17
+ track_files "lib/adsp/*.rb"
18
+ track_files "lib/adsp/stream/**/*.rb"
17
19
  end
18
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adsp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Aladjev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-04 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codecov
@@ -219,7 +219,6 @@ files:
219
219
  - lib/adsp/stream/writer_helpers.rb
220
220
  - lib/adsp/string.rb
221
221
  - lib/adsp/test/common.rb
222
- - lib/adsp/test/coverage_helper.rb
223
222
  - lib/adsp/test/file.rb
224
223
  - lib/adsp/test/minitest.rb
225
224
  - lib/adsp/test/mock/common.rb
@@ -246,6 +245,7 @@ files:
246
245
  - lib/adsp/test/version.rb
247
246
  - lib/adsp/validation.rb
248
247
  - lib/adsp/version.rb
248
+ - test/coverage_helper.rb
249
249
  - test/file.test.rb
250
250
  - test/stream/minitar.test.rb
251
251
  - test/stream/raw/compressor.test.rb