class KM
Constants
- VERSION
Public Class Methods
alias(name, alias_to)
click to toggle source
# File lib/km.rb, line 67 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/km.rb, line 112 def host @host end
identify(id)
click to toggle source
# File lib/km.rb, line 50 def identify(id) @id = id end
init(key, options={})
click to toggle source
# File lib/km.rb, line 21 def init(key, options={}) default = { :host => @host, :log_dir => @log_dir, :to_stderr => @to_stderr, :use_cron => @use_cron, :env => set_env, } 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] @env = options[:env] log_dir_writable? rescue Exception => e log_error(e) end end
log_dir()
click to toggle source
# File lib/km.rb, line 109 def log_dir @log_dir end
record(action,props={})
click to toggle source
# File lib/km.rb, line 54 def record(action,props={}) props = hash_keys_to_str(props) begin return unless is_initialized_and_identified? return set(action) if action.class == Hash props.update('_n' => action) generate_query('e', props) rescue Exception => e log_error(e) end end
set(data)
click to toggle source
# File lib/km.rb, line 76 def set(data) begin return unless is_initialized_and_identified? generate_query('s', data) rescue Exception => e log_error(e) end end
set_env()
click to toggle source
# File lib/km.rb, line 44 def set_env @env = Rails.env if defined? Rails @env ||= ENV['RACK_ENV'] @env ||= 'production' end