From 81f471612cc9fd2232b3bcf535173724595ccac0 Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@gmail.com> Date: Wed, 2 Jan 2013 00:03:05 +0100 Subject: [PATCH] Tests unitaires et doc --- lib/site_plugin.rb | 12 +++++++++--- plugins/youtube_plugin.rb | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/site_plugin.rb b/lib/site_plugin.rb index a756a3e..e319890 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 262b83d..6bc4710 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 -- GitLab