iostreams 1.10.2 → 1.10.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26d07bc98819ce065e8c698f00b75a6c2e9fc0a9ea6bf13c1afa8bc8c1e71e66
4
- data.tar.gz: 2f7898b4197d3f94cbfcc30ba6c8d23e72121877833e57ec9a989e465d019ca2
3
+ metadata.gz: 30ace4685022c88754654b2b48d1c86185e47841f1d3c6a3916bc348098b178d
4
+ data.tar.gz: 040c669d7ad4521941a3752dc405390c4f7dda98a583cc0f5d923091e12bd452
5
5
  SHA512:
6
- metadata.gz: 2887fb5b2935d28bcf2426fd7139a6b7a27c87c1da8d7289cc69f0a644c2d98e4667f6e6da1a57133bcf8bdd93e948d7819d24ce09cb0d65f6c35d59b0b604c7
7
- data.tar.gz: 034aa07ff80107a139dd86ffd492361887de4f4e8190385b48d12b1bedeb0a3af8c1a25720d41f731330cb46d707736972c707c3ec5576551425d29d3843da68
6
+ metadata.gz: 90f2635d2e443fe4c4f3992d8f92a725118b2f52c0d4861ee1d778be8f145d93c2f0663904f8cf699b33106a154d13980634881a0039c7e0ad6389d137d69760
7
+ data.tar.gz: 970da1fd8e3b6ea7e1b36dad476c7f842413c2b8b50dc2939802b1962c00347bcdfa6a135245550c9cb639b694e9ca2c16439bde1afe7677701f3867cdc277e4
@@ -1,3 +1,3 @@
1
1
  module IOStreams
2
- VERSION = "1.10.2".freeze
2
+ VERSION = "1.10.3".freeze
3
3
  end
@@ -14,7 +14,7 @@ module IOStreams
14
14
  # Name of the file entry within the Zip file.
15
15
  #
16
16
  # The stream supplied to the block only responds to #write
17
- def self.stream(output_stream, original_file_name: nil, zip_file_name: nil, entry_file_name: zip_file_name, &block)
17
+ def self.stream(output_stream, original_file_name: nil, zip_file_name: nil, entry_file_name: zip_file_name)
18
18
  # Default the name of the file within the zip to the supplied file_name without the zip extension
19
19
  if entry_file_name.nil? && original_file_name && (original_file_name =~ /\.(zip)\z/i)
20
20
  entry_file_name = original_file_name.to_s[0..-5]
@@ -23,7 +23,11 @@ module IOStreams
23
23
 
24
24
  Utils.load_soft_dependency("zip_tricks", "Zip") unless defined?(ZipTricks::Streamer)
25
25
 
26
- ZipTricks::Streamer.open(output_stream) { |zip| zip.write_deflated_file(entry_file_name, &block) }
26
+ result = nil
27
+ ZipTricks::Streamer.open(output_stream) do |zip|
28
+ zip.write_deflated_file(entry_file_name) { |io| result = yield(io) }
29
+ end
30
+ result
27
31
  end
28
32
  end
29
33
  end
@@ -20,10 +20,13 @@ class Bzip2WriterTest < Minitest::Test
20
20
 
21
21
  describe ".file" do
22
22
  it "file" do
23
- IOStreams::Bzip2::Writer.file(file_name) do |io|
24
- io.write(decompressed)
25
- io.write(decompressed)
26
- end
23
+ result =
24
+ IOStreams::Bzip2::Writer.file(file_name) do |io|
25
+ io.write(decompressed)
26
+ io.write(decompressed)
27
+ 53534
28
+ end
29
+ assert_equal 53534, result
27
30
 
28
31
  File.open(file_name, "rb") do |file|
29
32
  io = ::Bzip2::FFI::Reader.new(file)
@@ -35,10 +38,13 @@ class Bzip2WriterTest < Minitest::Test
35
38
 
36
39
  it "stream" do
37
40
  io_string = StringIO.new("".b)
38
- IOStreams::Bzip2::Writer.stream(io_string) do |io|
39
- io.write(decompressed)
40
- io.write(decompressed)
41
- end
41
+ result =
42
+ IOStreams::Bzip2::Writer.stream(io_string) do |io|
43
+ io.write(decompressed)
44
+ io.write(decompressed)
45
+ 53534
46
+ end
47
+ assert_equal 53534, result
42
48
 
43
49
  io = StringIO.new(io_string.string)
44
50
  rbzip2 = ::Bzip2::FFI::Reader.new(io)
@@ -22,18 +22,24 @@ class EncodeWriterTest < Minitest::Test
22
22
  it "file" do
23
23
  temp_file = Tempfile.new("rocket_job")
24
24
  file_name = temp_file.to_path
25
- IOStreams::Encode::Writer.file(file_name, encoding: "ASCII-8BIT") do |io|
26
- io << bad_data
27
- end
25
+ result =
26
+ IOStreams::Encode::Writer.file(file_name, encoding: "ASCII-8BIT") do |io|
27
+ io << bad_data
28
+ 53534
29
+ end
30
+ assert_equal 53534, result
28
31
  result = File.read(file_name, mode: "rb")
29
32
  assert_equal bad_data, result
30
33
  end
31
34
 
32
35
  it "stream" do
33
- io = StringIO.new("".b)
34
- IOStreams::Encode::Writer.stream(io, encoding: "ASCII-8BIT") do |encoded|
35
- encoded << bad_data
36
- end
36
+ io = StringIO.new("".b)
37
+ result =
38
+ IOStreams::Encode::Writer.stream(io, encoding: "ASCII-8BIT") do |encoded|
39
+ encoded << bad_data
40
+ 53534
41
+ end
42
+ assert_equal 53534, result
37
43
  assert_equal "ASCII-8BIT", io.string.encoding.to_s
38
44
  assert_equal bad_data, io.string
39
45
  end
@@ -70,9 +76,12 @@ class EncodeWriterTest < Minitest::Test
70
76
  it "returns byte count" do
71
77
  io_string = StringIO.new("".b)
72
78
  count = 0
73
- IOStreams::Encode::Writer.stream(io_string, encoding: "ASCII-8BIT") do |io|
74
- count += io.write(bad_data)
75
- end
79
+ result =
80
+ IOStreams::Encode::Writer.stream(io_string, encoding: "ASCII-8BIT") do |io|
81
+ count += io.write(bad_data)
82
+ 53534
83
+ end
84
+ assert_equal 53534, result
76
85
  assert_equal bad_data, io_string.string
77
86
  assert_equal bad_data.size, count
78
87
  end
@@ -20,9 +20,13 @@ class GzipWriterTest < Minitest::Test
20
20
 
21
21
  describe ".file" do
22
22
  it "file" do
23
- IOStreams::Gzip::Writer.file(file_name) do |io|
24
- io.write(decompressed)
25
- end
23
+ result =
24
+ IOStreams::Gzip::Writer.file(file_name) do |io|
25
+ io.write(decompressed)
26
+ 53534
27
+ end
28
+ assert_equal 53534, result
29
+
26
30
  result = Zlib::GzipReader.open(file_name, &:read)
27
31
  temp_file.delete
28
32
  assert_equal decompressed, result
@@ -30,11 +34,15 @@ class GzipWriterTest < Minitest::Test
30
34
 
31
35
  it "stream" do
32
36
  io_string = StringIO.new("".b)
33
- IOStreams::Gzip::Writer.stream(io_string) do |io|
34
- io.write(decompressed)
35
- end
36
- io = StringIO.new(io_string.string)
37
- gz = Zlib::GzipReader.new(io)
37
+ result =
38
+ IOStreams::Gzip::Writer.stream(io_string) do |io|
39
+ io.write(decompressed)
40
+ 53534
41
+ end
42
+ assert_equal 53534, result
43
+
44
+ io = StringIO.new(io_string.string)
45
+ gz = Zlib::GzipReader.new(io)
38
46
  data = gz.read
39
47
  gz.close
40
48
  assert_equal decompressed, data
@@ -18,18 +18,25 @@ class DelimitedWriterTest < Minitest::Test
18
18
  it "file" do
19
19
  temp_file = Tempfile.new("rocket_job")
20
20
  file_name = temp_file.to_path
21
- IOStreams::Line::Writer.file(file_name) do |io|
22
- lines.each { |line| io << line }
23
- end
21
+ result =
22
+ IOStreams::Line::Writer.file(file_name) do |io|
23
+ lines.each { |line| io << line }
24
+ 53534
25
+ end
26
+ assert_equal 53534, result
27
+
24
28
  result = File.read(file_name)
25
29
  assert_equal raw, result
26
30
  end
27
31
 
28
32
  it "stream" do
29
33
  io_string = StringIO.new
30
- IOStreams::Line::Writer.stream(io_string) do |io|
31
- lines.each { |line| io << line }
32
- end
34
+ result =
35
+ IOStreams::Line::Writer.stream(io_string) do |io|
36
+ lines.each { |line| io << line }
37
+ 53534
38
+ end
39
+ assert_equal 53534, result
33
40
  assert_equal raw, io_string.string
34
41
  end
35
42
  end
@@ -38,9 +45,12 @@ class DelimitedWriterTest < Minitest::Test
38
45
  it "returns byte count" do
39
46
  io_string = StringIO.new
40
47
  count = 0
41
- IOStreams::Line::Writer.stream(io_string) do |io|
42
- lines.each { |line| count += io.write(line) }
43
- end
48
+ result =
49
+ IOStreams::Line::Writer.stream(io_string) do |io|
50
+ lines.each { |line| count += io.write(line) }
51
+ 53534
52
+ end
53
+ assert_equal 53534, result
44
54
  assert_equal raw, io_string.string
45
55
  assert_equal raw.size, count
46
56
  end
@@ -21,9 +21,12 @@ class PgpWriterTest < Minitest::Test
21
21
 
22
22
  describe ".file" do
23
23
  it "writes encrypted text file" do
24
- IOStreams::Pgp::Writer.file(file_name, recipient: "receiver@example.org") do |io|
25
- io.write(decrypted)
26
- end
24
+ result =
25
+ IOStreams::Pgp::Writer.file(file_name, recipient: "receiver@example.org") do |io|
26
+ io.write(decrypted)
27
+ 53534
28
+ end
29
+ assert_equal 53534, result
27
30
 
28
31
  result = IOStreams::Pgp::Reader.file(file_name, passphrase: "receiver_passphrase", &:read)
29
32
  assert_equal decrypted, result
@@ -34,9 +37,12 @@ class PgpWriterTest < Minitest::Test
34
37
  binary_data = File.open(binary_file_name, "rb", &:read)
35
38
 
36
39
  File.open(binary_file_name, "rb") do |input|
37
- IOStreams::Pgp::Writer.file(file_name, recipient: "receiver@example.org") do |output|
38
- IO.copy_stream(input, output)
39
- end
40
+ result =
41
+ IOStreams::Pgp::Writer.file(file_name, recipient: "receiver@example.org") do |output|
42
+ IO.copy_stream(input, output)
43
+ 53534
44
+ end
45
+ assert_equal 53534, result
40
46
  end
41
47
 
42
48
  result = IOStreams::Pgp::Reader.file(file_name, passphrase: "receiver_passphrase", &:read)
@@ -108,9 +114,12 @@ class PgpWriterTest < Minitest::Test
108
114
 
109
115
  it "writes to a stream" do
110
116
  io_string = StringIO.new("".b)
111
- IOStreams::Pgp::Writer.stream(io_string, recipient: "receiver@example.org", signer: "sender@example.org", signer_passphrase: "sender_passphrase") do |io|
112
- io.write(decrypted)
113
- end
117
+ result =
118
+ IOStreams::Pgp::Writer.stream(io_string, recipient: "receiver@example.org", signer: "sender@example.org", signer_passphrase: "sender_passphrase") do |io|
119
+ io.write(decrypted)
120
+ 53534
121
+ end
122
+ assert_equal 53534, result
114
123
 
115
124
  io = StringIO.new(io_string.string)
116
125
  result = IOStreams::Pgp::Reader.stream(io, passphrase: "receiver_passphrase", &:read)
@@ -43,28 +43,38 @@ class RecordWriterTest < Minitest::Test
43
43
 
44
44
  describe "#<<" do
45
45
  it "file" do
46
- IOStreams::Record::Writer.file(file_name) do |io|
47
- inputs.each { |hash| io << hash }
48
- end
46
+ result =
47
+ IOStreams::Record::Writer.file(file_name) do |io|
48
+ inputs.each { |hash| io << hash }
49
+ 53534
50
+ end
51
+ assert_equal 53534, result
49
52
  result = File.read(file_name)
50
53
  assert_equal raw_csv_data, result
51
54
  end
52
55
 
53
56
  it "json file" do
54
- IOStreams::Record::Writer.file(file_name, file_name: "abc.json") do |io|
55
- inputs.each { |hash| io << hash }
56
- end
57
+ result =
58
+ IOStreams::Record::Writer.file(file_name, file_name: "abc.json") do |io|
59
+ inputs.each { |hash| io << hash }
60
+ 53534
61
+ end
62
+ assert_equal 53534, result
63
+
57
64
  result = File.read(file_name)
58
65
  assert_equal raw_json_data, result
59
66
  end
60
67
 
61
68
  it "stream" do
62
69
  io_string = StringIO.new
63
- IOStreams::Line::Writer.stream(io_string) do |io|
64
- IOStreams::Record::Writer.stream(io) do |stream|
65
- inputs.each { |row| stream << row }
70
+ result =
71
+ IOStreams::Line::Writer.stream(io_string) do |io|
72
+ IOStreams::Record::Writer.stream(io) do |stream|
73
+ inputs.each { |row| stream << row }
74
+ 53534
75
+ end
66
76
  end
67
- end
77
+ assert_equal 53534, result
68
78
  assert_equal raw_csv_data, io_string.string
69
79
  end
70
80
  end
@@ -29,20 +29,26 @@ class RowWriterTest < Minitest::Test
29
29
 
30
30
  describe ".stream" do
31
31
  it "file" do
32
- IOStreams::Row::Writer.file(file_name) do |io|
33
- csv_rows.each { |array| io << array }
34
- end
32
+ result =
33
+ IOStreams::Row::Writer.file(file_name) do |io|
34
+ csv_rows.each { |array| io << array }
35
+ 53534
36
+ end
37
+ assert_equal 53534, result
35
38
  result = ::File.read(file_name)
36
39
  assert_equal raw_csv_data, result
37
40
  end
38
41
 
39
42
  it "streams" do
40
43
  io_string = StringIO.new
41
- IOStreams::Line::Writer.stream(io_string) do |io|
42
- IOStreams::Row::Writer.stream(io) do |stream|
43
- csv_rows.each { |array| stream << array }
44
+ result =
45
+ IOStreams::Line::Writer.stream(io_string) do |io|
46
+ IOStreams::Row::Writer.stream(io) do |stream|
47
+ csv_rows.each { |array| stream << array }
48
+ 53534
49
+ end
44
50
  end
45
- end
51
+ assert_equal 53534, result
46
52
  assert_equal raw_csv_data, io_string.string
47
53
  end
48
54
  end
@@ -21,19 +21,25 @@ class ZipWriterTest < Minitest::Test
21
21
 
22
22
  describe ".file" do
23
23
  it "file" do
24
- IOStreams::Zip::Writer.file(file_name, entry_file_name: "text.txt") do |io|
25
- io.write(decompressed)
26
- end
24
+ result =
25
+ IOStreams::Zip::Writer.file(file_name, entry_file_name: "text.txt") do |io|
26
+ io.write(decompressed)
27
+ 53534
28
+ end
29
+ assert_equal 53534, result
27
30
  result = IOStreams::Zip::Reader.file(file_name, &:read)
28
31
  assert_equal decompressed, result
29
32
  end
30
33
 
31
34
  it "stream" do
32
35
  io_string = StringIO.new("".b)
33
- IOStreams::Zip::Writer.stream(io_string) do |io|
34
- io.write(decompressed)
35
- end
36
- io = StringIO.new(io_string.string)
36
+ result =
37
+ IOStreams::Zip::Writer.stream(io_string) do |io|
38
+ io.write(decompressed)
39
+ 53534
40
+ end
41
+ assert_equal 53534, result
42
+ io = StringIO.new(io_string.string)
37
43
  result = IOStreams::Zip::Reader.stream(io, &:read)
38
44
  assert_equal decompressed, result
39
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iostreams
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.2
4
+ version: 1.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-25 00:00:00.000000000 Z
11
+ date: 2021-10-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: