class KMTS

Constants

DEFAULT_TRACKING_SERVER
PROTOCOL_MATCHER
VERSION

Public Class Methods

alias(name, alias_to) click to toggle source
# File lib/kmts.rb, line 73
def alias(name, alias_to)
  begin
    return unless is_initialized?
    generate_query('a', { '_n' => alias_to, '_p' => name }, false)
  rescue Exception => e
    log_error(e)
  end
end
host() click to toggle source
# File lib/kmts.rb, line 118
def host
  @host
end
init(key, options={}) click to toggle source
# File lib/kmts.rb, line 27
def init(key, options={})
  default = {
    :host      => @host,
    :log_dir   => @log_dir,
    :to_stderr => @to_stderr,
    :use_cron  => @use_cron,
    :dryrun    => @dryrun,
    :env       => set_env,
    :force_key => @force_key
  }
  options = default.merge(options)

  begin
    @key       = key
    @host      = options[:host]
    @log_dir   = options[:log_dir]
    @use_cron  = options[:use_cron]
    @to_stderr = options[:to_stderr]
    @dryrun    = options[:dryrun]
    @env       = options[:env]
    @force_key = options[:force_key]
    log_dir_writable?
  rescue Exception => e
    log_error(e)
  end
end
log_dir() click to toggle source
# File lib/kmts.rb, line 115
def log_dir
  @log_dir
end
record(id, action, props={}) click to toggle source
# File lib/kmts.rb, line 60
def record(id, action, props={})
  props = hash_keys_to_str(props)
  begin
    return unless is_initialized?
    return set(id, action) if action.class == Hash

    props.update('_n' => action)
    generate_query('e', props, id)
  rescue Exception => e
    log_error(e)
  end
end
set(id, data) click to toggle source
# File lib/kmts.rb, line 82
def set(id, data)
  begin
    return unless is_initialized?
    generate_query('s', data, id)
  rescue Exception => e
    log_error(e)
  end
end
set_env() click to toggle source
# File lib/kmts.rb, line 54
def set_env
  @env = Rails.env if defined? Rails
  @env ||= ENV['RACK_ENV']
  @env ||= 'production'
end