From de09752972bd6e1c8a68d8c1d06c3311721dc1bd Mon Sep 17 00:00:00 2001 From: Paolo Capriotti Date: Thu, 2 Jul 2009 11:34:51 +0200 Subject: [PATCH] All plugins load by themselves now. Added test to check if plugins can be loaded before any possible dependency. --- lib/plugins/clocks/digital.rb | 2 ++ lib/plugins/engines/loader.rb | 2 ++ lib/plugins/ics/ics.rb | 3 ++- lib/plugins/loader.rb | 4 ++++ lib/plugins/movelist/simple_movelist.rb | 1 + test/plugins/test_loadable.rb | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 test/plugins/test_loadable.rb diff --git a/lib/plugins/clocks/digital.rb b/lib/plugins/clocks/digital.rb index bd4d6ec..463699f 100644 --- a/lib/plugins/clocks/digital.rb +++ b/lib/plugins/clocks/digital.rb @@ -5,9 +5,11 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. +require 'qtutils' require 'plugins/plugin' require 'constrained_text_item' require 'board/item_bag' +require 'observer_utils' class DigitalClock < Qt::GraphicsItemGroup include Plugin diff --git a/lib/plugins/engines/loader.rb b/lib/plugins/engines/loader.rb index bcf8a76..d578785 100644 --- a/lib/plugins/engines/loader.rb +++ b/lib/plugins/engines/loader.rb @@ -5,6 +5,8 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. +require 'qtutils' +require 'plugins/plugin' require 'factory' class EngineLoader diff --git a/lib/plugins/ics/ics.rb b/lib/plugins/ics/ics.rb index d6420e9..5ae7d5c 100644 --- a/lib/plugins/ics/ics.rb +++ b/lib/plugins/ics/ics.rb @@ -1,6 +1,7 @@ +require 'qtutils' +require 'plugins/plugin' require 'require_bundle' require 'action_provider' -require 'qtutils' require_bundle 'ics', 'protocol' require_bundle 'ics', 'connection' require_bundle 'ics', 'match_handler' diff --git a/lib/plugins/loader.rb b/lib/plugins/loader.rb index f2fd598..9562a8d 100644 --- a/lib/plugins/loader.rb +++ b/lib/plugins/loader.rb @@ -52,4 +52,8 @@ class PluginLoader @instance ||= PluginLoader.internal_new end end + + def self.base_dir + BASE_DIR + end end diff --git a/lib/plugins/movelist/simple_movelist.rb b/lib/plugins/movelist/simple_movelist.rb index 0807d06..57a213e 100644 --- a/lib/plugins/movelist/simple_movelist.rb +++ b/lib/plugins/movelist/simple_movelist.rb @@ -5,6 +5,7 @@ # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. +require 'qtutils' require 'plugins/plugin' require 'observer_utils' diff --git a/test/plugins/test_loadable.rb b/test/plugins/test_loadable.rb new file mode 100644 index 0000000..aae1ab8 --- /dev/null +++ b/test/plugins/test_loadable.rb @@ -0,0 +1,32 @@ +# Copyright (c) 2009 Paolo Capriotti +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +require 'test/unit' +require 'plugins/loader' +require 'rbconfig' + +class TestLoadable < Test::Unit::TestCase + RUBY_EXE = Config::CONFIG['ruby_install_name'] + + def test_load_plugins + plugins = PluginLoader.base_dir + lib = File.join(plugins, '..') + + Dir[File.join(plugins, '*')].each do |f| + if File.directory?(f) + Dir[File.join(f, '*.rb')].each do |rb_file| + `#{RUBY_EXE} -I#{lib} #{rb_file}` + assert_equal 0, $? + end + end + end + end + +end + + + -- 2.11.4.GIT