Module: Fragile::PluginManager
- Included in:
- Application
- Defined in:
- lib/fragile/plugin_manager.rb
Instance Attribute Summary collapse
-
#plugin_dir ⇒ Object
Returns the value of attribute plugin_dir.
Instance Method Summary collapse
Instance Attribute Details
#plugin_dir ⇒ Object
Returns the value of attribute plugin_dir.
16 17 18 |
# File 'lib/fragile/plugin_manager.rb', line 16 def plugin_dir @plugin_dir end |
Instance Method Details
#create_plugin(plugin, config) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fragile/plugin_manager.rb', line 33 def create_plugin(plugin, config) if plugin.instance_of?(Class) # クラスなら直接 new する plugin.new(config) else # 文字列かシンボルならクラスを取得して new する plugin_name = classify(plugin.to_s) create_plugin_instance(plugin_name, config) end end |
#load_plugins ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fragile/plugin_manager.rb', line 18 def load_plugins Fragile.logger.info "plugin_dir is '#{@plugin_dir}'." unless Dir.exist?(@plugin_dir) Fragile.logger.warn "'#{@plugin_dir}' is not exist." return end pattern = File.join(@plugin_dir, "*.rb") Fragile.logger.info "pattern is '#{pattern}'." Dir.glob(pattern) do |path| load path Fragile.logger.info "'#{path}' is loaded." end end |