Class: RosettAi::Thor::Tasks::Content
- Inherits:
-
Thor
- Object
- Thor
- RosettAi::Thor::Tasks::Content
- Defined in:
- lib/rosett_ai/thor/tasks/content.rb
Overview
Thor task for premium content pack management.
Content packs are signed tarballs of YAML files downloaded from the NeatNerds content server. License tier is checked before download — software functionality is never restricted.
Instance Method Summary collapse
-
#install(pack_name) ⇒ void
Install the component.
-
#list ⇒ void
List available items.
-
#update ⇒ void
Update to the latest version.
Instance Method Details
#install(pack_name) ⇒ void
This method returns an undefined value.
Install the component.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rosett_ai/thor/tasks/content.rb', line 62 def install(pack_name) result = validate_license! tier = result[:tier] client = build_client catalog = client.catalog(tier: tier.name.to_s) pack_info = catalog&.find { |entry| entry['name'] == pack_name } raise ::Thor::Error, t('install.not_found', name: pack_name) unless pack_info required_tier = RosettAi::Licensing::Tier.new(pack_info['tier_required']) unless tier.entitled_to?(required_tier) raise ::Thor::Error, t('install.tier_required', name: pack_name, required: required_tier, current: tier) end download_and_install(client, pack_name, pack_info['version']) rescue RosettAi::ContentError => e raise ::Thor::Error, e. end |
#list ⇒ void
This method returns an undefined value.
List available items.
37 38 39 40 41 42 43 |
# File 'lib/rosett_ai/thor/tasks/content.rb', line 37 def list if [:available] list_available else list_installed end end |
#update ⇒ void
This method returns an undefined value.
Update to the latest version.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/rosett_ai/thor/tasks/content.rb', line 96 def update validate_license! registry = RosettAi::Content::PackRegistry.new packs = registry.installed if packs.empty? puts Rainbow(t('list.no_packs')).yellow return end client = build_client packs.each do |manifest| puts t('update.checking', name: manifest.name) download_and_install(client, manifest.name, manifest.version) end puts Rainbow(t('update.success')).green rescue RosettAi::ContentError => e puts Rainbow(t('update.offline')).yellow puts Rainbow(e.).red end |