1
0
Fork 0
This commit is contained in:
Gregory Eremin 2011-10-06 16:39:14 +04:00
parent 1896c50e9c
commit 2f03500db6
5 changed files with 18 additions and 13 deletions

View File

@ -1 +1 @@
0.4.8
0.4.10

View File

@ -13,7 +13,7 @@ module MusicBrainz
url = WEB_SERVICE_URL + resourse.to_s.gsub('_', '-') + '/' + (params[:id].to_s || '')
params.delete(:id) unless params[:id].nil?
url << '?' + params.map{ |k, v|
k.to_s.gsub('_', '-') + '=' + (v.is_a?(Array) ? v.map{ |_| _.to_s.gsub('_', '-') }.join(',') : v.to_s)
k.to_s.gsub('_', '-') + '=' + (v.is_a?(Array) ? v.map{ |_| _.to_s.gsub('_', '-') }.join('+') : v.to_s)
}.join('&') unless params.empty?
self.get_contents url
end

View File

@ -1,6 +1,6 @@
module MusicBrainz
class Artist < MusicBrainz::Base
attr_accessor :id, :type, :name, :country, :date_begin, :date_end
attr_accessor :id, :type, :name, :country, :date_begin, :date_end, :urls
@release_groups
def release_groups
@ -14,7 +14,7 @@ module MusicBrainz
end
def self.find mbid
res = MusicBrainz.load :artist, :id => mbid
res = MusicBrainz.load :artist, :id => mbid, :inc => [:url_rels]
return nil if res.nil?
@artist = self.parse_xml(Nokogiri::XML(res))
end
@ -27,6 +27,10 @@ module MusicBrainz
@artist.country = self.safe_get_value(xml, 'artist > country')
@artist.date_begin = self.safe_get_value(xml, 'artist > life-span > begin')
@artist.date_end = self.safe_get_value(xml, 'artist > life-span > end')
@artist.urls = {}
xml.css('relation-list[target-type="url"] > relation').each do |rel|
@artist.urls[rel.attr('type').downcase.split(' ').join('_').to_sym] = rel.css('target').text
end
@artist
end

View File

@ -1,12 +1,12 @@
module MusicBrainz
class Release < MusicBrainz::Base
attr_accessor :id, :title, :status, :date, :country
attr_accessor :id, :title, :status, :format, :date, :country
@tracks
def tracks
if @tracks.nil? and not self.id.nil?
@tracks = []
Nokogiri::XML(MusicBrainz.load(:release, :id => self.id, :inc => [:recordings], :limit => 100)).css('medium-list > medium > track-list > track').each do |r|
Nokogiri::XML(MusicBrainz.load(:release, :id => self.id, :inc => [:recordings, :media], :limit => 100)).css('medium-list > medium > track-list > track').each do |r|
@tracks << MusicBrainz::Track.parse_xml(r)
end
end
@ -14,7 +14,7 @@ module MusicBrainz
end
def self.find mbid
xml = Nokogiri::XML(MusicBrainz.load(:release, :id => mbid)).css('release').first
xml = Nokogiri::XML(MusicBrainz.load(:release, :id => mbid, :inc => [:media])).css('release').first
self.parse_xml(xml) unless xml.nil?
end
@ -23,6 +23,7 @@ module MusicBrainz
@release.id = self.safe_get_attr(xml, nil, 'id')
@release.title = self.safe_get_value(xml, 'title')
@release.status = self.safe_get_value(xml, 'status')
@release.format = self.safe_get_value(xml, 'medium-list > medium > format')
date = xml.css('date').empty? ? '2030-12-31' : xml.css('date').text
if date.length == 0
date = '2030-12-31'

View File

@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{musicbrainz}
s.version = "0.4.8"
s.version = "0.4.10"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = [%q{Gregory Eremin}]
s.date = %q{2011-09-19}
s.authors = ["Gregory Eremin"]
s.date = %q{2011-09-20}
s.description = %q{MusicBrainz Web Service wrapper with ActiveRecord-style models}
s.email = %q{magnolia_fan@me.com}
s.extra_rdoc_files = [
@ -36,9 +36,9 @@ Gem::Specification.new do |s|
"test/test_musicbrainz.rb"
]
s.homepage = %q{http://github.com/magnolia-fan/musicbrainz}
s.licenses = [%q{MIT}]
s.require_paths = [%q{lib}]
s.rubygems_version = %q{1.8.8}
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.6.2}
s.summary = %q{MusicBrainz Web Service wrapper}
if s.respond_to? :specification_version then