Class: Flo::CredStore::PwProtectedStore
- Inherits:
-
Object
- Object
- Flo::CredStore::PwProtectedStore
- Defined in:
- lib/flo/cred_store/pw_protected_store.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#credentials_for(provider_sym) ⇒ Flo::CredStore::Creds
Decrypts the credentials file and returns the credentials for the requested provider.
-
#encrypt_file(file_location) ⇒ String
Convenience method for producing an encrypted version of a file.
-
#initialize(opts = {}) ⇒ PwProtectedStore
constructor
A new instance of PwProtectedStore.
-
#inspect ⇒ Object
Remove password from inspect output.
Constructor Details
#initialize(opts = {}) ⇒ PwProtectedStore
Returns a new instance of PwProtectedStore.
12 13 14 15 |
# File 'lib/flo/cred_store/pw_protected_store.rb', line 12 def initialize(opts={}) @password = opts[:password] # If nil, should prompt interactively @cred_file_location = opts[:cred_file_location] end |
Instance Attribute Details
#cred_file ⇒ Object
33 34 35 |
# File 'lib/flo/cred_store/pw_protected_store.rb', line 33 def cred_file @cred_file ||= File.new(@cred_file_location || File.join(Dir.home, '.flo_creds.yml.gpg')) end |
Instance Method Details
#credentials_for(provider_sym) ⇒ Flo::CredStore::Creds
Decrypts the credentials file and returns the credentials for the requested provider
21 22 23 |
# File 'lib/flo/cred_store/pw_protected_store.rb', line 21 def credentials_for(provider_sym) Flo::CredStore::Creds.new(full_credentials_hash[provider_sym]) end |
#encrypt_file(file_location) ⇒ String
Convenience method for producing an encrypted version of a file. This only returns the encrypted version as a string, you will have to save it yourself if desired
29 30 31 |
# File 'lib/flo/cred_store/pw_protected_store.rb', line 29 def encrypt_file(file_location) crypto.encrypt(File.open(file_location)).to_s end |
#inspect ⇒ Object
Remove password from inspect output
38 39 40 |
# File 'lib/flo/cred_store/pw_protected_store.rb', line 38 def inspect "#<Flo::CredStore::PwProtectedStore:#{object_id} @cred_file=#{cred_file.inspect}>" end |