Sha256: c32457483ec3f7637a2cc029137543d7dedfeaab826805564e2af4fc711ddd2e

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

module Astrails
  module Safe
    class Gpg < Pipe

      protected

      def post_process
        @backup.compressed = true
      end

      def pipe
        if key
          "|gpg #{@config[:options]} -e -r #{key}"
        elsif password
          "|gpg #{@config[:options]} -c --passphrase-file #{gpg_password_file(password)}"
        end
      end

      def extension
        ".gpg"
      end

      def active?
        raise RuntimeError, "can't use both gpg password and pubkey" if key && password

        password || key
      end

      private

      def password
        @password ||= @config[:gpg, :password]
      end

      def key
        @key ||= @config[:gpg, :key]
      end

      def gpg_password_file(pass)
        return "TEMP_GENERATED_FILENAME" if $DRY_RUN
        Astrails::Safe::TmpFile.create("gpg-pass") { |file| file.write(pass) }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
astrails-safe-0.1.7 lib/astrails/safe/gpg.rb