Class: RosettAi::Content::PackRegistry
- Inherits:
-
Object
- Object
- RosettAi::Content::PackRegistry
- Defined in:
- lib/rosett_ai/content/pack_registry.rb
Overview
Tracks installed content packs via filesystem scanning.
No separate registry file — the filesystem IS the registry. Each pack directory under ~/.config/rosett-ai/premium/ contains a manifest.yml that describes the pack.
Instance Method Summary collapse
-
#installed ⇒ Array<PackManifest>
Lists all installed content packs by scanning the premium directory.
-
#installed?(pack_name) ⇒ Boolean
Whether a pack with the given name is installed.
-
#remove!(pack_name)
Removes an installed pack and its directory.
-
#version(pack_name) ⇒ String?
Returns the installed version of a pack.
Instance Method Details
#installed ⇒ Array<PackManifest>
Lists all installed content packs by scanning the premium directory.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rosett_ai/content/pack_registry.rb', line 17 def installed return [] unless premium_dir.exist? Dir.children(premium_dir.to_s).filter_map do |entry| dir = premium_dir.join(entry) manifest_path = dir.join('manifest.yml') next unless dir.directory? && manifest_path.exist? PackManifest.from_file(manifest_path.to_s) rescue RosettAi::ContentError nil end end |
#installed?(pack_name) ⇒ Boolean
Whether a pack with the given name is installed.
35 36 37 38 |
# File 'lib/rosett_ai/content/pack_registry.rb', line 35 def installed?(pack_name) manifest_path = premium_dir.join(pack_name, 'manifest.yml') manifest_path.exist? end |
#remove!(pack_name)
This method returns an undefined value.
Removes an installed pack and its directory.
56 57 58 59 |
# File 'lib/rosett_ai/content/pack_registry.rb', line 56 def remove!(pack_name) dir = premium_dir.join(pack_name) FileUtils.rm_rf(dir.to_s) if dir.exist? end |
#version(pack_name) ⇒ String?
Returns the installed version of a pack.
44 45 46 47 48 49 50 |
# File 'lib/rosett_ai/content/pack_registry.rb', line 44 def version(pack_name) manifest_path = premium_dir.join(pack_name, 'manifest.yml') return nil unless manifest_path.exist? manifest = PackManifest.from_file(manifest_path.to_s) manifest.version end |