class RuGUI::Plugin::Location

This class is a representation of RuGUI plugins.

Attributes

dir[RW]
loaded[RW]
plugin_name[RW]

Public Class Methods

new(dir) click to toggle source
# File lib/rugui/plugin/loader.rb, line 48
def initialize(dir)
  self.dir = dir
  self.plugin_name = dir.split(File::SEPARATOR).last
end

Public Instance Methods

load() click to toggle source

Load plugins.

# File lib/rugui/plugin/loader.rb, line 54
def load
  $LOAD_PATH.unshift(File.join(self.dir, "lib")) if File.directory?(self.dir)
  $LOAD_PATH.uniq!

  init_file = File.expand_path(File.join(self.dir, "init.rb"))
  if File.exist?(init_file)
    require_for init_file
  else
    logger.warn "The init file for (#{self.plugin_name}) was not found."
  end
end
loaded?() click to toggle source
# File lib/rugui/plugin/loader.rb, line 72
def loaded?
  self.loaded ||= false
end
require_for(init_file) click to toggle source
# File lib/rugui/plugin/loader.rb, line 66
def require_for(init_file)
  require init_file
rescue Exception
  logger.error "An error occurred while loading #{self.plugin_name}. Checks its init file: #{$!}"
end