diff --git a/lib/site_plugin.rb b/lib/site_plugin.rb index a756a3e3458188af0070851ecbd40e9b974acc2e..e319890a5eb7301c4cee2c3cd965b3647226fbfb 100644 --- a/lib/site_plugin.rb +++ b/lib/site_plugin.rb @@ -17,8 +17,14 @@ class SitePlugin @@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 !" + # Raise an error message if the missing method should have been implemented + # in the subclasse. This possible methode are: + # * <tt>#can_handle?</tt> + # * <tt>#get</tt> + # + # They *must* be implemented by the subclasse. + def method_missing(method) + return unless ['can_handle?', 'get'].include(method) + raise "Method #{method} not implemented !" end end diff --git a/plugins/youtube_plugin.rb b/plugins/youtube_plugin.rb index 262b83d4c01e931e0871a6f3994cf751ac1bf81f..6bc4710d24050a652538ca327d3fc56f0e6a239c 100644 --- a/plugins/youtube_plugin.rb +++ b/plugins/youtube_plugin.rb @@ -3,13 +3,13 @@ require_relative '../lib/site_plugin.rb' require 'rubygems' require 'youtube_it' +# SitePlugin for YouTube class YoutubePlugin < SitePlugin def self.can_handle?(site) site =~ /^http:\/\/((www.)?youtube.(fr|com)\/watch\?v=|youtu\.be\/)[a-zA-Z0-9]+$/ end public - # Store a new youtube api client def initialize @client = YouTubeIt::Client.new end