module Shmidi

Constants

JSON_CREATE_ID
PROFILE
TRACE
TRACE_EXTERNAL
TRACE_INTERNAL
VERSION

Public Class Methods

DUMP(obj, opts={}) click to toggle source
# File lib/shmidi.rb, line 61
def self.DUMP(obj, opts={})
  Oj.dump((obj.kind_of?(Base) ? obj.to_hash : obj), opts)
end
JSON_PARSE(str, opts = {:warn => true}) click to toggle source
# File lib/shmidi.rb, line 65
def self.JSON_PARSE str, opts = {:warn => true}
  return nil if str.nil?
  Oj.load(str, opts)
rescue
  if opts[:warn]
    Shmidi.ON_EXCEPTION
    TRACE {"#{str}".force_encoding(Encoding::UTF_8)}
  end
  nil
end
ON_EXCEPTION() click to toggle source
# File lib/shmidi.rb, line 47
def self.ON_EXCEPTION
  back = $!.backtrace.join("\n\t\t")
  @@trace_queue.push("ERROR\t#{$!.class.name}:#{$!}\n\t\t#{back}")
end
PRETTY(obj) click to toggle source
# File lib/shmidi.rb, line 76
def self.PRETTY obj
  DUMP((obj.kind_of?(String) ? JSON_PARSE(obj) : obj), :indent=>2)
end
TRACE() { || ... } click to toggle source
# File lib/shmidi.rb, line 32
def self.TRACE
  return nil unless TRACE
  @@trace_queue.push(yield)
end
TRACE_EXTERNAL() { || ... } click to toggle source
# File lib/shmidi.rb, line 37
def self.TRACE_EXTERNAL
  return nil unless TRACE_EXTERNAL
  @@trace_queue.push(yield)
end
TRACE_INTERNAL() { || ... } click to toggle source
# File lib/shmidi.rb, line 42
def self.TRACE_INTERNAL
  return nil unless TRACE_INTERNAL
  @@trace_queue.push(yield)
end
timestamp() click to toggle source
# File lib/shmidi.rb, line 15
def self.timestamp
  t = Time.now
  (t.to_i * 1000) + (t.usec / 1000)
end