fantasdic r326 - in trunk: . lib lib/fantasdic lib/fantasdic/sources



Author: mblondel
Date: Fri Aug 22 18:17:41 2008
New Revision: 326
URL: http://svn.gnome.org/viewvc/fantasdic?rev=326&view=rev

Log:
    * lib/fantasdic/source_base.rb: Renamed load_plugins to load_sources. Also
    the sources used to be added automatically to the list of available sources.
    This was detected when Source::Base was inherited. This behavior was
    changed. Sources now need to be declared with register_source. This allows
    to inherit from Source::Base without adding a source.
    * lib/fantasdic.rb: Renamed load_plugins to load_sources.
    * lib/fantasdic/sources/dict_server.rb: Call register_source.
    * lib/fantasdic/sources/google_translate.rb: Ditto.


Modified:
   trunk/ChangeLog
   trunk/lib/fantasdic.rb
   trunk/lib/fantasdic/source_base.rb
   trunk/lib/fantasdic/sources/dict_server.rb
   trunk/lib/fantasdic/sources/google_translate.rb

Modified: trunk/lib/fantasdic.rb
==============================================================================
--- trunk/lib/fantasdic.rb	(original)
+++ trunk/lib/fantasdic.rb	Fri Aug 22 18:17:41 2008
@@ -103,7 +103,7 @@
     DESCRIPTION = _("Look up words in various dictionary sources")
 
     def self.main
-        Source::Base::load_plugins
+        Source::Base::load_sources
 
         options = CommandLineOptions.instance
 

Modified: trunk/lib/fantasdic/source_base.rb
==============================================================================
--- trunk/lib/fantasdic/source_base.rb	(original)
+++ trunk/lib/fantasdic/source_base.rb	Fri Aug 22 18:17:41 2008
@@ -58,8 +58,8 @@
         class << self
             attr_reader :registered_sources
 
-            def inherited(child)
-                @registered_sources << child
+            def register_source(source)
+                @registered_sources << source
             end
 
             def short_name
@@ -267,7 +267,7 @@
             end
         end
 
-        def self.load_plugins
+        def self.load_sources
             # Load found source plugins (system-wide and user-wide)
             [Config::SOURCE_DIR, Config::PERSONAL_SOURCE_DIR].each do |dir|
                 Dir["#{dir}/*.rb"].each { |f| load f }

Modified: trunk/lib/fantasdic/sources/dict_server.rb
==============================================================================
--- trunk/lib/fantasdic/sources/dict_server.rb	(original)
+++ trunk/lib/fantasdic/sources/dict_server.rb	Fri Aug 22 18:17:41 2008
@@ -333,3 +333,5 @@
 
 end
 end
+
+Fantasdic::Source::Base.register_source(Fantasdic::Source::DictServer)
\ No newline at end of file

Modified: trunk/lib/fantasdic/sources/google_translate.rb
==============================================================================
--- trunk/lib/fantasdic/sources/google_translate.rb	(original)
+++ trunk/lib/fantasdic/sources/google_translate.rb	Fri Aug 22 18:17:41 2008
@@ -103,4 +103,6 @@
     end
 
 end
-end
\ No newline at end of file
+end
+
+Fantasdic::Source::Base.register_source(Fantasdic::Source::GoogleTranslate)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]