lib/oboe/api/util.rb in oboe-2.7.1.7-java vs lib/oboe/api/util.rb in oboe-2.7.2.fuchs1

- old
+ new

@@ -3,31 +3,35 @@ require 'pp' module Oboe module API + ## + # General utility methods for the gem module Util BACKTRACE_CUTOFF = 200 # Internal: Check whether the provided key is reserved or not. Reserved # keys are either keys that are handled by liboboe calls or the oboe gem. # # key - the key to check. # # Return a boolean indicating whether or not key is reserved. def valid_key?(key) - !%w[ Label Layer Edge Timestamp Timestamp_u ].include? key.to_s + !%w(Label Layer Edge Timestamp Timestamp_u).include? key.to_s end # Internal: Get the current backtrace. # # ignore - Number of frames to ignore at the end of the backtrace. Use # when you know how many layers deep in oboe the call is being # made. # # Returns a string with each frame of the backtrace separated by '\r\n'. - def backtrace(ignore=1) + # + # FIXME: ignore is not currently used (see BACKTRACE_CUTOFF) + def backtrace(_ignore = 1) trim_backtrace(Kernel.caller).join("\r\n") end # Internal: Trim a backtrace to a manageable size # @@ -57,11 +61,11 @@ return false unless Oboe::Config.blacklist # Ensure that the blacklist is an array unless Oboe::Config.blacklist.is_a?(Array) val = Oboe::Config[:blacklist] - Oboe::Config[:blacklist] = [ val.to_s ] + Oboe::Config[:blacklist] = [val.to_s] end Oboe::Config.blacklist.each do |h| return true if addr_port.to_s.match(h.to_s) end @@ -91,27 +95,27 @@ # 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) + if klass.is_a?(Class) && klass.is_a?(Module) # Class - kv["Class"] = klass.to_s + kv['Class'] = klass.to_s - elsif (not klass.is_a?(Class) and not klass.is_a?(Module)) + elsif (!klass.is_a?(Class) && !klass.is_a?(Module)) # Class instance - kv["Class"] = klass.class.to_s + kv['Class'] = klass.class.to_s else # Module - kv["Module"] = klass.to_s + kv['Module'] = klass.to_s end end kv end - end end end