Class: GitAuto::Config::CredentialStore
- Inherits:
-
Object
- Object
- GitAuto::Config::CredentialStore
- Defined in:
- lib/git_auto/config/credential_store.rb
Constant Summary collapse
- CREDENTIALS_FILE =
File.join(File.("~/.git_auto"), "credentials.yml")
- ENCRYPTION_KEY =
ENV["GIT_AUTO_SECRET"] || "default_development_key"
Instance Method Summary collapse
- #api_key_exists?(provider) ⇒ Boolean
- #get_api_key(provider) ⇒ Object
-
#initialize ⇒ CredentialStore
constructor
A new instance of CredentialStore.
- #store_api_key(key, provider) ⇒ Object
Constructor Details
#initialize ⇒ CredentialStore
Returns a new instance of CredentialStore.
14 15 16 |
# File 'lib/git_auto/config/credential_store.rb', line 14 def initialize ensure_credentials_file end |
Instance Method Details
#api_key_exists?(provider) ⇒ Boolean
32 33 34 35 |
# File 'lib/git_auto/config/credential_store.rb', line 32 def api_key_exists?(provider) credentials = load_credentials credentials.key?(provider.to_s) end |
#get_api_key(provider) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/git_auto/config/credential_store.rb', line 24 def get_api_key(provider) credentials = load_credentials encrypted_key = credentials[provider.to_s] return nil unless encrypted_key decrypt(encrypted_key) end |
#store_api_key(key, provider) ⇒ Object
18 19 20 21 22 |
# File 'lib/git_auto/config/credential_store.rb', line 18 def store_api_key(key, provider) credentials = load_credentials credentials[provider.to_s] = encrypt(key) save_credentials(credentials) end |