lib/io_streams/pgp/reader.rb in iostreams-1.0.0.beta7 vs lib/io_streams/pgp/reader.rb in iostreams-1.0.0

- old
+ new

@@ -19,10 +19,12 @@ # file_name: [String] # Name of file to read from # # passphrase: [String] # Pass phrase for private key to decrypt the file with - def self.file(file_name, passphrase: self.default_passphrase) + def self.file(file_name, passphrase: nil) + # Cannot use `passphrase: self.default_passphrase` since it is considered private + passphrase ||= default_passphrase raise(ArgumentError, 'Missing both passphrase and IOStreams::Pgp::Reader.default_passphrase') unless passphrase loopback = IOStreams::Pgp.pgp_version.to_f >= 2.1 ? '--pinentry-mode loopback' : '' command = "#{IOStreams::Pgp.executable} #{loopback} --batch --no-tty --yes --decrypt --passphrase-fd 0 #{file_name}" IOStreams::Pgp.logger&.debug { "IOStreams::Pgp::Reader.open: #{command}" }