class CoverArt::Client
Constants
- ENDPOINT
Attributes
http[R]
Public Class Methods
new() { |f| ... }
click to toggle source
# File lib/coverart/client.rb, line 7 def initialize &block @http ||= Faraday.new url: ENDPOINT do |f| yield f if block_given? f.adapter Faraday.default_adapter end end
Public Instance Methods
back(mbid)
click to toggle source
# File lib/coverart/client.rb, line 35 def back mbid get "/release/#{ mbid }/back" end
front(mbid)
click to toggle source
# File lib/coverart/client.rb, line 31 def front mbid get "/release/#{ mbid }/front" end
get(url)
click to toggle source
# File lib/coverart/client.rb, line 14 def get url response = http.get url case response.status when 404 then nil when 200 then JSON.parse response.body when 300..310 if response.headers[:location].match /\.(jpg|jpeg|png|gif)/ response.headers[:location] else get response.headers[:location] end else raise "Unexpected response (#{ response.status }) at #{ url }" end end
group(mbid)
click to toggle source
# File lib/coverart/client.rb, line 39 def group mbid get "/release-group/#{ mbid }/front" end