class Siba::InstalledPlugins
Constants
- GEM_PREFIX
Public Class Methods
all_installed()
click to toggle source
# File lib/siba/plugins/installed_plugins.rb, line 16 def all_installed @installed ||= find_installed end
category_dir(category)
click to toggle source
# File lib/siba/plugins/installed_plugins.rb, line 37 def category_dir(category) File.expand_path "../#{category}/", __FILE__ end
gem_name(category, type)
click to toggle source
# File lib/siba/plugins/installed_plugins.rb, line 45 def gem_name(category, type) "#{GEM_PREFIX}#{category}-#{type}" end
install_gem_message(category, type)
click to toggle source
# File lib/siba/plugins/installed_plugins.rb, line 53 def install_gem_message(category, type) "'#{type}' plugin is not installed.\nRun 'gem install #{gem_name(category, type)}' to install it and try again." end
installed?(category, type)
click to toggle source
# File lib/siba/plugins/installed_plugins.rb, line 10 def installed?(category, type) types = all_installed[category] return false if types.nil? types.include? type end
plugin_category_and_type(category, type)
click to toggle source
# File lib/siba/plugins/installed_plugins.rb, line 49 def plugin_category_and_type(category, type) "#{category}#{type.nil? ? "" : '-' + type}" end
plugin_path(category, type)
click to toggle source
# File lib/siba/plugins/installed_plugins.rb, line 20 def plugin_path(category, type) unless installed? category, type raise Siba::Error, "Plugin #{plugin_category_and_type(category, type)} is not installed" end siba_file.run_this do path = type_dir category, type unless siba_file.file_directory? path path = Siba::GemHelper.gem_path gem_name(category, type) path = File.join path, "lib", gem_name(category, type) end unless siba_file.file_directory? path raise Siba::Error, "Failed to get path to plugin #{plugin_category_and_type(category, type)}" end path end end
type_dir(category, type)
click to toggle source
# File lib/siba/plugins/installed_plugins.rb, line 41 def type_dir(category, type) File.join category_dir(category), type end
Private Class Methods
find_installed()
click to toggle source
# File lib/siba/plugins/installed_plugins.rb, line 59 def find_installed installed = {} Siba::GemHelper.all_local_gems.map{|a| a.name}.each do |item| Siba::Plugins::CATEGORIES.each do |category| installed[category] ||= [] gem_prefix_full = /^#{GEM_PREFIX}#{category}-/ installed[category] << item.gsub(gem_prefix_full, '') if item =~ /#{gem_prefix_full}.*$/ end end Siba::Plugins::CATEGORIES.each do |category| installed[category] += Dir.glob(File.join(category_dir(category),"*")).select { |entry| File.directory? entry }.select{|dir| File.file?(File.join(dir,"init.rb")) } .map{|directory| File.basename(directory)} end installed end