Sha256: 16ef022a90149de0a4c274472946573daeee738d004786f61d718af16588d78a

Contents?: true

Size: 707 Bytes

Versions: 2

Compression:

Stored size: 707 Bytes

Contents

# frozen_string_literal: true

module Biscuit
  class SecretsDecrypter
    attr_reader :secrets_file

    def initialize(secrets_file)
      fail "#{secrets_file} is not found" unless File.exists? secrets_file

      @secrets_file = secrets_file
    end

    def load(&block)
      if block_given?
        secrets.each{ |key, value|
          block.call(key, value)
        }
      else
        secrets
      end
    end

    private

    def secrets
      @_secrets ||= YAML.load(exported)
    end

    def exported
      @_exported ||= Biscuit.run!("export -f '#{secrets_file}'")
    end

    def secret_lines
      @_secret_lines ||= exported.split("\n").select { |line| line =~ /\S/ }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
biscuit-0.1.4 lib/biscuit/secrets_decrypter.rb
biscuit-0.1.3 lib/biscuit/secrets_decrypter.rb