class Squirtgun::Gun

TODO: decide if this is a shitty name because its all Squirtgun::Squirtgun..

Public Instance Methods

report(options={}) click to toggle source
# File lib/squirtgun.rb, line 25
def report(options={})
  return if options[:context].nil? or options[:value].nil?


  # TODO: add message format testing?  Guzzler currenlty expects [context]:[value]..

  options[:project_id] ||= Squirtgun::Config.project_id

  sock = UDPSocket.new
  sock.send({:stat => options, :hmac => encode_packet(options[:context] + options[:value], Squirtgun::Config.secret_key)}.to_json, 0, Squirtgun::Config.listener, Squirtgun::Config.listener_port)
  sock.close
end

Private Instance Methods

encode_packet(data, key) click to toggle source
# File lib/squirtgun.rb, line 39
def encode_packet(data, key)
  OpenSSL::HMAC.hexdigest('sha1', key, data)
end