Class: Gleis::Addon
- Inherits:
-
Object
- Object
- Gleis::Addon
- Defined in:
- lib/gleis/addon.rb
Overview
The class implements the methods required to manage the add-ons of a gleis app
Class Method Summary collapse
Class Method Details
.add(app_name, name) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/gleis/addon.rb', line 4 def self.add(app_name, name) token = Token.check body = API.request('post', 'addons', token, 'name': app_name, 'addon': name) if body['success'] == 1 puts "Successfully added #{name} add-on to #{app_name}." else puts "Failed to add add-on: #{body['message']}" end end |
.list(app_name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gleis/addon.rb', line 14 def self.list(app_name) token = Token.check body = API.request('get', "addons/#{app_name}", token) addons = body ['data'] if addons.any? puts "List of available add-ons:\n\n" printf("\t%s\n", 'ADD-ON NAME') printf("\t%-30s %-15s %s\n", 'DESCRIPTION', 'VERSION', 'CATEGORY') printf("\t%-30s %-15s %s\n\n", '-----------', '-------', '--------') addons.each do |addon| printf("\t%-30s %-15s %s\n", addon['name'], addon['version'], addon['category']) puts "\t#{addon['description']}\n\n" end else puts 'No add-ons avaialble.' end end |
.remove(app_name, name) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/gleis/addon.rb', line 32 def self.remove(app_name, name) token = Token.check body = API.request('delete', "addons/#{app_name}/#{name}", token) if body['success'] == 1 puts "Successfully removed #{name} add-on from #{app_name}." else puts "Failed to remove add-on: #{body['message']}" end end |