musicbrainz 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/CHANGELOG.md +10 -0
- data/Contributors +1 -0
- data/Gemfile +1 -1
- data/README.md +5 -3
- data/Rakefile +8 -0
- data/lib/musicbrainz.rb +2 -0
- data/lib/musicbrainz/bindings/release_group.rb +4 -1
- data/lib/musicbrainz/bindings/track_search.rb +21 -0
- data/lib/musicbrainz/models/artist.rb +2 -6
- data/lib/musicbrainz/models/base_model.rb +32 -0
- data/lib/musicbrainz/models/release_group.rb +10 -13
- data/lib/musicbrainz/models/track.rb +4 -0
- data/lib/musicbrainz/version.rb +1 -1
- data/spec/bindings/release_group_search_spec.rb +3 -3
- data/spec/bindings/track_search_spec.rb +17 -0
- data/spec/client_modules/cache_spec.rb +1 -1
- data/spec/fixtures/release_group/entity.xml +22 -0
- data/spec/fixtures/release_group/search.xml +79 -0
- data/spec/models/artist_spec.rb +1 -0
- data/spec/models/release_group_spec.rb +16 -3
- metadata +40 -25
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/Contributors
CHANGED
data/Gemfile
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
source
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
gemspec
|
data/README.md
CHANGED
|
@@ -80,9 +80,9 @@ MusicBrainz::ReleaseGroup
|
|
|
80
80
|
```ruby
|
|
81
81
|
# Class Methods
|
|
82
82
|
MusicBrainz::ReleaseGroup.find(id)
|
|
83
|
-
MusicBrainz::ReleaseGroup.find_by_artist_and_title(artist_name, title,
|
|
83
|
+
MusicBrainz::ReleaseGroup.find_by_artist_and_title(artist_name, title, 'Album') # 3rd arg optional
|
|
84
84
|
MusicBrainz::ReleaseGroup.search(artist_name, title)
|
|
85
|
-
MusicBrainz::ReleaseGroup.search(artist_name, title,
|
|
85
|
+
MusicBrainz::ReleaseGroup.search(artist_name, title, 'Album') # 3rd arg optional
|
|
86
86
|
|
|
87
87
|
# Instance Methods
|
|
88
88
|
@release_group.releases
|
|
@@ -93,7 +93,8 @@ MusicBrainz::ReleaseGroup.search(artist_name, title, type: 'Album')
|
|
|
93
93
|
:type => String,
|
|
94
94
|
:title => String,
|
|
95
95
|
:desc => String,
|
|
96
|
-
:first_release_date => Date
|
|
96
|
+
:first_release_date => Date,
|
|
97
|
+
:urls => Hash
|
|
97
98
|
}
|
|
98
99
|
```
|
|
99
100
|
|
|
@@ -124,6 +125,7 @@ MusicBrainz::Track
|
|
|
124
125
|
```ruby
|
|
125
126
|
# Class Methods
|
|
126
127
|
MusicBrainz::Track.find(id)
|
|
128
|
+
MusicBrainz::ReleaseGroup.search(artist_name, track_name)
|
|
127
129
|
|
|
128
130
|
# Fields
|
|
129
131
|
{
|
data/Rakefile
ADDED
data/lib/musicbrainz.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require "digest/sha1"
|
|
2
2
|
require "fileutils"
|
|
3
|
+
require "date"
|
|
3
4
|
|
|
4
5
|
require "faraday"
|
|
5
6
|
require "nokogiri"
|
|
@@ -29,6 +30,7 @@ require "musicbrainz/bindings/release_group_releases"
|
|
|
29
30
|
require "musicbrainz/bindings/release"
|
|
30
31
|
require "musicbrainz/bindings/release_tracks"
|
|
31
32
|
require "musicbrainz/bindings/track"
|
|
33
|
+
require "musicbrainz/bindings/track_search"
|
|
32
34
|
|
|
33
35
|
module MusicBrainz
|
|
34
36
|
GH_PAGE_URL = "http://git.io/brainz"
|
|
@@ -8,7 +8,10 @@ module MusicBrainz
|
|
|
8
8
|
type: (xml.attribute('type').value rescue nil),
|
|
9
9
|
title: (xml.xpath('./title').text rescue nil),
|
|
10
10
|
desc: (xml.xpath('./disambiguation').text rescue nil),
|
|
11
|
-
first_release_date: (xml.xpath('./first-release-date').text rescue nil)
|
|
11
|
+
first_release_date: (xml.xpath('./first-release-date').text rescue nil),
|
|
12
|
+
urls: (Hash[xml.xpath('./relation-list[@target-type="url"]/relation').map{ |xml|
|
|
13
|
+
[xml.attribute('type').value.downcase.split(" ").join("_").to_sym, xml.xpath('./target').text]
|
|
14
|
+
}] rescue {})
|
|
12
15
|
}
|
|
13
16
|
end
|
|
14
17
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module MusicBrainz
|
|
3
|
+
module Bindings
|
|
4
|
+
module TrackSearch
|
|
5
|
+
def parse(xml)
|
|
6
|
+
xml.xpath('./recording-list/recording').map do |xml|
|
|
7
|
+
{
|
|
8
|
+
id: (xml.attribute('id').value rescue nil),
|
|
9
|
+
mbid: (xml.attribute('id').value rescue nil), # Old shit
|
|
10
|
+
title: (xml.xpath('./title').text.gsub(/[`’]/, "'") rescue nil),
|
|
11
|
+
artist: (xml.xpath('./artist-credit/name-credit/artist/name').text rescue nil),
|
|
12
|
+
releases: (xml.xpath('./release-list/release/title').map{ |xml| xml.text } rescue []),
|
|
13
|
+
score: (xml.attribute('score').value.to_i rescue nil)
|
|
14
|
+
} rescue nil
|
|
15
|
+
end.delete_if{ |item| item.nil? }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
extend self
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -9,7 +9,7 @@ module MusicBrainz
|
|
|
9
9
|
field :urls, Hash
|
|
10
10
|
|
|
11
11
|
def release_groups
|
|
12
|
-
@release_groups ||= client.load(:release_group, { artist: id }, {
|
|
12
|
+
@release_groups ||= client.load(:release_group, { artist: id, inc: [:url_rels] }, {
|
|
13
13
|
binding: :artist_release_groups,
|
|
14
14
|
create_models: :release_group,
|
|
15
15
|
sort: :first_release_date
|
|
@@ -25,11 +25,7 @@ module MusicBrainz
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def search(name)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
client.load(:artist, { query: "artist:#{name}", limit: 10 }, {
|
|
31
|
-
binding: :artist_search
|
|
32
|
-
})
|
|
28
|
+
super({artist: name})
|
|
33
29
|
end
|
|
34
30
|
|
|
35
31
|
def discography(mbid)
|
|
@@ -23,6 +23,38 @@ module MusicBrainz
|
|
|
23
23
|
def client
|
|
24
24
|
MusicBrainz.client
|
|
25
25
|
end
|
|
26
|
+
|
|
27
|
+
def search(hash)
|
|
28
|
+
hash = escape_strings(hash)
|
|
29
|
+
query_val = build_query(hash)
|
|
30
|
+
underscore_name = self.name[13..-1].underscore
|
|
31
|
+
client.load(underscore_name.to_sym, { query: query_val, limit: 10 }, { binding: underscore_name.insert(-1,"_search").to_sym })
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class ::String
|
|
35
|
+
def underscore
|
|
36
|
+
self.gsub(/::/, '/').
|
|
37
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
|
38
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
|
39
|
+
tr("-", "_").
|
|
40
|
+
downcase
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def build_query(hash)
|
|
45
|
+
return ["#{hash.first[0].to_s}:\"#{hash.first[1]}\""] if hash.size ==1
|
|
46
|
+
arr ||= []
|
|
47
|
+
hash.each { |k, v| arr << "#{k.to_s}:\"#{hash[k]}\"" }
|
|
48
|
+
arr.join(' AND ')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def escape_strings(hash)
|
|
52
|
+
hash.each { |k, v| hash[k] = CGI.escape(v).gsub(/\!/, '\!') }
|
|
53
|
+
hash
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# these probably should be private... but I'm not sure how to get it to work in a module...
|
|
57
|
+
# private_class_method :build_query, :escape_strings
|
|
26
58
|
end
|
|
27
59
|
|
|
28
60
|
module InstanceMethods
|
|
@@ -5,6 +5,7 @@ module MusicBrainz
|
|
|
5
5
|
field :title, String
|
|
6
6
|
field :desc, String
|
|
7
7
|
field :first_release_date, Date
|
|
8
|
+
field :urls, Hash
|
|
8
9
|
|
|
9
10
|
alias_method :disambiguation, :desc
|
|
10
11
|
|
|
@@ -18,26 +19,22 @@ module MusicBrainz
|
|
|
18
19
|
|
|
19
20
|
class << self
|
|
20
21
|
def find(id)
|
|
21
|
-
client.load(:release_group, { id: id }, {
|
|
22
|
+
client.load(:release_group, { id: id, inc: [:url_rels] }, {
|
|
22
23
|
binding: :release_group,
|
|
23
24
|
create_model: :release_group
|
|
24
25
|
})
|
|
25
26
|
end
|
|
26
27
|
|
|
27
|
-
def search(artist_name, title,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
client.load(
|
|
34
|
-
:release_group, { query: query.join(' AND '), limit: 10 },
|
|
35
|
-
{ binding: :release_group_search }
|
|
36
|
-
)
|
|
28
|
+
def search(artist_name, title, type = nil)
|
|
29
|
+
if type
|
|
30
|
+
super({artist: artist_name, releasegroup: title, type: type})
|
|
31
|
+
else
|
|
32
|
+
super({artist: artist_name, releasegroup: title})
|
|
33
|
+
end
|
|
37
34
|
end
|
|
38
35
|
|
|
39
|
-
def find_by_artist_and_title(artist_name, title,
|
|
40
|
-
matches = search(artist_name, title,
|
|
36
|
+
def find_by_artist_and_title(artist_name, title, type = nil )
|
|
37
|
+
matches = search(artist_name, title, type)
|
|
41
38
|
matches.empty? ? nil : find(matches.first[:id])
|
|
42
39
|
end
|
|
43
40
|
end
|
data/lib/musicbrainz/version.rb
CHANGED
|
@@ -5,8 +5,8 @@ require "spec_helper"
|
|
|
5
5
|
describe MusicBrainz::Bindings::ReleaseGroupSearch do
|
|
6
6
|
describe '.parse' do
|
|
7
7
|
it "gets correct release group data" do
|
|
8
|
-
response = '<release-group-list><release-group id="246bc928-2dc8-35ba-80ee-7a0079de1632" type="Single" ext:score="100"><title>Empire</title></release-group>'
|
|
9
|
-
described_class.parse(Nokogiri::XML.parse(response)).should == [
|
|
8
|
+
response = '<metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ext="http://musicbrainz.org/ns/ext#-2.0"><release-group-list><release-group id="246bc928-2dc8-35ba-80ee-7a0079de1632" type="Single" ext:score="100"><title>Empire</title></release-group></release-group-list></metadata>'
|
|
9
|
+
described_class.parse(Nokogiri::XML.parse(response).remove_namespaces!.xpath('/metadata')).should == [
|
|
10
10
|
{
|
|
11
11
|
id: '246bc928-2dc8-35ba-80ee-7a0079de1632', mbid: '246bc928-2dc8-35ba-80ee-7a0079de1632',
|
|
12
12
|
title: 'Empire', type: 'Single', score: 100
|
|
@@ -14,4 +14,4 @@ describe MusicBrainz::Bindings::ReleaseGroupSearch do
|
|
|
14
14
|
]
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
|
-
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe MusicBrainz::Bindings::TrackSearch do
|
|
6
|
+
describe '.parse' do
|
|
7
|
+
it "gets correct Track (really recording) data" do
|
|
8
|
+
response = '<metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ext="http://musicbrainz.org/ns/ext#-2.0"><recording-list offset="0" count="1"><recording id="0b382a13-32f0-4743-9248-ba5536a6115e" ext:score="100"><title>King Fred</title><artist-credit><name-credit><artist id="f52f7a92-d495-4d32-89e7-8b1e5b8541c8"><name>Too Much Joy</name></artist></name-credit></artist-credit><release-list><release id="8442e42b-c40a-4817-89a0-dbe663c94d2d"><title>Green Eggs and Crack</title></release></release-list></recording></recording-list></metadata>'
|
|
9
|
+
described_class.parse(Nokogiri::XML.parse(response).remove_namespaces!.xpath('/metadata')).should == [
|
|
10
|
+
{
|
|
11
|
+
id: '0b382a13-32f0-4743-9248-ba5536a6115e', mbid: '0b382a13-32f0-4743-9248-ba5536a6115e',
|
|
12
|
+
title: 'King Fred', artist: 'Too Much Joy', releases: ['Green Eggs and Crack'], score: 100
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -12,7 +12,7 @@ describe MusicBrainz::ClientModules::CachingProxy do
|
|
|
12
12
|
let(:test_response){ File.open(test_response_file).read }
|
|
13
13
|
|
|
14
14
|
before(:all) do
|
|
15
|
-
MusicBrainz.config.cache_path =
|
|
15
|
+
MusicBrainz.config.cache_path = File.join(File.dirname(__FILE__), '..', '..', 'tmp', 'cache_module_spec_cache')
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
after(:all) do
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#">
|
|
3
|
+
<release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
|
|
4
|
+
<title>Empire</title>
|
|
5
|
+
<first-release-date>2006-08-28</first-release-date>
|
|
6
|
+
<primary-type>Album</primary-type>
|
|
7
|
+
<relation-list target-type="url">
|
|
8
|
+
<relation type-id="6578f0e9-1ace-4095-9de8-6e517ddb1ceb" type="wikipedia">
|
|
9
|
+
<target id="e831302f-4fa8-4630-afa5-4e32a795322a">http://en.wikipedia.org/wiki/Empire_(Kasabian_album)</target>
|
|
10
|
+
</relation>
|
|
11
|
+
<relation type-id="156344d3-da8b-40c6-8b10-7b1c22727124" type="lyrics">
|
|
12
|
+
<target id="87d521d9-c78e-42fd-ac5e-98c82e6394a0">http://lyrics.wikia.com/Kasabian:Empire_(2006)</target>
|
|
13
|
+
</relation>
|
|
14
|
+
<relation type-id="c3ac9c3b-f546-4d15-873f-b294d2c1b708" type="review">
|
|
15
|
+
<target id="732310f9-ac35-468f-b293-891c6f7d0812">http://www.bbc.co.uk/music/reviews/389x</target>
|
|
16
|
+
</relation>
|
|
17
|
+
<relation type-id="99e550f3-5ab4-3110-b5b9-fe01d970b126" type="discogs">
|
|
18
|
+
<target id="1afddd13-53dd-4d0c-87e2-faf016725e95">http://www.discogs.com/master/89980</target>
|
|
19
|
+
</relation>
|
|
20
|
+
</relation-list>
|
|
21
|
+
</release-group>
|
|
22
|
+
</metadata>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<?xml version="1.0" standalone="yes"?>
|
|
2
|
+
<metadata created="2013-05-06T14:05:42.527Z" xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ext="http://musicbrainz.org/ns/ext#-2.0">
|
|
3
|
+
<release-group-list count="2" offset="0">
|
|
4
|
+
<release-group id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61" type="Album" ext:score="100">
|
|
5
|
+
<title>Empire</title>
|
|
6
|
+
<primary-type>Album</primary-type>
|
|
7
|
+
<artist-credit>
|
|
8
|
+
<name-credit>
|
|
9
|
+
<artist id="69b39eab-6577-46a4-a9f5-817839092033">
|
|
10
|
+
<name>Kasabian</name>
|
|
11
|
+
<sort-name>Kasabian</sort-name>
|
|
12
|
+
</artist>
|
|
13
|
+
</name-credit>
|
|
14
|
+
</artist-credit>
|
|
15
|
+
<release-list count="7">
|
|
16
|
+
<release id="9f068ed6-9f69-4a60-bf5a-0931176a9aba">
|
|
17
|
+
<title>Empire</title>
|
|
18
|
+
<status>Official</status>
|
|
19
|
+
</release>
|
|
20
|
+
<release id="30d5e730-ce0a-464d-93e1-7d76e4bb3e31">
|
|
21
|
+
<title>Empire</title>
|
|
22
|
+
<status>Official</status>
|
|
23
|
+
</release>
|
|
24
|
+
<release id="36ee86ab-0450-4d8f-a970-183c11f210c1">
|
|
25
|
+
<title>Empire</title>
|
|
26
|
+
<status>Official</status>
|
|
27
|
+
</release>
|
|
28
|
+
<release id="2225dd4c-ae9a-403b-8ea0-9e05014c778f">
|
|
29
|
+
<title>Empire</title>
|
|
30
|
+
<status>Official</status>
|
|
31
|
+
</release>
|
|
32
|
+
<release id="2c8dcfc6-4afe-4b33-abc7-dff1bb4c5386">
|
|
33
|
+
<title>Empire</title>
|
|
34
|
+
<status>Official</status>
|
|
35
|
+
</release>
|
|
36
|
+
<release id="2bc94ddc-b872-3b7f-b0a7-98a4fffbe5ba">
|
|
37
|
+
<title>Empire</title>
|
|
38
|
+
<status>Official</status>
|
|
39
|
+
</release>
|
|
40
|
+
<release id="dd34af03-37ab-460a-b20a-54629336d81a">
|
|
41
|
+
<title>Empire</title>
|
|
42
|
+
<status>Official</status>
|
|
43
|
+
</release>
|
|
44
|
+
</release-list>
|
|
45
|
+
<tag-list>
|
|
46
|
+
<tag count="3">
|
|
47
|
+
<name>rock</name>
|
|
48
|
+
</tag>
|
|
49
|
+
<tag count="4">
|
|
50
|
+
<name>alternative rock</name>
|
|
51
|
+
</tag>
|
|
52
|
+
<tag count="1">
|
|
53
|
+
<name>indie</name>
|
|
54
|
+
</tag>
|
|
55
|
+
<tag count="1">
|
|
56
|
+
<name>rock and indie</name>
|
|
57
|
+
</tag>
|
|
58
|
+
</tag-list>
|
|
59
|
+
</release-group>
|
|
60
|
+
<release-group id="246bc928-2dc8-35ba-80ee-7a0079de1632" type="Single" ext:score="100">
|
|
61
|
+
<title>Empire</title>
|
|
62
|
+
<primary-type>Single</primary-type>
|
|
63
|
+
<artist-credit>
|
|
64
|
+
<name-credit>
|
|
65
|
+
<artist id="69b39eab-6577-46a4-a9f5-817839092033">
|
|
66
|
+
<name>Kasabian</name>
|
|
67
|
+
<sort-name>Kasabian</sort-name>
|
|
68
|
+
</artist>
|
|
69
|
+
</name-credit>
|
|
70
|
+
</artist-credit>
|
|
71
|
+
<release-list count="1">
|
|
72
|
+
<release id="1da0d848-b937-4beb-8024-f4fdf6193708">
|
|
73
|
+
<title>Empire</title>
|
|
74
|
+
<status>Official</status>
|
|
75
|
+
</release>
|
|
76
|
+
</release-list>
|
|
77
|
+
</release-group>
|
|
78
|
+
</release-group-list>
|
|
79
|
+
</metadata>
|
data/spec/models/artist_spec.rb
CHANGED
|
@@ -56,5 +56,6 @@ describe MusicBrainz::Artist do
|
|
|
56
56
|
release_groups.first.type.should == "Single"
|
|
57
57
|
release_groups.first.title.should == "Club Foot"
|
|
58
58
|
release_groups.first.first_release_date.should == Date.new(2004, 5, 10)
|
|
59
|
+
release_groups.first.urls[:discogs].should == 'http://www.discogs.com/master/125150'
|
|
59
60
|
end
|
|
60
61
|
end
|
|
@@ -21,22 +21,27 @@ describe MusicBrainz::ReleaseGroup do
|
|
|
21
21
|
release_group.type.should == "Album"
|
|
22
22
|
release_group.title.should == "Empire"
|
|
23
23
|
release_group.first_release_date.should == Date.new(2006, 8, 28)
|
|
24
|
+
release_group.urls[:wikipedia].should == 'http://en.wikipedia.org/wiki/Empire_(Kasabian_album)'
|
|
24
25
|
end
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
describe '.search' do
|
|
28
29
|
context 'without type filter' do
|
|
29
30
|
it "searches release group by artist name and title" do
|
|
31
|
+
response = File.open(File.join(File.dirname(__FILE__), "../fixtures/release_group/search.xml")).read
|
|
32
|
+
MusicBrainz::Client.any_instance.stub(:get_contents).with('http://musicbrainz.org/ws/2/release-group?query=artist:"Kasabian" AND releasegroup:"Empire"&limit=10').
|
|
33
|
+
and_return({ status: 200, body: response})
|
|
34
|
+
|
|
30
35
|
matches = MusicBrainz::ReleaseGroup.search('Kasabian', 'Empire')
|
|
31
36
|
matches.length.should be > 0
|
|
32
37
|
matches.first[:title].should == 'Empire'
|
|
33
|
-
matches.first[:type].should == '
|
|
38
|
+
matches.first[:type].should == 'Album'
|
|
34
39
|
end
|
|
35
40
|
end
|
|
36
41
|
|
|
37
42
|
context 'with type filter' do
|
|
38
43
|
it "searches release group by artist name and title" do
|
|
39
|
-
matches = MusicBrainz::ReleaseGroup.search('Kasabian', 'Empire',
|
|
44
|
+
matches = MusicBrainz::ReleaseGroup.search('Kasabian', 'Empire', 'Album')
|
|
40
45
|
matches.length.should be > 0
|
|
41
46
|
matches.first[:title].should == 'Empire'
|
|
42
47
|
matches.first[:type].should == 'Album'
|
|
@@ -46,8 +51,16 @@ describe MusicBrainz::ReleaseGroup do
|
|
|
46
51
|
|
|
47
52
|
describe '.find_by_artist_and_title' do
|
|
48
53
|
it "gets first release group by artist name and title" do
|
|
54
|
+
response = File.open(File.join(File.dirname(__FILE__), "../fixtures/release_group/search.xml")).read
|
|
55
|
+
MusicBrainz::Client.any_instance.stub(:get_contents).with('http://musicbrainz.org/ws/2/release-group?query=artist:"Kasabian" AND releasegroup:"Empire"&limit=10').
|
|
56
|
+
and_return({ status: 200, body: response})
|
|
57
|
+
|
|
58
|
+
response = File.open(File.join(File.dirname(__FILE__), "../fixtures/release_group/entity.xml")).read
|
|
59
|
+
MusicBrainz::Client.any_instance.stub(:get_contents).with('http://musicbrainz.org/ws/2/release-group/6f33e0f0-cde2-38f9-9aee-2c60af8d1a61?inc=url-rels').
|
|
60
|
+
and_return({ status: 200, body: response})
|
|
61
|
+
|
|
49
62
|
release_group = MusicBrainz::ReleaseGroup.find_by_artist_and_title('Kasabian', 'Empire')
|
|
50
|
-
release_group.id.should == '
|
|
63
|
+
release_group.id.should == '6f33e0f0-cde2-38f9-9aee-2c60af8d1a61'
|
|
51
64
|
end
|
|
52
65
|
end
|
|
53
66
|
|
metadata
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: musicbrainz
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.7.5
|
|
4
5
|
prerelease:
|
|
5
|
-
version: 0.7.4
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Gregory Eremin
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-
|
|
12
|
+
date: 2013-05-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
|
|
15
|
+
name: faraday
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
16
18
|
requirements:
|
|
17
19
|
- - ! '>='
|
|
18
20
|
- !ruby/object:Gem::Version
|
|
19
21
|
version: '0'
|
|
20
|
-
none: false
|
|
21
|
-
name: faraday
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
25
26
|
requirements:
|
|
26
27
|
- - ! '>='
|
|
27
28
|
- !ruby/object:Gem::Version
|
|
28
29
|
version: '0'
|
|
29
|
-
none: false
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
|
-
|
|
31
|
+
name: nokogiri
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
32
34
|
requirements:
|
|
33
35
|
- - ! '>='
|
|
34
36
|
- !ruby/object:Gem::Version
|
|
35
37
|
version: '0'
|
|
36
|
-
none: false
|
|
37
|
-
name: nokogiri
|
|
38
38
|
type: :runtime
|
|
39
39
|
prerelease: false
|
|
40
|
-
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
41
42
|
requirements:
|
|
42
43
|
- - ! '>='
|
|
43
44
|
- !ruby/object:Gem::Version
|
|
44
45
|
version: '0'
|
|
45
|
-
none: false
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
|
-
|
|
47
|
+
name: rspec
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
48
50
|
requirements:
|
|
49
51
|
- - ! '>='
|
|
50
52
|
- !ruby/object:Gem::Version
|
|
51
53
|
version: '0'
|
|
52
|
-
none: false
|
|
53
|
-
name: rspec
|
|
54
54
|
type: :development
|
|
55
55
|
prerelease: false
|
|
56
|
-
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
57
58
|
requirements:
|
|
58
59
|
- - ! '>='
|
|
59
60
|
- !ruby/object:Gem::Version
|
|
60
61
|
version: '0'
|
|
61
|
-
none: false
|
|
62
62
|
- !ruby/object:Gem::Dependency
|
|
63
|
-
|
|
63
|
+
name: awesome_print
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
64
66
|
requirements:
|
|
65
67
|
- - ! '>='
|
|
66
68
|
- !ruby/object:Gem::Version
|
|
67
69
|
version: '0'
|
|
68
|
-
none: false
|
|
69
|
-
name: awesome_print
|
|
70
70
|
type: :development
|
|
71
71
|
prerelease: false
|
|
72
|
-
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
73
74
|
requirements:
|
|
74
75
|
- - ! '>='
|
|
75
76
|
- !ruby/object:Gem::Version
|
|
76
77
|
version: '0'
|
|
77
|
-
none: false
|
|
78
78
|
description:
|
|
79
79
|
email:
|
|
80
80
|
- magnolia_fan@me.com
|
|
@@ -85,10 +85,12 @@ files:
|
|
|
85
85
|
- .gitignore
|
|
86
86
|
- .rspec
|
|
87
87
|
- .travis.yml
|
|
88
|
+
- CHANGELOG.md
|
|
88
89
|
- Contributors
|
|
89
90
|
- Gemfile
|
|
90
91
|
- LICENSE
|
|
91
92
|
- README.md
|
|
93
|
+
- Rakefile
|
|
92
94
|
- lib/mb.rb
|
|
93
95
|
- lib/musicbrainz.rb
|
|
94
96
|
- lib/musicbrainz/bindings/artist.rb
|
|
@@ -100,6 +102,7 @@ files:
|
|
|
100
102
|
- lib/musicbrainz/bindings/release_group_search.rb
|
|
101
103
|
- lib/musicbrainz/bindings/release_tracks.rb
|
|
102
104
|
- lib/musicbrainz/bindings/track.rb
|
|
105
|
+
- lib/musicbrainz/bindings/track_search.rb
|
|
103
106
|
- lib/musicbrainz/client.rb
|
|
104
107
|
- lib/musicbrainz/client_modules/caching_proxy.rb
|
|
105
108
|
- lib/musicbrainz/client_modules/failsafe_proxy.rb
|
|
@@ -116,10 +119,13 @@ files:
|
|
|
116
119
|
- musicbrainz.gemspec
|
|
117
120
|
- spec/bindings/release_group_search_spec.rb
|
|
118
121
|
- spec/bindings/release_spec.rb
|
|
122
|
+
- spec/bindings/track_search_spec.rb
|
|
119
123
|
- spec/client_modules/cache_spec.rb
|
|
120
124
|
- spec/deprecated/cache_config_spec.rb
|
|
121
125
|
- spec/deprecated/proxy_config_spec.rb
|
|
122
126
|
- spec/fixtures/kasabian.xml
|
|
127
|
+
- spec/fixtures/release_group/entity.xml
|
|
128
|
+
- spec/fixtures/release_group/search.xml
|
|
123
129
|
- spec/models/artist_spec.rb
|
|
124
130
|
- spec/models/base_model_spec.rb
|
|
125
131
|
- spec/models/release_group_spec.rb
|
|
@@ -134,30 +140,39 @@ rdoc_options: []
|
|
|
134
140
|
require_paths:
|
|
135
141
|
- lib
|
|
136
142
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
|
+
none: false
|
|
137
144
|
requirements:
|
|
138
145
|
- - ! '>='
|
|
139
146
|
- !ruby/object:Gem::Version
|
|
140
147
|
version: '0'
|
|
141
|
-
|
|
148
|
+
segments:
|
|
149
|
+
- 0
|
|
150
|
+
hash: 3461617473548305683
|
|
142
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
|
+
none: false
|
|
143
153
|
requirements:
|
|
144
154
|
- - ! '>='
|
|
145
155
|
- !ruby/object:Gem::Version
|
|
146
156
|
version: '0'
|
|
147
|
-
|
|
157
|
+
segments:
|
|
158
|
+
- 0
|
|
159
|
+
hash: 3461617473548305683
|
|
148
160
|
requirements: []
|
|
149
161
|
rubyforge_project:
|
|
150
|
-
rubygems_version: 1.8.
|
|
162
|
+
rubygems_version: 1.8.24
|
|
151
163
|
signing_key:
|
|
152
164
|
specification_version: 3
|
|
153
165
|
summary: MusicBrainz Web Service wrapper with ActiveRecord-style models
|
|
154
166
|
test_files:
|
|
155
167
|
- spec/bindings/release_group_search_spec.rb
|
|
156
168
|
- spec/bindings/release_spec.rb
|
|
169
|
+
- spec/bindings/track_search_spec.rb
|
|
157
170
|
- spec/client_modules/cache_spec.rb
|
|
158
171
|
- spec/deprecated/cache_config_spec.rb
|
|
159
172
|
- spec/deprecated/proxy_config_spec.rb
|
|
160
173
|
- spec/fixtures/kasabian.xml
|
|
174
|
+
- spec/fixtures/release_group/entity.xml
|
|
175
|
+
- spec/fixtures/release_group/search.xml
|
|
161
176
|
- spec/models/artist_spec.rb
|
|
162
177
|
- spec/models/base_model_spec.rb
|
|
163
178
|
- spec/models/release_group_spec.rb
|