1
0
Fork 0

Merge pull request #16 from Applicat/add_type_attribute_to_release

Adds type field to release model.
This commit is contained in:
Gregory Eremin 2013-01-25 05:39:09 -08:00
commit 7518325c00
6 changed files with 7 additions and 2 deletions

View File

@ -108,6 +108,7 @@ MusicBrainz::Release.find(id)
# Fields # Fields
{ {
:id => String, :id => String,
:type => String,
:title => String, :title => String,
:status => String, :status => String,
:format => String, :format => String,

View File

@ -6,6 +6,7 @@ module MusicBrainz
hash = { hash = {
id: (xml.attribute('id').value rescue nil), id: (xml.attribute('id').value rescue nil),
type: (xml.xpath('./release-group').attribute('type').value rescue nil),
title: (xml.xpath('./title').text rescue nil), title: (xml.xpath('./title').text rescue nil),
status: (xml.xpath('./status').text rescue nil), status: (xml.xpath('./status').text rescue nil),
country: (xml.xpath('./country').text rescue nil), country: (xml.xpath('./country').text rescue nil),

View File

@ -1,6 +1,7 @@
module MusicBrainz module MusicBrainz
class Release < BaseModel class Release < BaseModel
field :id, String field :id, String
field :type, String
field :title, String field :title, String
field :status, String field :status, String
field :format, String field :format, String
@ -20,7 +21,7 @@ module MusicBrainz
class << self class << self
def find(id) def find(id)
client.load(:release, { id: id, inc: [:media] }, { client.load(:release, { id: id, inc: [:media, :release_groups] }, {
binding: :release, binding: :release,
create_model: :release create_model: :release
}) })

View File

@ -9,7 +9,7 @@ module MusicBrainz
alias_method :disambiguation, :desc alias_method :disambiguation, :desc
def releases def releases
@releases ||= client.load(:release, { release_group: id, inc: [:media], limit: 100 }, { @releases ||= client.load(:release, { release_group: id, inc: [:media, :release_groups], limit: 100 }, {
binding: :release_group_releases, binding: :release_group_releases,
create_models: :release, create_models: :release,
sort: :date sort: :date

View File

@ -60,6 +60,7 @@ describe MusicBrainz::ReleaseGroup do
releases.first.title.should == "Empire" releases.first.title.should == "Empire"
releases.first.date.should == Date.new(2006, 8, 28) releases.first.date.should == Date.new(2006, 8, 28)
releases.first.country.should == "GB" releases.first.country.should == "GB"
releases.first.type.should == "Album"
end end
end end
end end

View File

@ -24,6 +24,7 @@ describe MusicBrainz::Release do
release.asin.should == 'B002NOYX6I' release.asin.should == 'B002NOYX6I'
release.barcode.should == '602527197692' release.barcode.should == '602527197692'
release.quality.should == 'normal' release.quality.should == 'normal'
release.type.should == 'Album'
end end
it "gets correct release tracks" do it "gets correct release tracks" do