Class: FanartTv::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/fanart_tv/configuration.rb

Constant Summary collapse

DEFAULT_QUERY_INTERVAL =
1.5
DEFAULT_TRIES_LIMIT =
5
DEFAULT_CACHE_PATH =
File.join(File.dirname(__FILE__), "..", "tmp", "cache")
DEFAULT_PERFORM_CACHING =
false
DEFAULT_WEBSERVICE_URL_ARTIST =
"http://api.fanart.tv/webservice/artist/%{api_key}/%{musicbrainz_id}/JSON/%{type}/%{sort}/%{limit}/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



14
15
16
17
18
19
20
# File 'lib/fanart_tv/configuration.rb', line 14

def initialize
  @webservice_url_artist = DEFAULT_WEBSERVICE_URL_ARTIST
  @query_interval = DEFAULT_QUERY_INTERVAL
  @tries_limit = DEFAULT_TRIES_LIMIT
  @cache_path = DEFAULT_CACHE_PATH
  @perform_caching = DEFAULT_PERFORM_CACHING
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



3
4
5
# File 'lib/fanart_tv/configuration.rb', line 3

def api_key
  @api_key
end

#app_nameObject

Returns the value of attribute app_name.



3
4
5
# File 'lib/fanart_tv/configuration.rb', line 3

def app_name
  @app_name
end

#app_versionObject

Returns the value of attribute app_version.



3
4
5
# File 'lib/fanart_tv/configuration.rb', line 3

def app_version
  @app_version
end

#cache_pathObject

Returns the value of attribute cache_path.



3
4
5
# File 'lib/fanart_tv/configuration.rb', line 3

def cache_path
  @cache_path
end

#contactObject

Returns the value of attribute contact.



3
4
5
# File 'lib/fanart_tv/configuration.rb', line 3

def contact
  @contact
end

#perform_cachingObject

Returns the value of attribute perform_caching.



3
4
5
# File 'lib/fanart_tv/configuration.rb', line 3

def perform_caching
  @perform_caching
end

#query_intervalObject

Returns the value of attribute query_interval.



3
4
5
# File 'lib/fanart_tv/configuration.rb', line 3

def query_interval
  @query_interval
end

#tries_limitObject

Returns the value of attribute tries_limit.



3
4
5
# File 'lib/fanart_tv/configuration.rb', line 3

def tries_limit
  @tries_limit
end

#webservice_url_artistObject

Returns the value of attribute webservice_url_artist.



3
4
5
# File 'lib/fanart_tv/configuration.rb', line 3

def webservice_url_artist
  @webservice_url_artist
end

Instance Method Details

#user_agent_stringObject



27
28
29
30
31
32
33
# File 'lib/fanart_tv/configuration.rb', line 27

def user_agent_string
  %w[ app_name app_version contact ].each do |param|
    raise "#{param} must be set" if instance_variable_get("@#{param}").nil?
  end

  "#{@app_name}/#{@app_version} ( #{@contact} )"
end