iostreams 1.8.0 → 1.9.0
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/io_streams/builder.rb +20 -7
- data/lib/io_streams/stream.rb +8 -0
- data/lib/io_streams/version.rb +1 -1
- data/test/builder_test.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 410a7bdcec2ee16f130bbb7010bfd2258975253c1bd380c1832f034ae18b2979
|
4
|
+
data.tar.gz: 6f8e7bd896166b10a77477a95a0eae88b742a117525d48c10fd23952fa37faa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85a53eae7c90affdfcd577836d83533d75eff5eb8e880352c6890d4805c219b91e99fc1d936cc72829dbe93d6b8ea55585cc0a2b3a1c8886ab2b261e7c078cb7
|
7
|
+
data.tar.gz: 5bd17a2bae394ca10a84f659fe1e0aac8315ab393cfe11e4606b3b0e4ca901d121c2b0aeae91cf6dac0f1939fec039fac21036a5c8382abe382f5d705bf519ad
|
data/lib/io_streams/builder.rb
CHANGED
@@ -79,15 +79,16 @@ module IOStreams
|
|
79
79
|
# with their options that will be applied when the reader or writer is invoked.
|
80
80
|
def pipeline
|
81
81
|
return streams.dup.freeze if streams
|
82
|
-
return {}.freeze unless file_name
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
built_streams[:encode] = options[:encode] if options&.key?(:encode)
|
83
|
+
build_pipeline.freeze
|
84
|
+
end
|
87
85
|
|
88
|
-
|
89
|
-
|
90
|
-
|
86
|
+
# Removes the named stream from the current pipeline.
|
87
|
+
# If the stream pipeline has not yet been built it will be built from the file_name if present.
|
88
|
+
# Note: Any options must be set _before_ calling this method.
|
89
|
+
def remove_from_pipeline(stream_name)
|
90
|
+
@streams ||= build_pipeline
|
91
|
+
@streams.delete(stream_name.to_sym)
|
91
92
|
end
|
92
93
|
|
93
94
|
# Returns the tabular format if set, otherwise tries to autodetect the format if the file_name has been set
|
@@ -106,6 +107,18 @@ module IOStreams
|
|
106
107
|
|
107
108
|
private
|
108
109
|
|
110
|
+
def build_pipeline
|
111
|
+
return {} unless file_name
|
112
|
+
|
113
|
+
built_streams = {}
|
114
|
+
# Encode stream is always first
|
115
|
+
built_streams[:encode] = options[:encode] if options&.key?(:encode)
|
116
|
+
|
117
|
+
opts = options || {}
|
118
|
+
parse_extensions.each { |stream| built_streams[stream] = opts[stream] || {} }
|
119
|
+
built_streams
|
120
|
+
end
|
121
|
+
|
109
122
|
def class_for_stream(type, stream)
|
110
123
|
ext = IOStreams.extensions[stream.nil? ? nil : stream.to_sym] ||
|
111
124
|
raise(ArgumentError, "Unknown Stream type: #{stream.inspect}")
|
data/lib/io_streams/stream.rb
CHANGED
@@ -56,6 +56,14 @@ module IOStreams
|
|
56
56
|
builder.pipeline
|
57
57
|
end
|
58
58
|
|
59
|
+
# Removes the named stream from the current pipeline.
|
60
|
+
# If the stream pipeline has not yet been built it will be built from the file_name if present.
|
61
|
+
# Note: Any options must be set _before_ calling this method.
|
62
|
+
def remove_from_pipeline(stream_name)
|
63
|
+
builder.remove_from_pipeline(stream_name)
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
59
67
|
# Iterate over a file / stream returning one line at a time.
|
60
68
|
#
|
61
69
|
# Example: Read a line at a time
|
data/lib/io_streams/version.rb
CHANGED
data/test/builder_test.rb
CHANGED
@@ -237,6 +237,21 @@ class BuilderTest < Minitest::Test
|
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
240
|
+
describe "#remove_from_pipeline" do
|
241
|
+
let(:file_name) { "my/path/abc.bz2.pgp" }
|
242
|
+
it "removes a named stream from the pipeline" do
|
243
|
+
assert_equal({bz2: {}, pgp: {}}, streams.pipeline)
|
244
|
+
streams.remove_from_pipeline(:bz2)
|
245
|
+
assert_equal({pgp: {}}, streams.pipeline)
|
246
|
+
end
|
247
|
+
it "removes a named stream from the pipeline with options" do
|
248
|
+
streams.option(:pgp, passphrase: "unlock-me")
|
249
|
+
assert_equal({bz2: {}, pgp: {passphrase: "unlock-me"}}, streams.pipeline)
|
250
|
+
streams.remove_from_pipeline(:bz2)
|
251
|
+
assert_equal({pgp: {passphrase: "unlock-me"}}, streams.pipeline)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
240
255
|
describe "#execute" do
|
241
256
|
it "directly calls block for an empty stream" do
|
242
257
|
string_io = StringIO.new
|
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.
|
4
|
+
version: 1.9.0
|
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-
|
11
|
+
date: 2021-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|