diff --git a/lib/playbot.rb b/lib/playbot.rb index 3f9203bfe08d40aae8fff42dc238e88f46fca224..53b94113c263fe27720c8c51d9537cbe661f3ad1 100644 --- a/lib/playbot.rb +++ b/lib/playbot.rb @@ -3,9 +3,8 @@ require 'net/yail/irc_bot' require 'site_plugin' -# +# -- # Add plugins folder to LOAD_PATH and subsequently require all plugins. -# dir = '../plugins' $LOAD_PATH << dir Dir[File.join(dir, '*.rb')].each {|file| require File.basename(file) } diff --git a/lib/site_plugin.rb b/lib/site_plugin.rb index c59d975f5322f22970fe8dd826896411ed6901d1..3ac1c3856fb0437456aba29e07b2cf686331f0e2 100644 --- a/lib/site_plugin.rb +++ b/lib/site_plugin.rb @@ -1,3 +1,6 @@ +# Implement a plugin system. +# +# Each plugin have to inherite from this class and implement a can_handle?(site) method. class SitePlugin @@repository = [] @@ -9,7 +12,13 @@ class SitePlugin @@repository << target end + # Return the plugin that can handle a given site. def self.for_site(site) @@repository.find {|handler| handler.can_handle? site } end + + # A place holder method. This method *must* be implemented in the subclasses. + def can_handle?(site) + raise "Method not implemented !" + end end