Sha256: 6e94d0980e85212ebec5475fba452e578d9ad6fd2614d7f7063c4b9b7260146f
Contents?: true
Size: 885 Bytes
Versions: 5
Compression:
Stored size: 885 Bytes
Contents
# frozen_string_literal: true require 'stringio' module Chamber class DecryptionKey def initialize(options = {}) self.rootpath = options[:rootpath] self.filename = options[:filename] || '' end def resolve if filename.readable? filename.read elsif in_environment_variable? environment_variable end end def self.resolve(*args) new(*args).resolve end protected attr_accessor :filename, :rootpath def filename=(other) other_file = Pathname.new(other) @filename = if other_file.readable? other_file else default_file end end private def in_environment_variable? ENV['CHAMBER_KEY'] end def environment_variable ENV['CHAMBER_KEY'] end def default_file Pathname.new(rootpath + '.chamber.pem') end end end
Version data entries
5 entries across 5 versions & 1 rubygems