lib/ztk/base.rb in ztk-0.0.8 vs lib/ztk/base.rb in ztk-0.0.9

- old
+ new

@@ -20,11 +20,11 @@ require "ostruct" module ZTK - # ZTK::Base error class + # ZTK::Base Error Class class BaseError < Error; end # ZTK Base Class # # This is the base class inherited by most of the other classes in this @@ -33,22 +33,22 @@ # # You should never interact with this class directly; you should inherit it # and extend functionality as appropriate. class Base - # @param [Hash] config configuration options hash - # @option config [IO] :stdout instance of IO to be used for STDOUT - # @option config [IO] :stderr instance of IO to be used for STDERR - # @option config [IO] :stdin instance of IO to be used for STDIN - # @option config [Logger] :logger instance of Logger to be used for logging + # @param [Hash] config Configuration options hash. + # @option config [IO] :stdout Instance of IO to be used for STDOUT. + # @option config [IO] :stderr Instance of IO to be used for STDERR. + # @option config [IO] :stdin Instance of IO to be used for STDIN. + # @option config [Logger] :logger Instance of Logger to be used for logging. def initialize(config={}) - defined?(Rails) and rails_logger = Rails.logger + # defined?(Rails) and rails_logger = Rails.logger @config = OpenStruct.new({ :stdout => $stdout, :stderr => $stderr, :stdin => $stdin, - :logger => (rails_logger || $logger) + :logger => $logger }.merge(config)) @config.stdout.respond_to?(:sync=) and @config.stdout.sync = true @config.stderr.respond_to?(:sync=) and @config.stderr.sync = true @config.stdin.respond_to?(:sync=) and @config.stdin.sync = true @@ -83,10 +83,10 @@ # @yieldreturn [String] The message to log. def log(method_name, &block) if block_given? @config.logger and @config.logger.method(method_name.to_sym).call { yield } else - raise(Error, "You must supply a block to the log method!") + raise BaseError, "You must supply a block to the log method!" end end end