musicbrainz 0.4.10 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.10
1
+ 0.5.0
@@ -2,16 +2,31 @@ module MusicBrainz
2
2
  @@last_query_time = 0
3
3
  @@query_interval = 1.5 # Min: 1.0 Safe: 1.5
4
4
 
5
+ WEB_SERVICE_URL = 'http://musicbrainz.org/ws/2/'
6
+ USER_AGENT = "gem musicbrainz (https://github.com/magnolia-fan/musicbrainz) @ " + Socket.gethostname
7
+
5
8
  def self.query_interval= sec
6
9
  @@query_interval = sec.to_f
7
10
  end
11
+
12
+ def self.load resourse, params = {}
13
+ url = WEB_SERVICE_URL + resourse.to_s.gsub('_', '-') + '/' + (params[:id].to_s || '')
14
+ params.delete(:id) unless params[:id].nil?
15
+ url << '?' + params.map{ |k, v|
16
+ k.to_s.gsub('_', '-') + '=' + (v.is_a?(Array) ? v.map{ |_| _.to_s.gsub('_', '-') }.join('+') : v.to_s)
17
+ }.join('&') unless params.empty?
18
+ self.get_contents url
19
+ end
20
+
21
+ private
8
22
 
9
- def self.load url
10
- sleep @@query_interval - (Time.now.to_f - @@last_query_time) if Time.now.to_f - @@last_query_time < @@query_interval
23
+ def self.get_contents url
24
+ time_passed = Time.now.to_f - @@last_query_time
25
+ sleep @@query_interval - time_passed if time_passed < @@query_interval
11
26
  response = nil
12
27
  5.times do
13
28
  begin
14
- response = open(url, "User-Agent" => "gem musicbrainz (https://github.com/magnolia-fan/musicbrainz) @ " + Socket.gethostname)
29
+ response = open(url, "User-Agent" => USER_AGENT)
15
30
  @@last_query_time = Time.now.to_f
16
31
  rescue => e
17
32
  return nil if e.io.status[0].to_i == 404
@@ -1,14 +1,12 @@
1
1
  module MusicBrainz
2
- class Artist
2
+ class Artist < MusicBrainz::Base
3
3
  attr_accessor :id, :type, :name, :country, :date_begin, :date_end, :urls
4
4
  @release_groups
5
5
 
6
6
  def release_groups
7
7
  if @release_groups.nil? and not self.id.nil?
8
8
  @release_groups = []
9
- Nokogiri::XML(MusicBrainz.load(
10
- 'http://musicbrainz.org/ws/2/release-group/?artist=' + self.id
11
- )).css('release-group').each do |rg|
9
+ Nokogiri::XML(MusicBrainz.load(:release_group, :artist => self.id)).css('release-group').each do |rg|
12
10
  @release_groups << MusicBrainz::ReleaseGroup.parse_xml(rg)
13
11
  end
14
12
  end
@@ -16,19 +14,19 @@ module MusicBrainz
16
14
  end
17
15
 
18
16
  def self.find mbid
19
- res = MusicBrainz.load('http://musicbrainz.org/ws/2/artist/' + mbid + '?inc=url-rels')
17
+ res = MusicBrainz.load :artist, :id => mbid, :inc => [:url_rels]
20
18
  return nil if res.nil?
21
19
  @artist = self.parse_xml(Nokogiri::XML(res))
22
20
  end
23
21
 
24
22
  def self.parse_xml xml
25
23
  @artist = MusicBrainz::Artist.new
26
- @artist.id = xml.css('artist').attr('id').value
27
- @artist.type = xml.css('artist').attr('type').value unless xml.css('artist').nil? or xml.css('artist').attr('type').nil?
28
- @artist.name = xml.css('artist > name').text
29
- @artist.country = xml.css('artist > country').text unless xml.css('artist > country').empty?
30
- @artist.date_begin = xml.css('artist > life-span > begin').text unless xml.css('artist > life-span > begin').empty?
31
- @artist.date_end = xml.css('artist > life-span > end').text unless xml.css('artist > life-span > end').empty?
24
+ @artist.id = self.safe_get_attr(xml, 'artist', 'id')
25
+ @artist.type = self.safe_get_attr(xml, 'artist', 'type')
26
+ @artist.name = self.safe_get_value(xml, 'artist > name')
27
+ @artist.country = self.safe_get_value(xml, 'artist > country')
28
+ @artist.date_begin = self.safe_get_value(xml, 'artist > life-span > begin')
29
+ @artist.date_end = self.safe_get_value(xml, 'artist > life-span > end')
32
30
  @artist.urls = {}
33
31
  xml.css('relation-list[target-type="url"] > relation').each do |rel|
34
32
  @artist.urls[rel.attr('type').downcase.split(' ').join('_').to_sym] = rel.css('target').text
@@ -49,16 +47,14 @@ module MusicBrainz
49
47
 
50
48
  def self.search name
51
49
  artists = []
52
- xml = Nokogiri::XML(MusicBrainz.load(
53
- 'http://musicbrainz.org/ws/2/artist/?query='+ CGI.escape(name).gsub(/\!/, '') +'~&limit=50'
54
- ))
50
+ xml = Nokogiri::XML(MusicBrainz.load(:artist, :query => CGI.escape(name).gsub(/\!/, '') + '~', :limit => 50))
55
51
  xml.css('artist-list > artist').each do |a|
56
52
  artist = {
57
53
  :name => a.first_element_child.text,
58
54
  :weight => 0,
59
- :desc => (a.css('disambiguation').text unless a.css('disambiguation').empty?),
60
- :type => a.attr('type'),
61
- :mbid => a.attr('id')
55
+ :desc => self.safe_get_value(a, 'disambiguation'),
56
+ :type => self.safe_get_attr(a, nil, 'type'),
57
+ :mbid => self.safe_get_attr(a, nil, 'id')
62
58
  }
63
59
  aliases = a.css('alias-list > alias').map{ |item| item.text }
64
60
  if aliases.include? name
@@ -0,0 +1,12 @@
1
+ module MusicBrainz
2
+ class Base
3
+ def self.safe_get_attr xml, path, name
4
+ node = path.nil? ? xml : (xml.css(path).first unless xml.css(path).empty?)
5
+ node.attr(name) unless node.nil? or node.attr(name).nil?
6
+ end
7
+
8
+ def self.safe_get_value xml, path
9
+ xml.css(path).first.text unless xml.css(path).empty?
10
+ end
11
+ end
12
+ end
@@ -1,12 +1,12 @@
1
1
  module MusicBrainz
2
- class Release
2
+ class Release < MusicBrainz::Base
3
3
  attr_accessor :id, :title, :status, :format, :date, :country
4
4
  @tracks
5
5
 
6
6
  def tracks
7
7
  if @tracks.nil? and not self.id.nil?
8
8
  @tracks = []
9
- Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/release/' + self.id + '?inc=recordings+media&limit=100')).css('medium-list > medium > track-list > track').each do |r|
9
+ Nokogiri::XML(MusicBrainz.load(:release, :id => self.id, :inc => [:recordings, :media], :limit => 100)).css('medium-list > medium > track-list > track').each do |r|
10
10
  @tracks << MusicBrainz::Track.parse_xml(r)
11
11
  end
12
12
  end
@@ -14,16 +14,16 @@ module MusicBrainz
14
14
  end
15
15
 
16
16
  def self.find mbid
17
- xml = Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/release/' + mbid + '?inc=media')).css('release').first
17
+ xml = Nokogiri::XML(MusicBrainz.load(:release, :id => mbid, :inc => [:media])).css('release').first
18
18
  self.parse_xml(xml) unless xml.nil?
19
19
  end
20
20
 
21
21
  def self.parse_xml xml
22
22
  @release = MusicBrainz::Release.new
23
- @release.id = xml.attr('id')
24
- @release.title = xml.css('title').text unless xml.css('title').empty?
25
- @release.status = xml.css('status').text unless xml.css('status').empty?
26
- @release.format = xml.css('medium-list > medium > format').first.text unless xml.css('medium-list > medium > format').empty?
23
+ @release.id = self.safe_get_attr(xml, nil, 'id')
24
+ @release.title = self.safe_get_value(xml, 'title')
25
+ @release.status = self.safe_get_value(xml, 'status')
26
+ @release.format = self.safe_get_value(xml, 'medium-list > medium > format')
27
27
  date = xml.css('date').empty? ? '2030-12-31' : xml.css('date').text
28
28
  if date.length == 0
29
29
  date = '2030-12-31'
@@ -34,7 +34,7 @@ module MusicBrainz
34
34
  end
35
35
  date = date.split('-')
36
36
  @release.date = Time.utc(date[0], date[1], date[2])
37
- @release.country = xml.css('country').text unless xml.css('country').empty?
37
+ @release.country = self.safe_get_value(xml, 'country')
38
38
  @release
39
39
  end
40
40
  end
@@ -1,12 +1,12 @@
1
1
  module MusicBrainz
2
- class ReleaseGroup
2
+ class ReleaseGroup < MusicBrainz::Base
3
3
  attr_accessor :id, :type, :title, :disambiguation, :first_release_date
4
4
  @releases
5
5
 
6
6
  def releases
7
7
  if @releases.nil? and not self.id.nil?
8
8
  @releases = []
9
- Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/release/?release-group=' + self.id + '&inc=media&limit=100')).css('release').each do |r|
9
+ Nokogiri::XML(MusicBrainz.load(:release, :release_group => self.id, :inc => [:media], :limit => 100)).css('release').each do |r|
10
10
  @releases << MusicBrainz::Release.parse_xml(r)
11
11
  end
12
12
  end
@@ -14,16 +14,16 @@ module MusicBrainz
14
14
  end
15
15
 
16
16
  def self.find mbid
17
- xml = Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/release-group/' + mbid)).css('release-group').first
17
+ xml = Nokogiri::XML(MusicBrainz.load(:release_group, :id => mbid)).css('release-group').first
18
18
  self.parse_xml(xml) unless xml.nil?
19
19
  end
20
20
 
21
21
  def self.parse_xml xml
22
22
  @release_group = MusicBrainz::ReleaseGroup.new
23
- @release_group.id = xml.attr('id')
24
- @release_group.type = xml.attr('type')
25
- @release_group.title = xml.css('title').text
26
- @release_group.disambiguation = xml.css('disambiguation').empty? ? '' : xml.css('disambiguation').text
23
+ @release_group.id = self.safe_get_attr(xml, nil, 'id')
24
+ @release_group.type = self.safe_get_attr(xml, nil, 'type')
25
+ @release_group.title = self.safe_get_value(xml, 'title')
26
+ @release_group.disambiguation = self.safe_get_value(xml, 'disambiguation')
27
27
  date = xml.css('first-release-date').empty? ? '2030-12-31' : xml.css('first-release-date').text
28
28
  if date.length == 0
29
29
  date = '2030-12-31'
@@ -1,19 +1,19 @@
1
1
  module MusicBrainz
2
- class Track
2
+ class Track < MusicBrainz::Base
3
3
  attr_accessor :position, :recording_id, :title, :length
4
4
 
5
5
  def self.find mbid
6
- xml = Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/recording/' + mbid + '?limit=100'))
6
+ xml = Nokogiri::XML(MusicBrainz.load(:recording, :id => mbid))
7
7
  self.parse_xml(xml) unless xml.nil?
8
8
  end
9
9
 
10
10
  def self.parse_xml xml
11
11
  @track = MusicBrainz::Track.new
12
- @track.position = xml.css('position').text.to_i unless xml.css('position').empty?
13
- @track.recording_id = xml.css('recording').attr('id').value unless xml.css('recording').empty?
14
- @track.title = xml.css('recording > title').text unless xml.css('recording > title').empty?
15
- @track.length = xml.css('length').first.text.to_i unless xml.css('length').empty?
16
- @track.length = xml.css('recording > length').first.text.to_i unless xml.css('recording > length').empty?
12
+ @track.position = self.safe_get_value(xml, 'position').to_i
13
+ @track.recording_id = self.safe_get_attr(xml, 'recording', 'id')
14
+ @track.title = self.safe_get_value(xml, 'recording > title')
15
+ @track.length = self.safe_get_value(xml, 'length').to_i
16
+ @track.length = self.safe_get_value(xml, 'recording > length').to_i
17
17
  @track
18
18
  end
19
19
  end
data/lib/musicbrainz.rb CHANGED
@@ -4,6 +4,7 @@ require "nokogiri"
4
4
  require "cgi"
5
5
 
6
6
  require "models/music_brainz"
7
+ require "models/music_brainz/base"
7
8
  require "models/music_brainz/artist"
8
9
  require "models/music_brainz/release_group"
9
10
  require "models/music_brainz/release"
data/musicbrainz.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{musicbrainz}
8
- s.version = "0.4.10"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Gregory Eremin"]
12
- s.date = %q{2011-09-20}
11
+ s.authors = [%q{Gregory Eremin}]
12
+ s.date = %q{2011-10-06}
13
13
  s.description = %q{MusicBrainz Web Service wrapper with ActiveRecord-style models}
14
14
  s.email = %q{magnolia_fan@me.com}
15
15
  s.extra_rdoc_files = [
@@ -27,18 +27,22 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "lib/models/music_brainz.rb",
29
29
  "lib/models/music_brainz/artist.rb",
30
+ "lib/models/music_brainz/base.rb",
30
31
  "lib/models/music_brainz/release.rb",
31
32
  "lib/models/music_brainz/release_group.rb",
32
33
  "lib/models/music_brainz/track.rb",
33
34
  "lib/musicbrainz.rb",
34
35
  "musicbrainz.gemspec",
35
36
  "test/helper.rb",
36
- "test/test_musicbrainz.rb"
37
+ "test/test_musicbrainz_artist.rb",
38
+ "test/test_musicbrainz_release.rb",
39
+ "test/test_musicbrainz_release_group.rb",
40
+ "test/test_musicbrainz_track.rb"
37
41
  ]
38
42
  s.homepage = %q{http://github.com/magnolia-fan/musicbrainz}
39
- s.licenses = ["MIT"]
40
- s.require_paths = ["lib"]
41
- s.rubygems_version = %q{1.6.2}
43
+ s.licenses = [%q{MIT}]
44
+ s.require_paths = [%q{lib}]
45
+ s.rubygems_version = %q{1.8.8}
42
46
  s.summary = %q{MusicBrainz Web Service wrapper}
43
47
 
44
48
  if s.respond_to? :specification_version then
@@ -0,0 +1,47 @@
1
+ require 'helper'
2
+
3
+ class TestMusicbrainzArtist < Test::Unit::TestCase
4
+ context "artist" do
5
+ should "load artist xml" do
6
+ assert_nothing_raised(Exception) do
7
+ MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033')
8
+ end
9
+ end
10
+
11
+ should "search by name" do
12
+ matches = MusicBrainz::Artist.search('Kasabian')
13
+ assert_operator(0, :<, matches.length)
14
+ assert_equal("Kasabian", matches.first[:name])
15
+ end
16
+
17
+ should "get correct result by name" do
18
+ @artist = MusicBrainz::Artist.find_by_name('Kasabian')
19
+ assert_equal("69b39eab-6577-46a4-a9f5-817839092033", @artist.id)
20
+ end
21
+
22
+ setup do
23
+ @artist = MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033')
24
+ end
25
+
26
+ should "return valid instance" do
27
+ assert_instance_of(MusicBrainz::Artist, @artist)
28
+ end
29
+
30
+ should "contain correct data" do
31
+ assert_equal("69b39eab-6577-46a4-a9f5-817839092033", @artist.id)
32
+ assert_equal("Group", @artist.type)
33
+ assert_equal("Kasabian", @artist.name)
34
+ assert_equal("GB", @artist.country)
35
+ assert_equal("1999", @artist.date_begin)
36
+ end
37
+
38
+ should "load release groups" do
39
+ release_groups = @artist.release_groups
40
+ assert_operator(16, :<=, release_groups.length)
41
+ assert_equal('533cbc5f-ec7e-32ab-95f3-8d1f804a5176', release_groups.first.id)
42
+ assert_equal('Single', release_groups.first.type)
43
+ assert_equal('Club Foot', release_groups.first.title)
44
+ assert_equal(Time.utc(2004, 5, 10), release_groups.first.first_release_date)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,36 @@
1
+ require 'helper'
2
+
3
+ class TestMusicbrainzRelease < Test::Unit::TestCase
4
+ context "release" do
5
+ should "load xml" do
6
+ assert_nothing_raised(Exception) do
7
+ MusicBrainz::Release.find('2225dd4c-ae9a-403b-8ea0-9e05014c778f')
8
+ end
9
+ end
10
+
11
+ setup do
12
+ @release = MusicBrainz::Release.find('2225dd4c-ae9a-403b-8ea0-9e05014c778f')
13
+ end
14
+
15
+ should "return valid instance" do
16
+ assert_instance_of(MusicBrainz::Release, @release)
17
+ end
18
+
19
+ should "contain correct data" do
20
+ assert_equal("2225dd4c-ae9a-403b-8ea0-9e05014c778f", @release.id)
21
+ assert_equal("Empire", @release.title)
22
+ assert_equal("Official", @release.status)
23
+ assert_equal(Time.utc(2006, 8, 28), @release.date)
24
+ assert_equal("GB", @release.country)
25
+ end
26
+
27
+ should "load tracks" do
28
+ tracks = @release.tracks
29
+ assert_equal(11, tracks.length)
30
+ assert_equal(1, tracks.first.position)
31
+ assert_equal('b3015bab-1540-4d4e-9f30-14872a1525f7', tracks.first.recording_id)
32
+ assert_equal('Empire', tracks.first.title)
33
+ assert_equal(233013, tracks.first.length)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ require 'helper'
2
+
3
+ class TestMusicbrainzReleaseGroup < Test::Unit::TestCase
4
+ context "release group" do
5
+ should "load xml" do
6
+ assert_nothing_raised(Exception) do
7
+ MusicBrainz::ReleaseGroup.find('6f33e0f0-cde2-38f9-9aee-2c60af8d1a61')
8
+ end
9
+ end
10
+
11
+ setup do
12
+ @release_group = MusicBrainz::ReleaseGroup.find('6f33e0f0-cde2-38f9-9aee-2c60af8d1a61')
13
+ end
14
+
15
+ should "return valid instance" do
16
+ assert_instance_of(MusicBrainz::ReleaseGroup, @release_group)
17
+ end
18
+
19
+ should "contain correct data" do
20
+ assert_equal("6f33e0f0-cde2-38f9-9aee-2c60af8d1a61", @release_group.id)
21
+ assert_equal("Album", @release_group.type)
22
+ assert_equal("Empire", @release_group.title)
23
+ assert_equal(Time.utc(2006, 8, 28), @release_group.first_release_date)
24
+ end
25
+
26
+ should "load releases" do
27
+ releases = @release_group.releases
28
+ assert_operator(5, :<=, releases.length)
29
+ assert_equal('2225dd4c-ae9a-403b-8ea0-9e05014c778f', releases.first.id)
30
+ assert_equal('Official', releases.first.status)
31
+ assert_equal('Empire', releases.first.title)
32
+ assert_equal(Time.utc(2006, 8, 28), releases.first.date)
33
+ assert_equal('GB', releases.first.country)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,25 @@
1
+ require 'helper'
2
+
3
+ class TestMusicbrainzTrack < Test::Unit::TestCase
4
+ context "track" do
5
+ should "load xml" do
6
+ assert_nothing_raised(Exception) do
7
+ MusicBrainz::Track.find('b3015bab-1540-4d4e-9f30-14872a1525f7')
8
+ end
9
+ end
10
+
11
+ setup do
12
+ @track = MusicBrainz::Track.find('b3015bab-1540-4d4e-9f30-14872a1525f7')
13
+ end
14
+
15
+ should "return valid instance" do
16
+ assert_instance_of(MusicBrainz::Track, @track)
17
+ end
18
+
19
+ should "contain correct data" do
20
+ assert_equal("b3015bab-1540-4d4e-9f30-14872a1525f7", @track.recording_id)
21
+ assert_equal("Empire", @track.title)
22
+ assert_equal(233013, @track.length)
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,94 +1,90 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: musicbrainz
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
4
5
  prerelease:
5
- version: 0.4.10
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Gregory Eremin
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-09-20 00:00:00 +04:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-10-06 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: nokogiri
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2156435880 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  type: :runtime
25
23
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2156435880
25
+ - !ruby/object:Gem::Dependency
28
26
  name: shoulda
29
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &2156435060 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
35
33
  type: :development
36
34
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *2156435060
36
+ - !ruby/object:Gem::Dependency
39
37
  name: bundler
40
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &2156434280 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
40
+ requirements:
43
41
  - - ~>
44
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
45
43
  version: 1.0.0
46
44
  type: :development
47
45
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *2156434280
47
+ - !ruby/object:Gem::Dependency
50
48
  name: jeweler
51
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &2156211980 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
51
+ requirements:
54
52
  - - ~>
55
- - !ruby/object:Gem::Version
53
+ - !ruby/object:Gem::Version
56
54
  version: 1.6.4
57
55
  type: :development
58
56
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *2156211980
58
+ - !ruby/object:Gem::Dependency
61
59
  name: rcov
62
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &2156211280 !ruby/object:Gem::Requirement
63
61
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
68
66
  type: :development
69
67
  prerelease: false
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *2156211280
69
+ - !ruby/object:Gem::Dependency
72
70
  name: rdoc
73
- requirement: &id006 !ruby/object:Gem::Requirement
71
+ requirement: &2156210560 !ruby/object:Gem::Requirement
74
72
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
79
77
  type: :development
80
78
  prerelease: false
81
- version_requirements: *id006
79
+ version_requirements: *2156210560
82
80
  description: MusicBrainz Web Service wrapper with ActiveRecord-style models
83
81
  email: magnolia_fan@me.com
84
82
  executables: []
85
-
86
83
  extensions: []
87
-
88
- extra_rdoc_files:
84
+ extra_rdoc_files:
89
85
  - LICENSE.txt
90
86
  - README.rdoc
91
- files:
87
+ files:
92
88
  - .document
93
89
  - .travis.yml
94
90
  - Gemfile
@@ -99,43 +95,43 @@ files:
99
95
  - VERSION
100
96
  - lib/models/music_brainz.rb
101
97
  - lib/models/music_brainz/artist.rb
98
+ - lib/models/music_brainz/base.rb
102
99
  - lib/models/music_brainz/release.rb
103
100
  - lib/models/music_brainz/release_group.rb
104
101
  - lib/models/music_brainz/track.rb
105
102
  - lib/musicbrainz.rb
106
103
  - musicbrainz.gemspec
107
104
  - test/helper.rb
108
- - test/test_musicbrainz.rb
109
- has_rdoc: true
105
+ - test/test_musicbrainz_artist.rb
106
+ - test/test_musicbrainz_release.rb
107
+ - test/test_musicbrainz_release_group.rb
108
+ - test/test_musicbrainz_track.rb
110
109
  homepage: http://github.com/magnolia-fan/musicbrainz
111
- licenses:
110
+ licenses:
112
111
  - MIT
113
112
  post_install_message:
114
113
  rdoc_options: []
115
-
116
- require_paths:
114
+ require_paths:
117
115
  - lib
118
- required_ruby_version: !ruby/object:Gem::Requirement
116
+ required_ruby_version: !ruby/object:Gem::Requirement
119
117
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: -804216001345752924
124
- segments:
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ segments:
125
123
  - 0
126
- version: "0"
127
- required_rubygems_version: !ruby/object:Gem::Requirement
124
+ hash: 1738320966711740487
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
126
  none: false
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: "0"
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
133
131
  requirements: []
134
-
135
132
  rubyforge_project:
136
- rubygems_version: 1.6.2
133
+ rubygems_version: 1.8.8
137
134
  signing_key:
138
135
  specification_version: 3
139
136
  summary: MusicBrainz Web Service wrapper
140
137
  test_files: []
141
-
@@ -1,135 +0,0 @@
1
- require 'helper'
2
-
3
- class TestMusicbrainz < Test::Unit::TestCase
4
- context "artist" do
5
- should "load artist xml" do
6
- assert_nothing_raised(Exception) do
7
- MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033')
8
- end
9
- end
10
-
11
- should "search for artists by name" do
12
- matches = MusicBrainz::Artist.search('Kasabian')
13
- assert_operator(0, :<, matches.length)
14
- assert_equal("Kasabian", matches.first[:name])
15
- end
16
-
17
- should "get correct artist by name" do
18
- @artist = MusicBrainz::Artist.find_by_name('Kasabian')
19
- assert_equal("69b39eab-6577-46a4-a9f5-817839092033", @artist.id)
20
- end
21
-
22
- setup do
23
- @artist = MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033')
24
- end
25
-
26
- should "return valid instance" do
27
- assert_instance_of(MusicBrainz::Artist, @artist)
28
- end
29
-
30
- should "contain correct data" do
31
- assert_equal("69b39eab-6577-46a4-a9f5-817839092033", @artist.id)
32
- assert_equal("Group", @artist.type)
33
- assert_equal("Kasabian", @artist.name)
34
- assert_equal("GB", @artist.country)
35
- assert_equal("1999", @artist.date_begin)
36
- end
37
-
38
- should "load release groups" do
39
- release_groups = @artist.release_groups
40
- assert_operator(16, :<=, release_groups.length)
41
- assert_equal('533cbc5f-ec7e-32ab-95f3-8d1f804a5176', release_groups.first.id)
42
- assert_equal('Single', release_groups.first.type)
43
- assert_equal('Club Foot', release_groups.first.title)
44
- assert_equal(Time.utc(2004, 5, 10), release_groups.first.first_release_date)
45
- end
46
- end
47
-
48
- context "release group" do
49
- should "load release group xml" do
50
- assert_nothing_raised(Exception) do
51
- MusicBrainz::ReleaseGroup.find('6f33e0f0-cde2-38f9-9aee-2c60af8d1a61')
52
- end
53
- end
54
-
55
- setup do
56
- @release_group = MusicBrainz::ReleaseGroup.find('6f33e0f0-cde2-38f9-9aee-2c60af8d1a61')
57
- end
58
-
59
- should "return valid instance" do
60
- assert_instance_of(MusicBrainz::ReleaseGroup, @release_group)
61
- end
62
-
63
- should "contain correct data" do
64
- assert_equal("6f33e0f0-cde2-38f9-9aee-2c60af8d1a61", @release_group.id)
65
- assert_equal("Album", @release_group.type)
66
- assert_equal("Empire", @release_group.title)
67
- assert_equal(Time.utc(2006, 8, 28), @release_group.first_release_date)
68
- end
69
-
70
- should "load releases" do
71
- releases = @release_group.releases
72
- assert_operator(5, :<=, releases.length)
73
- assert_equal('2225dd4c-ae9a-403b-8ea0-9e05014c778f', releases.first.id)
74
- assert_equal('Official', releases.first.status)
75
- assert_equal('Empire', releases.first.title)
76
- assert_equal(Time.utc(2006, 8, 28), releases.first.date)
77
- assert_equal('GB', releases.first.country)
78
- end
79
- end
80
-
81
- context "release" do
82
- should "load release xml" do
83
- assert_nothing_raised(Exception) do
84
- MusicBrainz::Release.find('2225dd4c-ae9a-403b-8ea0-9e05014c778f')
85
- end
86
- end
87
-
88
- setup do
89
- @release = MusicBrainz::Release.find('2225dd4c-ae9a-403b-8ea0-9e05014c778f')
90
- end
91
-
92
- should "return valid instance" do
93
- assert_instance_of(MusicBrainz::Release, @release)
94
- end
95
-
96
- should "contain correct data" do
97
- assert_equal("2225dd4c-ae9a-403b-8ea0-9e05014c778f", @release.id)
98
- assert_equal("Empire", @release.title)
99
- assert_equal("Official", @release.status)
100
- assert_equal(Time.utc(2006, 8, 28), @release.date)
101
- assert_equal("GB", @release.country)
102
- end
103
-
104
- should "load tracks" do
105
- tracks = @release.tracks
106
- assert_equal(11, tracks.length)
107
- assert_equal(1, tracks.first.position)
108
- assert_equal('b3015bab-1540-4d4e-9f30-14872a1525f7', tracks.first.recording_id)
109
- assert_equal('Empire', tracks.first.title)
110
- assert_equal(233013, tracks.first.length)
111
- end
112
- end
113
-
114
- context "track" do
115
- should "load track xml" do
116
- assert_nothing_raised(Exception) do
117
- MusicBrainz::Track.find('b3015bab-1540-4d4e-9f30-14872a1525f7')
118
- end
119
- end
120
-
121
- setup do
122
- @track = MusicBrainz::Track.find('b3015bab-1540-4d4e-9f30-14872a1525f7')
123
- end
124
-
125
- should "return valid instance" do
126
- assert_instance_of(MusicBrainz::Track, @track)
127
- end
128
-
129
- should "contain correct data" do
130
- assert_equal("b3015bab-1540-4d4e-9f30-14872a1525f7", @track.recording_id)
131
- assert_equal("Empire", @track.title)
132
- assert_equal(233013, @track.length)
133
- end
134
- end
135
- end