lib/io_streams/symmetric_encryption/reader.rb in iostreams-0.20.3 vs lib/io_streams/symmetric_encryption/reader.rb in iostreams-1.0.0.beta

- old
+ new

@@ -1,22 +1,14 @@ module IOStreams module SymmetricEncryption - class Reader + class Reader < IOStreams::Reader # read from a file/stream using Symmetric Encryption - def self.open(file_name_or_io, **args, &block) - begin - require 'symmetric-encryption' unless defined?(SymmetricEncryption) - rescue LoadError => e - raise(LoadError, "Please install the 'symmetric-encryption' gem for .enc streaming support. #{e.message}") + def self.stream(input_stream, **args, &block) + unless defined?(SymmetricEncryption) + Utils.load_dependency('symmetric-encryption', '.enc streaming') end - if IOStreams.reader_stream?(file_name_or_io) - ::SymmetricEncryption::Reader.open(file_name_or_io, **args, &block) - else - IOStreams::File::Reader.open(file_name_or_io) do |file| - ::SymmetricEncryption::Reader.open(file, **args, &block) - end - end + ::SymmetricEncryption::Reader.open(input_stream, **args, &block) end end end end