Class: JIJI::Plugin::Loader
- Inherits:
-
Object
- Object
- JIJI::Plugin::Loader
- Defined in:
- lib/jiji/plugin/plugin_loader.rb
Overview
プラグインローダー
Instance Attribute Summary collapse
-
#server_logger ⇒ Object
Returns the value of attribute server_logger.
Instance Method Summary collapse
-
#initialize ⇒ Loader
constructor
A new instance of Loader.
-
#load ⇒ Object
プラグインをロードする。.
Constructor Details
#initialize ⇒ Loader
Returns a new instance of Loader.
29 30 31 |
# File 'lib/jiji/plugin/plugin_loader.rb', line 29 def initialize @loaded = Set.new end |
Instance Attribute Details
#server_logger ⇒ Object
Returns the value of attribute server_logger.
53 54 55 |
# File 'lib/jiji/plugin/plugin_loader.rb', line 53 def server_logger @server_logger end |
Instance Method Details
#load ⇒ Object
プラグインをロードする。
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jiji/plugin/plugin_loader.rb', line 33 def load ($: + Gem.latest_load_paths).each {|dir| plugin = File. "#{dir}/jiji_plugin.rb" next unless File.exist? plugin next if @loaded.include?( plugin ) begin Kernel.load plugin server_logger.info( "plugin loaded. plugin_path=#{plugin}" ) if server_logger @loaded << plugin rescue Exception if server_logger server_logger.error( "plugin load failed. plugin_path=#{plugin}" ) server_logger.error($!) else puts "plugin load failed. plugin_path=#{plugin}" puts ([$!.to_s] + $!.backtrace).join("\n ") end end } end |