lib/musicbrainz/bindings/artist.rb in musicbrainz-0.7.5 vs lib/musicbrainz/bindings/artist.rb in musicbrainz-0.7.6

- old
+ new

@@ -1,21 +1,21 @@ # encoding: UTF-8 module MusicBrainz module Bindings module Artist def parse(xml) - xml = xml.xpath('./artist') unless xml.xpath('./artist').empty? + xml = xml.xpath('./artist') + + return {} if xml.empty? + { id: (xml.attribute('id').value rescue nil), type: (xml.attribute('type').value rescue nil), name: (xml.xpath('./name').text.gsub(/[`’]/, "'") rescue nil), country: (xml.xpath('./country').text rescue nil), date_begin: (xml.xpath('./life-span/begin').text rescue nil), - date_end: (xml.xpath('./life-span/end').text rescue nil), - urls: (Hash[xml.xpath('./relation-list[@target-type="url"]/relation').map{ |xml| - [xml.attribute('type').value.downcase.split(" ").join("_").to_sym, xml.xpath('./target').text] - }] rescue {}) - } + date_end: (xml.xpath('./life-span/end').text rescue nil) + }.merge(Relations.parse(xml)) end extend self end end