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(name, options = {}, &block) ⇒ Object

Returns an instance of the given processor type.

Examples:

A simple file adapter

Yell::Adapters.new( :file )

Raises:



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/yell/adapters.rb', line 64

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

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

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

.register(name, klass) ⇒ Object

Register your own adapter here

Examples:

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


56
57
58
# File 'lib/yell/adapters.rb', line 56

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