Sha256: 7a2c05d856021caa4050a537309aff9b3c7acaff6e7ca107174eb86bc9395737

Contents?: true

Size: 904 Bytes

Versions: 12

Compression:

Stored size: 904 Bytes

Contents

module Astrails
  module Safe
    class Gpg < Pipe

      protected

      def post_process
        @backup.compressed = true
      end

      def pipe
        if key
          "|gpg #{@config[:gpg, :options]} -e -r #{key}"
        elsif password
          "|gpg #{@config[:gpg,: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

12 entries across 12 versions & 3 rubygems

Version Path
astrails-safe-0.1.10 lib/astrails/safe/gpg.rb
astrails-safe-0.1.8 lib/astrails/safe/gpg.rb
astrails-safe-0.1.9 lib/astrails/safe/gpg.rb
astrails-safe-0.2.0 lib/astrails/safe/gpg.rb
astrails-safe-0.2.1 lib/astrails/safe/gpg.rb
astrails-safe-0.2.2 lib/astrails/safe/gpg.rb
astrails-safe-0.2.3 lib/astrails/safe/gpg.rb
bostonlogic-safe-0.3.0 lib/astrails/safe/gpg.rb
astrails-safe-0.2.6 lib/astrails/safe/gpg.rb
astrails-safe-0.2.5 lib/astrails/safe/gpg.rb
webbynode-safe-0.2.5 lib/astrails/safe/gpg.rb
astrails-safe-0.2.4 lib/astrails/safe/gpg.rb