Sha256: 48efb2c1eb7aad58f84f8deda503764181f9d8bfd0296aa8a8eb83014018065e
Contents?: true
Size: 1.35 KB
Versions: 5
Compression:
Stored size: 1.35 KB
Contents
module CabbageDoc class Processor class Error < StandardError; end class InvalidType < Error; end class InvalidPriority < Error; end PRIORITIES = [:high, :medium, :low].freeze class << self def inherited(klass) all[klass.to_s.split('::').last.downcase.to_sym] = klass end def priority(value = nil) if value.is_a?(Symbol) raise InvalidPriority, value unless PRIORITIES.include?(value) @_priority = value else @_priority end end def all @_all ||= {} end def perform(type) klass = all[type] if klass klass.new.perform else raise InvalidType, type end end def load! Dir.glob(File.join(File.dirname(__FILE__), 'processors', '*.rb')).sort.each do |processor| require(processor) end end end def perform raise NotImplementedError end protected def cache @_cache ||= Cache.new end def client @_client ||= Client.new(auth) end def auth @_auth ||= Authentication.new end def collection @_collection ||= Collection.instance.tap do |collection| collection.load! end end def config @_config ||= Configuration.instance end end Processor.load! end
Version data entries
5 entries across 5 versions & 1 rubygems