Module: Yell::Adapters

Defined in:
lib/yell/adapters.rb,
lib/yell/adapters/io.rb,
lib/yell/adapters/base.rb,
lib/yell/adapters/file.rb,
lib/yell/adapters/streams.rb,
lib/yell/adapters/datefile.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Base, Collection, Datefile, File, Io, Stderr, Stdout

Class Method Summary collapse

Class Method Details

.new(type, options = {}, &block) ⇒ Object

Returns an instance of the given processor type.

Examples:

A simple file adapter

Yell::Adapters.new( :file )

Raises:



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/yell/adapters.rb', line 61

def self.new( type, options = {}, &block )
  return type if type.is_a?(Yell::Adapters::Base)

  adapter = case type
  when STDOUT then @adapters[:stdout]
  when STDERR then @adapters[:stderr]
  else @adapters[type.to_sym]
  end

  raise AdapterNotFound.new(type) if adapter.nil?
  adapter.new(options, &block)
end

.register(name, klass) ⇒ Object

Register your own adapter here

Examples:

Yell::Adapters.register( :myadapter, MyAdapter )


53
54
55
# File 'lib/yell/adapters.rb', line 53

def self.register( name, klass )
  @adapters[name.to_sym] = klass
end