class UnderFire::Configuration

Configuration information.

Attributes

config_info[R]

Public Class Methods

new() click to toggle source
# File lib/under_fire/configuration.rb, line 10
def initialize
  @config_info = load_config
end

Public Instance Methods

api_url() click to toggle source

Gracenote API url for use in queries. @return [String]

# File lib/under_fire/configuration.rb, line 40
def api_url
  "https://c#{client_id_string}.web.cddbp.net/webapi/xml/1.0/"
end
authorized?() click to toggle source

Returns true if user has a user_id @return [Boolean]

# File lib/under_fire/configuration.rb, line 46
def authorized?
  user_id != nil
end
client_id() click to toggle source

Gracenote client id stored in environment variable. @return [String]

# File lib/under_fire/configuration.rb, line 16
def client_id
  config_info.fetch(:client_id, nil).to_s
end
client_id_string() click to toggle source

Part of client id before the hyphen (used by api_url). @return [String]

# File lib/under_fire/configuration.rb, line 22
def client_id_string
  client_id.split('-')[0]
end
client_tag() click to toggle source

Part of client id after hyphen @return [String]

# File lib/under_fire/configuration.rb, line 28
def client_tag
  client_id.split('-')[1]
end
configured?() click to toggle source

Returns true if user has a client_id and user_id @return [Boolean]

# File lib/under_fire/configuration.rb, line 52
def configured?
  client_id != nil && !authorized?
end
reset() click to toggle source
# File lib/under_fire/configuration.rb, line 56
def reset
  initialize
end
user_id() click to toggle source

Gracenote user id @return [String]

# File lib/under_fire/configuration.rb, line 34
def user_id
  config_info.fetch(:user_id, nil).to_s
end

Private Instance Methods

load_config() click to toggle source
# File lib/under_fire/configuration.rb, line 62
def load_config
  {:client_id => ENV['GRACENOTE_CLIENT_ID'],
   :user_id => ENV['GRACENOTE_USER_ID']}
end