lib/io_streams/pgp.rb in iostreams-1.4.0 vs lib/io_streams/pgp.rb in iostreams-1.5.0

- old
+ new

@@ -72,13 +72,14 @@ out, err, status = Open3.capture3(command, binmode: true, stdin_data: params) logger&.debug { "IOStreams::Pgp.generate_key: #{command}\n#{params}\n#{err}#{out}" } raise(Pgp::Failure, "GPG Failed to generate key: #{err}#{out}") unless status.success? - if (match = err.match(/gpg: key ([0-9A-F]+)\s+/)) - match[1] - end + match = err.match(/gpg: key ([0-9A-F]+)\s+/) + return unless match + + match[1] end # Delete all private and public keys for a particular email. # # Returns false if no key was found. @@ -108,15 +109,10 @@ raise(ArgumentError, "Either :email, or :key_id must be supplied") if email.nil? && key_id.nil? !list_keys(email: email, key_id: key_id, private: private).empty? end - # Deprecated - def self.has_key?(**args) - key?(**args) - end - # Returns [Array<Hash>] the list of keys. # Each Hash consists of: # key_length: [Integer] # key_type: [String] # key_id: [String] @@ -230,11 +226,11 @@ results = [] secret = false err.each_line do |line| if line =~ /secret key imported/ secret = true - elsif match = line.match(/key\s+(\w+):\s+(\w+).+\"(.*)<(.*)>\"/) + elsif (match = line.match(/key\s+(\w+):\s+(\w+).+\"(.*)<(.*)>\"/)) results << { key_id: match[1].to_s.strip, private: secret, name: match[3].to_s.strip, email: match[4].to_s.strip @@ -344,11 +340,9 @@ raise(Pgp::Failure, "GPG Failed calling #{executable} to list keys for #{email || key_id}: #{err}#{out}") end end end - - private @logger = nil def self.logger @logger