Sha256: ac76f359d694ea9f3da762e020d9b8d1acb8a24a9798ad861893e41c93a42faf

Contents?: true

Size: 928 Bytes

Versions: 7

Compression:

Stored size: 928 Bytes

Contents

# frozen_string_literal: true

module Roro
  module Crypto
    class Exposer

      include Roro::FileReflection

      def initialize
        @writer = Roro::Crypto::FileWriter.new
        @cipher = Roro::Crypto::Cipher.new
      end

      def expose_file(file, key)
        encrypted_content = File.read(file)
        decrypted_content = @cipher.decrypt(encrypted_content, key)
        @writer.write_to_file(file.split('.enc').first, decrypted_content)
      end

      def expose(environments, directory, ext)
        if environments.empty?
          environments = gather_environments(directory, ext)
        else
          environments.each { |environment| get_key(environment) }
        end
        environments.each do |environment|
          exposable = source_files(directory, "#{environment}*#{ext}")
          exposable.each { |file| expose_file(file, get_key(environment)) }
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
roro-0.3.33 lib/roro/crypto/exposer.rb
roro-0.3.30 lib/roro/crypto/exposer.rb
roro-0.3.28 lib/roro/crypto/exposer.rb
roro-0.3.27 lib/roro/crypto/exposer.rb
roro-0.3.25 lib/roro/crypto/exposer.rb
roro-0.3.24 lib/roro/crypto/exposer.rb
roro-0.3.23 lib/roro/crypto/exposer.rb