Refactored Release and Track models, fixed tests
This commit is contained in:
@@ -6,7 +6,7 @@ module MusicBrainz
|
||||
class << self
|
||||
def model(xml)
|
||||
{
|
||||
:id => safe_get_attr(xml, nil, "id") || safe_get_attr(xml, "release-group", "id"),
|
||||
:id => safe_get_attr(xml, nil, "id") || safe_get_attr(xml, "release", "id"),
|
||||
:title => safe_get_value(xml, "title"),
|
||||
:status => safe_get_value(xml, "status"),
|
||||
:country => safe_get_value(xml, "country"),
|
||||
@@ -14,6 +14,14 @@ module MusicBrainz
|
||||
:date => safe_get_value(xml, "date")
|
||||
}
|
||||
end
|
||||
|
||||
def tracks(xml)
|
||||
tracks = []
|
||||
xml.css("medium-list > medium > track-list > track").each do |r|
|
||||
tracks << MusicBrainz::Parsers::Track.model(r)
|
||||
end
|
||||
tracks
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,14 @@ module MusicBrainz
|
||||
module Parsers
|
||||
class Track < Base
|
||||
class << self
|
||||
|
||||
def model(xml)
|
||||
{
|
||||
:position => safe_get_value(xml, "position"),
|
||||
:recording_id => safe_get_attr(xml, "recording", "id"),
|
||||
:title => safe_get_value(xml, "recording > title"),
|
||||
:length => safe_get_value(xml, "length") || safe_get_value(xml, "recording > length")
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user