Sha256: 6de69da5063588799d02b9bca5854b392bc5a7a390127c0c911824e0bbe3245a

Contents?: true

Size: 839 Bytes

Versions: 10

Compression:

Stored size: 839 Bytes

Contents

module Astrails
  module Safe
    class Gpg < Pipe

      def compressed?
        active? || @parent.compressed?
      end

      protected

      def pipe
        if key
          rise RuntimeError, "can't use both gpg password and pubkey" if password
          "|gpg -e -r #{key}"
        elsif password
          "|gpg -c --passphrase-file #{gpg_password_file(password)}"
        end
      end

      def extension
        ".gpg" if active?
      end

      def active?
        password || key
      end

      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

10 entries across 10 versions & 4 rubygems

Version Path
astrails-safe-0.1.1 lib/astrails/safe/gpg.rb
astrails-safe-0.1.2 lib/astrails/safe/gpg.rb
astrails-safe-0.1.3 lib/astrails/safe/gpg.rb
astrails-safe-0.1.4 lib/astrails/safe/gpg.rb
astrails-safe-0.1.6 lib/astrails/safe/gpg.rb
colin-safe-0.1.6 lib/astrails/safe/gpg.rb
colin-safe-0.1.7 lib/astrails/safe/gpg.rb
colin-safe-0.1.8 lib/astrails/safe/gpg.rb
markmansour-safe-0.1.7 lib/astrails/safe/gpg.rb
ralph-safe-0.1.7 lib/astrails/safe/gpg.rb