Class: RuGUI::Plugin::Location
- Includes:
- LogSupport
- Defined in:
- lib/rugui/plugin/loader.rb
Overview
This class is a representation of RuGUI plugins.
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#loaded ⇒ Object
Returns the value of attribute loaded.
-
#plugin_name ⇒ Object
Returns the value of attribute plugin_name.
Instance Method Summary collapse
-
#initialize(dir) ⇒ Location
constructor
A new instance of Location.
-
#load ⇒ Object
Load plugins.
- #loaded? ⇒ Boolean
- #require_for(init_file) ⇒ Object
Methods included from LogSupport
Constructor Details
#initialize(dir) ⇒ Location
Returns a new instance of Location.
48 49 50 51 |
# File 'lib/rugui/plugin/loader.rb', line 48 def initialize(dir) self.dir = dir self.plugin_name = dir.split(File::SEPARATOR).last end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
43 44 45 |
# File 'lib/rugui/plugin/loader.rb', line 43 def dir @dir end |
#loaded ⇒ Object
Returns the value of attribute loaded.
44 45 46 |
# File 'lib/rugui/plugin/loader.rb', line 44 def loaded @loaded end |
#plugin_name ⇒ Object
Returns the value of attribute plugin_name.
42 43 44 |
# File 'lib/rugui/plugin/loader.rb', line 42 def plugin_name @plugin_name end |
Instance Method Details
#load ⇒ Object
Load plugins.
54 55 56 57 58 59 60 61 62 63 64 |
# 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.(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? ⇒ Boolean
72 73 74 |
# File 'lib/rugui/plugin/loader.rb', line 72 def loaded? self.loaded ||= false end |
#require_for(init_file) ⇒ Object
66 67 68 69 70 |
# 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 |