Sha256: 0d3b87eed3cd0cda7bbdf16a8be02990558cc5986d54afc921f6fd409dfa8fff

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

# Copyright (C) 2006-2008 by Sergio Pistone
# sergio_pistone@yahoo.com.ar
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

require "cgi"

module PluginAdapter

	# Hack to make module methods become class methods when the module gets included
	def PluginAdapter.included( including )
		if including.is_a?( Class )
			including.extend( ClassMethods ) # adds class methods
		else # if including.is_a?( Module )
			including::ClassMethods.append_class_methods( self )
		end
	end

	# Methods under this module will became class methods when the module gets included
	# Note: don't use def self.<method name> but just <method name>
	module ClassMethods
		def ClassMethods.append_class_methods( mod )
			include mod::ClassMethods
		end

		def plugin_name()
			return site_name()
		end

		def notify( message )
			puts plugin_name() + ": " + message.gsub( /\/?<[^>]+>/, "" )
		end
	end

	def plugin_name()
		return self.class.plugin_name()
	end

	def notify( message )
		self.class.notify( message )
	end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
lyrics-0.0.3 lib/lyrics/cli/pluginadapter.rb
lyrics-ebook-0.1 lib/wiki_lyrics/cli/pluginadapter.rb
lyrics-0.0.2 lib/lyrics/cli/pluginadapter.rb