diff options
-rw-r--r-- | core/miquire_plugin.rb | 11 | ||||
-rw-r--r-- | test/core/test_miquire_plugin.rb | 4 |
2 files changed, 9 insertions, 6 deletions
diff --git a/core/miquire_plugin.rb b/core/miquire_plugin.rb index dc32c40b..43ce59cd 100644 --- a/core/miquire_plugin.rb +++ b/core/miquire_plugin.rb @@ -127,12 +127,17 @@ module Miquire::Plugin }.flatten local_depends.uniq.map{|d| d.to_spec } else - Array(spec[:depends][:plugin]).map{ |s| Array(s).first.to_sym.to_spec } - end + Array(spec[:depends][:plugin]).map do |s| + slug = Array(s).first.to_sym + if slug + slug.to_spec + else + slug end end end else [] end end def load(_spec) + return false unless _spec spec = _spec.to_spec return false unless spec return true if ::Plugin.instance_exist?(spec[:slug]) @@ -142,7 +147,7 @@ module Miquire::Plugin begin raise Miquire::LoadError unless load(depend) rescue Miquire::LoadError - raise Miquire::LoadError, "plugin #{spec[:slug]}: dependency error: plugin #{depended_plugin_slug} was not loaded." end end + raise Miquire::LoadError, "plugin #{spec[:slug]}: dependency error: plugin #{depend} was not loaded." end end notice "plugin loaded: " + File.join(spec[:path], "#{spec[:slug]}.rb") ::Plugin.create(spec[:slug].to_sym) do diff --git a/test/core/test_miquire_plugin.rb b/test/core/test_miquire_plugin.rb index f062a89a..95fd2281 100644 --- a/test/core/test_miquire_plugin.rb +++ b/test/core/test_miquire_plugin.rb @@ -80,9 +80,7 @@ class TC_MiquirePlugin < Test::Unit::TestCase assert(Miquire::Plugin.load(Miquire::Plugin.get_spec_by_slug(:standalone)), "プラグインがロードできる") assert(Plugin.instance_exist?(:standalone), "プラグインがロードできる") - assert_raise(ArgumentError, "存在しないプラグインはロードできない") { - Miquire::Plugin.load(Miquire::Plugin.get_spec_by_slug(:not_exist)) - } + refute(Miquire::Plugin.load(Miquire::Plugin.get_spec_by_slug(:not_exist)), "存在しないプラグインはロードできない") end must "load child plugin with parent" do |