Sha256: b4c379daab2edf2f20e02f290288643f0a414bfd12a3a2707f30a74ba99df90e

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

require 'httparty'
require "howareya/errors"
require "howareya/configuration"
require "howareya/version"

module Howareya
  class << self
    attr_accessor :configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configure
    yield(configuration)
  end

  def self.details
    { api_key: @configuration.api_key, url: @configuration.url}
  end

  def self.reset_configuration
    @configuration.reset
  end

  def self.record_metric key, value
    raise Howareya::MissingConfigError unless @configuration.url && @configuration.api_key
    response = ::HTTParty.post(@configuration.url, :body => { :api_key => @configuration.api_key, 
                                              :key => key, 
                                              :value => value })
    raise Howareya::MissingMetricError if response.code === 404
    raise Howareya::BadAPIKeyError if response.code === 401
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
howareya-0.1.3 lib/howareya.rb