lib/oboe/api/util.rb in oboe-2.3.2 vs lib/oboe/api/util.rb in oboe-2.3.3.7
- old
+ new
@@ -1,8 +1,10 @@
# Copyright (c) 2013 AppNeta, Inc.
# All rights reserved.
+require 'pp'
+
module Oboe
module API
module Util
BACKTRACE_CUTOFF = 200
@@ -64,8 +66,52 @@
return true if addr_port.to_s.match(h.to_s)
end
false
end
+
+ # Internal: Pretty print a list of arguments for reporting
+ #
+ # args - the list of arguments to work on
+ #
+ # Returns a pretty string representation of arguments
+ def pps(*args)
+ old_out = $stdout
+ begin
+ s = StringIO.new
+ $stdout = s
+ pp(*args)
+ ensure
+ $stdout = old_out
+ end
+ s.string
+ end
+
+ # Internal: Determine a string to report representing klass
+ #
+ # args - an instance of a Class, a Class or a Module
+ #
+ # Returns a string representation of klass
+ def get_class_name(klass)
+ kv = {}
+ if klass.to_s =~ /::/
+ klass.class.to_s.rpartition('::').last
+ else
+ if klass.is_a?(Class) and klass.is_a?(Module)
+ # Class
+ kv["Class"] = klass.to_s
+
+ elsif (not klass.is_a?(Class) and not klass.is_a?(Module))
+ # Class instance
+ kv["Class"] = klass.class.to_s
+
+ else
+ # Module
+ kv["Module"] = klass.to_s
+ end
+ end
+ kv
+ end
+
end
end
end