class Siba::Plugins

Constants

CATEGORIES
PLUGINS_HASH

Public Class Methods

categories_str() click to toggle source
# File lib/siba/plugins/plugins.rb, line 16
def categories_str
  Siba::Plugins::CATEGORIES.join(", ")
end
category_and_type_correct?(category, type) click to toggle source
# File lib/siba/plugins/plugins.rb, line 20
def category_and_type_correct?(category, type)
  PLUGINS_HASH.keys.include?(category) && PLUGINS_HASH[category].keys.include?(type)
end
get_list() click to toggle source
# File lib/siba/plugins/plugins.rb, line 36
def get_list
  str = ""
  all_names = PLUGINS_HASH.values.map{|a| a.keys}.flatten
  max_name_length = all_names.max do |a,b|
    a.length <=> b.length
  end.length + 5

  PLUGINS_HASH.each do |category, plugins|
    str << "#{category.capitalize}"
    str << "s" if plugins.size > 1
    str << ":\n"
    plugins.each do |type, desc|
      installed = InstalledPlugins.installed?(category, type) ? "*" : " "
      str << " #{installed} #{plugin_type_and_description(category, type, max_name_length)}\n"
    end
    str << "\n"
  end
  str
end
plugin_description(category, type) click to toggle source
# File lib/siba/plugins/plugins.rb, line 24
def plugin_description(category, type)
  unless category_and_type_correct? category, type
    raise Siba::Error, "Incorrect category '#{category}' or type '#{type}'."
  end
  PLUGINS_HASH[category][type]
end
plugin_type_and_description(category, type, name_column_length) click to toggle source
# File lib/siba/plugins/plugins.rb, line 31
def plugin_type_and_description(category, type, name_column_length)
  desc = plugin_description category, type
  sprintf("%-#{name_column_length}s %s", type, desc)
end
valid_category?(category) click to toggle source
# File lib/siba/plugins/plugins.rb, line 12
def valid_category?(category)
  Siba::Plugins::CATEGORIES.include? category
end