Class: RosettAi::Thor::Tasks::License

Inherits:
Thor
  • Object
show all
Defined in:
lib/rosett_ai/thor/tasks/license.rb

Overview

Thor task for license key management.

License keys control access to premium content pack downloads — they NEVER restrict software functionality (GPL-3.0 compliance).

Instance Method Summary collapse

Instance Method Details

#activate(raw_key) ⇒ void

This method returns an undefined value.

Activate a license key.

Parameters:

  • raw_key (Object)

    the raw key



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rosett_ai/thor/tasks/license.rb', line 38

def activate(raw_key)
  key = RosettAi::Licensing::LicenseKey.new(raw_key)
  key.decode

  store = RosettAi::Licensing::LicenseStore.new
  store.save(raw_key)

  puts Rainbow(t('activate.success', tier: key.tier.to_s)).green
rescue RosettAi::LicenseError => e
  raise ::Thor::Error, t('activate.invalid', reason: e.message)
end

#deactivatevoid

This method returns an undefined value.

Deactivate the current license.



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/rosett_ai/thor/tasks/license.rb', line 88

def deactivate
  store = RosettAi::Licensing::LicenseStore.new

  unless store.exists?
    puts Rainbow(t('deactivate.not_found')).yellow
    return
  end

  store.remove!
  puts Rainbow(t('deactivate.success')).green
end

#statusString

Return the current status.

Returns:

  • (String)


63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rosett_ai/thor/tasks/license.rb', line 63

def status
  result = RosettAi::Licensing::LicenseValidator.new.validate

  if result[:tier].name == :community
    puts Rainbow(t('status.community')).yellow
    return
  end

  print_status_table(result)
  print_warnings(result[:warnings])
end