Sha256: 7ffa00fe4da79bbd0db7041db60106db7a4e5e85e03d06a6b5717f641312e0d2
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 KB
Contents
# # A file with general support functions used by most files in the project. # require 'logger' class File # :nodoc: # for consistency with StringIO and others. makes more sense than forcing # them to provide a #stat def size stat.size end end class Symbol # :nodoc: def to_proc proc { |a| a.send self } end end module Enumerable # :nodoc: # 1.9 backport def group_by hash = Hash.new { |hash, key| hash[key] = [] } each { |item| hash[yield(item)] << item } hash end def sum initial=0 inject(initial) { |a, b| a + b } end end class Logger # :nodoc: # A helper method for creating <tt>Logger</tt>s which produce call stack # in their output def self.new_with_callstack logdev=STDERR log = Logger.new logdev log.level = WARN log.formatter = proc do |severity, time, progname, msg| # find where we were called from, in our code callstack = caller.dup callstack.shift while callstack.first =~ /\/logger\.rb:\d+:in/ from = callstack.first.sub(/:in `(.*?)'/, ":\\1") "[%s %s]\n%-7s%s\n" % [time.strftime('%H:%M:%S'), from, severity, msg.to_s] end log end end
Version data entries
5 entries across 5 versions & 2 rubygems
Version | Path |
---|---|
ruby-msg-1.2.17.1 | lib/support.rb |
ruby-msg-1.2.17.2 | lib/support.rb |
ruby-msg-1.2.17 | lib/support.rb |
ruby-msg-1.2.17.3 | lib/support.rb |
ruby-ole-1.2.1 | lib/ole/support.rb |