forked from mailman/mailman
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use the Configuration singleton to store config values - First config option is a application-wide logger
- Loading branch information
Showing
6 changed files
with
43 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Mailman | ||
class Configuration | ||
|
||
# Takes a block that is evaluated in the singleton to set options. | ||
def initialize(&block) | ||
class_eval(&block) | ||
end | ||
|
||
class << self | ||
|
||
# @return [Logger] the application's logger | ||
attr_accessor :logger | ||
|
||
def logger | ||
@logger ||= Logger.new(STDOUT) | ||
end | ||
|
||
end | ||
|
||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), '..', '/spec_helper')) | ||
|
||
describe Mailman::Configuration do | ||
|
||
it 'should have a default logger' do | ||
Mailman::Configuration.logger.instance_variable_get('@logdev').dev.should == STDOUT | ||
end | ||
|
||
it 'should store a custom logger using the class method' do | ||
Mailman::Configuration.logger = Logger.new(STDERR) | ||
Mailman::Configuration.logger.instance_variable_get('@logdev').dev.should == STDERR | ||
end | ||
|
||
it 'should store the custom logger using a block' do | ||
Mailman::Configuration.new { logger = Logger.new(STDERR) } | ||
Mailman::Configuration.logger.instance_variable_get('@logdev').dev.should == STDERR | ||
end | ||
|
||
end |