Sha256: 47ebd80be6dc8e99360330bd788f0d2b7a791a22a907033e4ef7b8665160d88e
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module Murlsh # Superclass for plugins. How plugins are registered. # # Hooks: # * add_pre - called before a new url is saved # run arguments (url, config hash) # * add_post - called after a new url is saved # run arguments (config hash) # * html_parse - called to parse HTML using something like Hpricot or Nokogiri # run arguments (parseable) # * url_display_add - called to display additional information after urls # run arguments (markup builder, url, config hash) class Plugin # Called when a plugin class inherits from this class (the way plugins # are registered). def self.inherited(child) registered << child end # Get registered plugins by hook (add_pre, add_post, etc.) def self.hooks(name) matches = registered.select { |p| p.hook == name }. sort { |a,b| a.to_s <=> b.to_s } if block_given? matches.each { |p| yield p } end matches end @registered = [] class << self; attr_reader :hook attr_reader :registered end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
murlsh-1.0.0 | lib/murlsh/plugin.rb |