Class: RosettAi::Licensing::LicenseStore
- Inherits:
-
Object
- Object
- RosettAi::Licensing::LicenseStore
- Defined in:
- lib/rosett_ai/licensing/license_store.rb
Overview
Persists the license key at ~/.config/rosett-ai/license.key with strict file permissions (0600, owned by current uid).
Constant Summary collapse
- SAFE_FILE_MODE =
Returns File permission mode for secure files.
0o600- SAFE_DIR_MODE =
Returns Directory permission mode for secure directories.
0o700
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#load ⇒ LicenseKey?
Load the license key from persistent storage.
-
#remove! ⇒ void
Remove the stored license key file.
-
#save(raw_key) ⇒ void
Save the license key to persistent storage.
Instance Method Details
#exists? ⇒ Boolean
42 43 44 |
# File 'lib/rosett_ai/licensing/license_store.rb', line 42 def exists? license_path.exist? end |
#load ⇒ LicenseKey?
Load the license key from persistent storage.
28 29 30 31 32 33 |
# File 'lib/rosett_ai/licensing/license_store.rb', line 28 def load return nil unless exists? File.read(license_path.to_s).chomp end |
#remove! ⇒ void
This method returns an undefined value.
Remove the stored license key file.
38 39 40 |
# File 'lib/rosett_ai/licensing/license_store.rb', line 38 def remove! File.delete(license_path.to_s) if exists? end |
#save(raw_key) ⇒ void
This method returns an undefined value.
Save the license key to persistent storage.
20 21 22 23 24 |
# File 'lib/rosett_ai/licensing/license_store.rb', line 20 def save(raw_key) ensure_parent_directory! File.write(license_path.to_s, raw_key, mode: 'w', perm: SAFE_FILE_MODE) end |