Sha256: cb5915f1843c6ad41495b37cf87d9f1a305f6b7164c351fe4c482ff62f0fcc1a

Contents?: true

Size: 762 Bytes

Versions: 3

Compression:

Stored size: 762 Bytes

Contents

module Shellject
  module Tasks
    # Loads, decrypts, and outputs a shelljection
    class Load
      attr_reader :save_directory, :name

      def initialize(save_directory, name)
        @save_directory = save_directory
        @name = name
      end

      def call
        ensure_readable
        file = File.open path
        STDOUT.print crypto.decrypt(file)
      ensure
        file.close if file
      end

      private

      def ensure_readable
        fail ShelljectError, "Could not read file #{path}" unless readable?
      end

      def readable?
        path.readable?
      end

      def path
        @path ||= save_directory.path_for name
      end

      def crypto
        GPGME::Crypto.new always_trust: true
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shellject-0.3.0 lib/shellject/tasks/load.rb
shellject-0.2.0 lib/shellject/tasks/load.rb
shellject-0.1.0 lib/shellject/tasks/load.rb