Class: MusicBrainz::Configuration
- Inherits:
-
Object
- Object
- MusicBrainz::Configuration
- Defined in:
- lib/musicbrainz/configuration.rb
Constant Summary collapse
- DEFAULT_WEB_SERVICE_URL =
"http://musicbrainz.org/ws/2/"
- DEFAULT_QUERY_INTERVAL =
1.5
- DEFAULT_TRIES_LIMIT =
5
- DEFAULT_CACHE_PATH =
File.join(File.dirname(__FILE__), "..", "tmp", "cache")
- DEFAULT_PERFORM_CACHING =
false
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#app_version ⇒ Object
Returns the value of attribute app_version.
-
#cache_path ⇒ Object
Returns the value of attribute cache_path.
-
#contact ⇒ Object
Returns the value of attribute contact.
-
#perform_caching ⇒ Object
Returns the value of attribute perform_caching.
-
#query_interval ⇒ Object
Returns the value of attribute query_interval.
-
#tries_limit ⇒ Object
Returns the value of attribute tries_limit.
-
#web_service_url ⇒ Object
Returns the value of attribute web_service_url.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 17 18 19 20 |
# File 'lib/musicbrainz/configuration.rb', line 14 def initialize @web_service_url = DEFAULT_WEB_SERVICE_URL @query_interval = DEFAULT_QUERY_INTERVAL @tries_limit = DEFAULT_TRIES_LIMIT @cache_path = DEFAULT_CACHE_PATH @perform_caching = DEFAULT_PERFORM_CACHING end |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
3 4 5 |
# File 'lib/musicbrainz/configuration.rb', line 3 def app_name @app_name end |
#app_version ⇒ Object
Returns the value of attribute app_version.
3 4 5 |
# File 'lib/musicbrainz/configuration.rb', line 3 def app_version @app_version end |
#cache_path ⇒ Object
Returns the value of attribute cache_path.
3 4 5 |
# File 'lib/musicbrainz/configuration.rb', line 3 def cache_path @cache_path end |
#contact ⇒ Object
Returns the value of attribute contact.
3 4 5 |
# File 'lib/musicbrainz/configuration.rb', line 3 def contact @contact end |
#perform_caching ⇒ Object
Returns the value of attribute perform_caching.
3 4 5 |
# File 'lib/musicbrainz/configuration.rb', line 3 def perform_caching @perform_caching end |
#query_interval ⇒ Object
Returns the value of attribute query_interval.
3 4 5 |
# File 'lib/musicbrainz/configuration.rb', line 3 def query_interval @query_interval end |
#tries_limit ⇒ Object
Returns the value of attribute tries_limit.
3 4 5 |
# File 'lib/musicbrainz/configuration.rb', line 3 def tries_limit @tries_limit end |
#web_service_url ⇒ Object
Returns the value of attribute web_service_url.
3 4 5 |
# File 'lib/musicbrainz/configuration.rb', line 3 def web_service_url @web_service_url end |
Instance Method Details
#valid? ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/musicbrainz/configuration.rb', line 22 def valid? %w[ app_name app_version contact ].each do |param| unless instance_variable_defined?(:"@#{param}") raise Exception.new("Application identity parameter '#{param}' missing") end end unless tries_limit.nil? && query_interval.nil? raise Exception.new("'tries_limit' parameter must be 1 or greater") if tries_limit.to_i < 1 raise Exception.new("'query_interval' parameter must be greater than zero") if query_interval.to_f < 0 end if perform_caching raise Exception.new("'cache_path' parameter must be set") if cache_path.nil? end true end |