Class: Homophone::Service::DummySpotify

Inherits:
Object
  • Object
show all
Includes:
MusicianRetriever
Defined in:
lib/homophone/service.rb

Instance Method Summary collapse

Methods included from MusicianRetriever

#musician

Instance Method Details

#get(url) ⇒ Object

Raises:

  • (ArgumentError)


31
32
33
34
35
36
37
38
39
# File 'lib/homophone/service.rb', line 31

def get(url)
  uri = URI(url)
  params = begin CGI::parse(uri.query) rescue nil end
  path_parts = uri.path.split('/').reject { |p| p == '' }
  path = cassette_path(path_parts, params)
  raise ArgumentError, "No cassette for #{url}" unless path
  path = File.join(source_path, "#{path}.yml")
  JSON.load(YAML.load(IO.read(path))['http_interactions'][0]['response']['body']['string'])
end