require 'transistor/version' require 'transistor/client' module Transistor class << self attr_accessor :config end class Config attr_accessor :id, :secret, :host, :secure def initialize @host = 'api.transistor.fm' @secure = true @tracking_url = 'track.transistor.fm/:entry_id.:format/:url' end def base_url if self.secure "https://#{self.host}" else "http://#{self.host}" end end def credentials { id: self.id, key: self.secret, algorithm: 'sha256' } end def user_agent "Transistor Ruby Client, Version #{Transistor::Version}" end def protocol if self.secure 'https' else 'http' end end def tracking_url(entry_id, format, url) full_url = @tracking_url .gsub(':entry_id', entry_id.to_s) .gsub(':format', format.to_s) .gsub(':url', url) [self.protocol, '://', full_url].join() end end def self.setup self.config ||= Config.new yield(config) end end