lib/secret_env/storage.rb in secret_env-0.4.0 vs lib/secret_env/storage.rb in secret_env-0.5.0

- old
+ new

@@ -15,10 +15,12 @@ case type when 'plain' Storage::Plain when 'credstash' Storage::CredStash + when 'file' + Storage::File else raise "Unknown storage type: #{type}" end end end @@ -48,9 +50,22 @@ end class CredStash < Base def retrieve(secret_key) ::CredStash.get(full_key(secret_key)) + end + end + + class File < Base + LOCAL_FILE_PATH = 'config/secret_env.local' + + def initialize(namespace: '') + super + @secrets = Hash[*::File.readlines(LOCAL_FILE_PATH).map(&:strip).map {|line| line.split("=", 2) }.flatten] + end + + def retrieve(secret_key) + @secrets[full_key(secret_key)] end end end end