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 =
0o600- SAFE_DIR_MODE =
0o700
Instance Method Summary collapse
Instance Method Details
#exists? ⇒ Boolean
31 32 33 |
# File 'lib/rosett_ai/licensing/license_store.rb', line 31 def exists? license_path.exist? end |
#load ⇒ Object
20 21 22 23 24 25 |
# File 'lib/rosett_ai/licensing/license_store.rb', line 20 def load return nil unless exists? File.read(license_path.to_s).chomp end |
#remove! ⇒ Object
27 28 29 |
# File 'lib/rosett_ai/licensing/license_store.rb', line 27 def remove! File.delete(license_path.to_s) if exists? end |
#save(raw_key) ⇒ Object
14 15 16 17 18 |
# File 'lib/rosett_ai/licensing/license_store.rb', line 14 def save(raw_key) ensure_parent_directory! File.write(license_path.to_s, raw_key, mode: 'w', perm: SAFE_FILE_MODE) end |