brainz_releases 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/.gitignore +4 -0
- data/Gemfile +3 -0
- data/README.rdoc +46 -0
- data/Rakefile +2 -0
- data/brainz_releases.gemspec +25 -0
- data/lib/.DS_Store +0 -0
- data/lib/brainz_releases/release.rb +26 -0
- data/lib/brainz_releases/search.rb +73 -0
- data/lib/brainz_releases/version.rb +3 -0
- data/lib/brainz_releases.rb +10 -0
- data/spec/brainz_releases_spec.rb +14 -0
- data/spec/fixtures/ok.xml +724 -0
- data/spec/release_spec.rb +28 -0
- data/spec/search_spec.rb +155 -0
- data/spec/spec_helper.rb +2 -0
- metadata +108 -0
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
= BrainzReleases
|
2
|
+
|
3
|
+
Uses the {MusicBrainz XML Web Service (version 2)}[http://musicbrainz.org/doc/XML_Web_Service/Version_2] to extract the releases for an artist and turn them into nice ruby objects.
|
4
|
+
|
5
|
+
{Gem Documentation}[http://rubydoc.info/github/paulsturgess/musicbrainz/master/]
|
6
|
+
|
7
|
+
== Usage
|
8
|
+
|
9
|
+
Example:
|
10
|
+
|
11
|
+
require 'rubygems'
|
12
|
+
require 'brainz_releases'
|
13
|
+
|
14
|
+
releases = BrainzReleases.search do |search|
|
15
|
+
search.user_agent = "YourAppName/x.x" # Required – A string to identify your requests containing your app name and version number (this is required by the MusicBrainz API)
|
16
|
+
search.mbid = "9f9953f0-68bb-4ce3-aace-2f44c87f0aa3" # MusicBrainz artist ID
|
17
|
+
search.name = "Bonobo" # Only necessary if you don't know the MusicBrainz ID
|
18
|
+
search.start_date = Date.parse("1/1/2011") # Optional – defaults to 1 month ago
|
19
|
+
search.end_date = Date.parse("5/5/2011") # Optional – defaults to 1 month in the future
|
20
|
+
end
|
21
|
+
|
22
|
+
release = releases.first
|
23
|
+
|
24
|
+
# A BrainzReleases::Release object has a number of methods to easily access the attributes returned by the MusicBrainz api
|
25
|
+
# For example...
|
26
|
+
release.title # => "Fi"
|
27
|
+
release.date_available # => "2005-02-08"
|
28
|
+
release.release_type # => "Album"
|
29
|
+
release.label # => "Mush Records"
|
30
|
+
release.format # => "CD"
|
31
|
+
release.track_count # => "17"
|
32
|
+
release.country # => "US"
|
33
|
+
release.mbid # => "4a46ee61-75b5-4e2b-ac2e-81ef2ccec0f9"
|
34
|
+
release.artist # => "Bibio"
|
35
|
+
release.artist_mbid # => "9f9953f0-68bb-4ce3-aace-2f44c87f0aa3"
|
36
|
+
|
37
|
+
|
38
|
+
== Warnings
|
39
|
+
|
40
|
+
The MusicBrainz Web Service allows only ONE web service request per second. This gem DOES NOT implement any time based delay and takes no responsibility if you abuse the request limit.
|
41
|
+
|
42
|
+
{MusicBrainz API documentation}[http://musicbrainz.org/doc/XML_Web_Service/Version_2]
|
43
|
+
|
44
|
+
== Installation
|
45
|
+
|
46
|
+
gem install brainz_releases
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "brainz_releases/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "brainz_releases"
|
7
|
+
s.version = BrainzReleases::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Paul Sturgess"]
|
10
|
+
s.email = ["paulsturgess@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/paulsturgess/brainz_releases"
|
12
|
+
s.summary = "Provides a ruby inteface for extracting the releases for an artist from MusicBrainz"
|
13
|
+
s.description = "Uses the MusicBrainz XML Web Service (version 2) to extract the releases for an artist and turn them into nice ruby objects."
|
14
|
+
|
15
|
+
s.rubyforge_project = "brainz_releases"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_runtime_dependency "nokogiri", "~> 1.4"
|
23
|
+
s.add_development_dependency "rspec", "~> 2.6"
|
24
|
+
s.add_development_dependency "fakeweb", "~> 1.3.0"
|
25
|
+
end
|
data/lib/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module BrainzReleases
|
2
|
+
class Release
|
3
|
+
|
4
|
+
attr_accessor :mbid, :title, :release_type, :date_available, :artist, :artist_mbid, :label, :track_count, :country, :format
|
5
|
+
|
6
|
+
def initialize(*args, &block)
|
7
|
+
self.instance_eval(&block) if block
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.build_from_node(node)
|
11
|
+
Release.new do |release|
|
12
|
+
release.mbid = node["id"]
|
13
|
+
release.artist = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:artist-credit/xmlns:name-credit/xmlns:artist/xmlns:name").first.content rescue nil
|
14
|
+
release.artist_mbid = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:artist-credit/xmlns:name-credit/xmlns:artist").first['id']
|
15
|
+
release.title = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:title").first.content rescue nil
|
16
|
+
release.release_type = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:release-group").first['type']
|
17
|
+
release.date_available = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:date").first.content rescue nil
|
18
|
+
release.track_count = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:medium-list/xmlns:track-count").first.content rescue nil
|
19
|
+
release.format = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:medium-list/xmlns:medium/xmlns:format").first.content rescue nil
|
20
|
+
release.label = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:label-info-list/xmlns:label-info/xmlns:label/xmlns:name").first.content rescue nil
|
21
|
+
release.country = node.xpath("//xmlns:release[@id='#{release.mbid}']/xmlns:country").first.content rescue nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'net/http'
|
4
|
+
require 'CGI'
|
5
|
+
require 'Date'
|
6
|
+
|
7
|
+
module BrainzReleases
|
8
|
+
class Search
|
9
|
+
|
10
|
+
class Error < StandardError; end
|
11
|
+
class ResponseError < Error; end
|
12
|
+
class ConfigError < Error; end
|
13
|
+
|
14
|
+
attr_accessor :name, :mbid, :start_date, :end_date, :user_agent
|
15
|
+
|
16
|
+
def self.search(*args, &block)
|
17
|
+
Search.new(*args, &block).results
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(*args, &block)
|
21
|
+
(block.arity < 1 ? self.instance_eval(&block) : block.call(self)) if block
|
22
|
+
raise ConfigError, "You must provide a :name or :mbid parameter" if [name, mbid].all?(&:nil?)
|
23
|
+
raise ConfigError, "You must provide a user_agent parameter to identify your requests" if user_agent.nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
def start_date
|
27
|
+
@start_date ||= Date.today << 1
|
28
|
+
end
|
29
|
+
|
30
|
+
def end_date
|
31
|
+
@end_date ||= Date.today >> 1
|
32
|
+
end
|
33
|
+
|
34
|
+
#http://musicbrainz.org/ws/2/release/?type=xml&query=arid:2ff0dfc6-0542-4bbc-a44a-60605c074ba6
|
35
|
+
|
36
|
+
# Musicbrainz uri to request releases
|
37
|
+
def uri
|
38
|
+
URI.parse("http://musicbrainz.org/ws/2/release/?type=xml&query=#{query}")
|
39
|
+
end
|
40
|
+
|
41
|
+
def releases_xml
|
42
|
+
http = Net::HTTP.new(uri.host)
|
43
|
+
request = Net::HTTP::Get.new(uri.request_uri, {"User-Agent" => user_agent})
|
44
|
+
response = http.request(request)
|
45
|
+
case response.code
|
46
|
+
when "200"
|
47
|
+
@releases_xml = Nokogiri::XML(response.body)
|
48
|
+
else
|
49
|
+
raise ResponseError, "There is a problem accessing the Music Brainz api"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns an array of BrainzReleases::Release objects
|
54
|
+
def results
|
55
|
+
(releases = []).tap do
|
56
|
+
releases_xml.xpath('//xmlns:release').each do |node|
|
57
|
+
releases << BrainzReleases::Release.build_from_node(node)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def query
|
65
|
+
CGI.escape("#{artist_param} AND date:[#{start_date.to_s} TO #{end_date.to_s}]")
|
66
|
+
end
|
67
|
+
|
68
|
+
def artist_param
|
69
|
+
mbid ? "arid:#{mbid}" : "artist:#{name}"
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,724 @@
|
|
1
|
+
<metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ext="http://musicbrainz.org/ns/ext#-2.0">
|
2
|
+
<release-list offset="0" count="20">
|
3
|
+
<release ext:score="100" id="4a46ee61-75b5-4e2b-ac2e-81ef2ccec0f9">
|
4
|
+
<title>Fi</title>
|
5
|
+
<status>Official</status>
|
6
|
+
<text-representation>
|
7
|
+
<language>eng</language>
|
8
|
+
<script>Latn</script>
|
9
|
+
</text-representation>
|
10
|
+
<artist-credit>
|
11
|
+
<name-credit>
|
12
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
13
|
+
<name>Bibio</name>
|
14
|
+
<sort-name>Bibio</sort-name>
|
15
|
+
</artist>
|
16
|
+
</name-credit>
|
17
|
+
</artist-credit>
|
18
|
+
<release-group type="Album" id="02f2abd4-155b-36e8-abe8-dc99d3083958"/>
|
19
|
+
<date>2005-02-08</date>
|
20
|
+
<country>US</country>
|
21
|
+
<barcode>663405123424</barcode>
|
22
|
+
<asin>B0006ZXJ8O</asin>
|
23
|
+
<label-info-list>
|
24
|
+
<label-info>
|
25
|
+
<catalog-number>MH-234</catalog-number>
|
26
|
+
<label id="05e6e753-0f22-438d-9cdd-cdc57eb56433">
|
27
|
+
<name>Mush Records</name>
|
28
|
+
</label>
|
29
|
+
</label-info>
|
30
|
+
</label-info-list>
|
31
|
+
<medium-list count="1">
|
32
|
+
<track-count>17</track-count>
|
33
|
+
<medium>
|
34
|
+
<format>CD</format>
|
35
|
+
<disc-list count="1"/>
|
36
|
+
<track-list count="17"/>
|
37
|
+
</medium>
|
38
|
+
</medium-list>
|
39
|
+
</release>
|
40
|
+
<release ext:score="100" id="40504860-1d87-4632-adb1-67bb94f928ed">
|
41
|
+
<title>Hand Cranked</title>
|
42
|
+
<status>Official</status>
|
43
|
+
<text-representation>
|
44
|
+
<language>eng</language>
|
45
|
+
<script>Latn</script>
|
46
|
+
</text-representation>
|
47
|
+
<artist-credit>
|
48
|
+
<name-credit>
|
49
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
50
|
+
<name>Bibio</name>
|
51
|
+
<sort-name>Bibio</sort-name>
|
52
|
+
</artist>
|
53
|
+
</name-credit>
|
54
|
+
</artist-credit>
|
55
|
+
<release-group type="Album" id="662f6134-c6e9-3869-ad67-3bdee1bfeb1c"/>
|
56
|
+
<date>2006-03-07</date>
|
57
|
+
<country>US</country>
|
58
|
+
<label-info-list>
|
59
|
+
<label-info>
|
60
|
+
<catalog-number>MH-244</catalog-number>
|
61
|
+
<label id="05e6e753-0f22-438d-9cdd-cdc57eb56433">
|
62
|
+
<name>Mush Records</name>
|
63
|
+
</label>
|
64
|
+
</label-info>
|
65
|
+
</label-info-list>
|
66
|
+
<medium-list count="1">
|
67
|
+
<track-count>14</track-count>
|
68
|
+
<medium>
|
69
|
+
<format>CD</format>
|
70
|
+
<disc-list count="1"/>
|
71
|
+
<track-list count="14"/>
|
72
|
+
</medium>
|
73
|
+
</medium-list>
|
74
|
+
</release>
|
75
|
+
<release ext:score="100" id="835c99e1-e7ac-4ee1-b294-083113921fe8">
|
76
|
+
<title>Sheila Sets Sail</title>
|
77
|
+
<status>Official</status>
|
78
|
+
<text-representation>
|
79
|
+
<language>eng</language>
|
80
|
+
<script>Latn</script>
|
81
|
+
</text-representation>
|
82
|
+
<artist-credit>
|
83
|
+
<name-credit>
|
84
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
85
|
+
<name>Bibio</name>
|
86
|
+
<sort-name>Bibio</sort-name>
|
87
|
+
</artist>
|
88
|
+
</name-credit>
|
89
|
+
</artist-credit>
|
90
|
+
<release-group type="Single" id="12dd993b-2d1a-37fc-b32e-0cf5b7717533"/>
|
91
|
+
<date>2006</date>
|
92
|
+
<country>GB</country>
|
93
|
+
<medium-list count="1">
|
94
|
+
<track-count>2</track-count>
|
95
|
+
<medium>
|
96
|
+
<disc-list count="0"/>
|
97
|
+
<track-list count="2"/>
|
98
|
+
</medium>
|
99
|
+
</medium-list>
|
100
|
+
</release>
|
101
|
+
<release ext:score="100" id="f414d3cc-c6f3-44bc-8e43-cef73f289d3c">
|
102
|
+
<title>Vignetting the Compost</title>
|
103
|
+
<status>Official</status>
|
104
|
+
<text-representation>
|
105
|
+
<language>eng</language>
|
106
|
+
<script>Latn</script>
|
107
|
+
</text-representation>
|
108
|
+
<artist-credit>
|
109
|
+
<name-credit>
|
110
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
111
|
+
<name>Bibio</name>
|
112
|
+
<sort-name>Bibio</sort-name>
|
113
|
+
</artist>
|
114
|
+
</name-credit>
|
115
|
+
</artist-credit>
|
116
|
+
<release-group type="Album" id="1860599e-1a1e-3a42-8fdc-eb7af9b9e190"/>
|
117
|
+
<date>2009-02-03</date>
|
118
|
+
<country>US</country>
|
119
|
+
<barcode>663405126326</barcode>
|
120
|
+
<asin>B001NJY5LW</asin>
|
121
|
+
<label-info-list>
|
122
|
+
<label-info>
|
123
|
+
<catalog-number>MH-263</catalog-number>
|
124
|
+
<label id="05e6e753-0f22-438d-9cdd-cdc57eb56433">
|
125
|
+
<name>Mush Records</name>
|
126
|
+
</label>
|
127
|
+
</label-info>
|
128
|
+
</label-info-list>
|
129
|
+
<medium-list count="1">
|
130
|
+
<track-count>16</track-count>
|
131
|
+
<medium>
|
132
|
+
<format>CD</format>
|
133
|
+
<disc-list count="1"/>
|
134
|
+
<track-list count="16"/>
|
135
|
+
</medium>
|
136
|
+
</medium-list>
|
137
|
+
</release>
|
138
|
+
<release ext:score="100" id="a7bf4f6b-babb-48ea-aaf3-d17538137654">
|
139
|
+
<title>Ovals and Emeralds</title>
|
140
|
+
<status>Official</status>
|
141
|
+
<text-representation>
|
142
|
+
<language>eng</language>
|
143
|
+
<script>Latn</script>
|
144
|
+
</text-representation>
|
145
|
+
<artist-credit>
|
146
|
+
<name-credit>
|
147
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
148
|
+
<name>Bibio</name>
|
149
|
+
<sort-name>Bibio</sort-name>
|
150
|
+
</artist>
|
151
|
+
</name-credit>
|
152
|
+
</artist-credit>
|
153
|
+
<release-group type="EP" id="9c5b0bb0-d421-366f-929a-19a8b9850fc8"/>
|
154
|
+
<date>2009-03-03</date>
|
155
|
+
<country>XW</country>
|
156
|
+
<label-info-list>
|
157
|
+
<label-info>
|
158
|
+
<catalog-number>MH-042</catalog-number>
|
159
|
+
<label id="05e6e753-0f22-438d-9cdd-cdc57eb56433">
|
160
|
+
<name>Mush Records</name>
|
161
|
+
</label>
|
162
|
+
</label-info>
|
163
|
+
</label-info-list>
|
164
|
+
<medium-list count="1">
|
165
|
+
<track-count>6</track-count>
|
166
|
+
<medium>
|
167
|
+
<format>Digital Media</format>
|
168
|
+
<disc-list count="0"/>
|
169
|
+
<track-list count="6"/>
|
170
|
+
</medium>
|
171
|
+
</medium-list>
|
172
|
+
</release>
|
173
|
+
<release ext:score="100" id="244d8104-820b-4fc3-9ed6-336c3a317d5c">
|
174
|
+
<title>Ambivalence Avenue</title>
|
175
|
+
<status>Official</status>
|
176
|
+
<text-representation>
|
177
|
+
<language>eng</language>
|
178
|
+
<script>Latn</script>
|
179
|
+
</text-representation>
|
180
|
+
<artist-credit>
|
181
|
+
<name-credit>
|
182
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
183
|
+
<name>Bibio</name>
|
184
|
+
<sort-name>Bibio</sort-name>
|
185
|
+
</artist>
|
186
|
+
</name-credit>
|
187
|
+
</artist-credit>
|
188
|
+
<release-group type="Album" id="a4c6be15-bfc4-4078-b80b-d9f03a4049b1"/>
|
189
|
+
<date>2009-06-22</date>
|
190
|
+
<country>GB</country>
|
191
|
+
<barcode>801061017729</barcode>
|
192
|
+
<asin>B00292SQNA</asin>
|
193
|
+
<label-info-list>
|
194
|
+
<label-info>
|
195
|
+
<catalog-number>WARPCD177</catalog-number>
|
196
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
197
|
+
<name>Warp Records</name>
|
198
|
+
</label>
|
199
|
+
</label-info>
|
200
|
+
</label-info-list>
|
201
|
+
<medium-list count="1">
|
202
|
+
<track-count>12</track-count>
|
203
|
+
<medium>
|
204
|
+
<format>CD</format>
|
205
|
+
<disc-list count="1"/>
|
206
|
+
<track-list count="12"/>
|
207
|
+
</medium>
|
208
|
+
</medium-list>
|
209
|
+
</release>
|
210
|
+
<release ext:score="100" id="e479ca69-79b4-40f0-8e44-c09a065e3136">
|
211
|
+
<title>Ambivalence Avenue / Fire Ant</title>
|
212
|
+
<status>Official</status>
|
213
|
+
<text-representation>
|
214
|
+
<language>eng</language>
|
215
|
+
<script>Latn</script>
|
216
|
+
</text-representation>
|
217
|
+
<artist-credit>
|
218
|
+
<name-credit>
|
219
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
220
|
+
<name>Bibio</name>
|
221
|
+
<sort-name>Bibio</sort-name>
|
222
|
+
</artist>
|
223
|
+
</name-credit>
|
224
|
+
</artist-credit>
|
225
|
+
<release-group type="Single" id="67cd2404-7a3e-4cf8-b6f0-4f7eb2f489e7"/>
|
226
|
+
<date>2009-06-08</date>
|
227
|
+
<country>GB</country>
|
228
|
+
<barcode>0801061927974</barcode>
|
229
|
+
<asin>B002A03J1A</asin>
|
230
|
+
<label-info-list>
|
231
|
+
<label-info>
|
232
|
+
<catalog-number>7WAP279</catalog-number>
|
233
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
234
|
+
<name>Warp Records</name>
|
235
|
+
</label>
|
236
|
+
</label-info>
|
237
|
+
</label-info-list>
|
238
|
+
<medium-list count="1">
|
239
|
+
<track-count>2</track-count>
|
240
|
+
<medium>
|
241
|
+
<format>Vinyl</format>
|
242
|
+
<disc-list count="0"/>
|
243
|
+
<track-list count="2"/>
|
244
|
+
</medium>
|
245
|
+
</medium-list>
|
246
|
+
</release>
|
247
|
+
<release ext:score="100" id="d542e30e-b50e-4f48-b622-18471f4641b1">
|
248
|
+
<title>The Apple and The Tooth</title>
|
249
|
+
<status>Official</status>
|
250
|
+
<text-representation>
|
251
|
+
<language>eng</language>
|
252
|
+
<script>Latn</script>
|
253
|
+
</text-representation>
|
254
|
+
<artist-credit>
|
255
|
+
<name-credit>
|
256
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
257
|
+
<name>Bibio</name>
|
258
|
+
<sort-name>Bibio</sort-name>
|
259
|
+
</artist>
|
260
|
+
</name-credit>
|
261
|
+
</artist-credit>
|
262
|
+
<release-group type="EP" id="54494aea-4596-464c-b3fa-e984b13b59b7"/>
|
263
|
+
<date>2009-11-10</date>
|
264
|
+
<country>US</country>
|
265
|
+
<barcode>0801061019020</barcode>
|
266
|
+
<asin>B002QXIO20</asin>
|
267
|
+
<label-info-list>
|
268
|
+
<label-info>
|
269
|
+
<catalog-number>WARPCD190</catalog-number>
|
270
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
271
|
+
<name>Warp Records</name>
|
272
|
+
</label>
|
273
|
+
</label-info>
|
274
|
+
</label-info-list>
|
275
|
+
<medium-list count="1">
|
276
|
+
<track-count>12</track-count>
|
277
|
+
<medium>
|
278
|
+
<format>CD</format>
|
279
|
+
<disc-list count="1"/>
|
280
|
+
<track-list count="12"/>
|
281
|
+
</medium>
|
282
|
+
</medium-list>
|
283
|
+
</release>
|
284
|
+
<release ext:score="100" id="23df32ab-b08a-39b7-8fbb-d33a7f1bc1d6">
|
285
|
+
<title>The Apple and The Tooth</title>
|
286
|
+
<status>Official</status>
|
287
|
+
<text-representation>
|
288
|
+
<language>eng</language>
|
289
|
+
<script>Latn</script>
|
290
|
+
</text-representation>
|
291
|
+
<artist-credit>
|
292
|
+
<name-credit>
|
293
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
294
|
+
<name>Bibio</name>
|
295
|
+
<sort-name>Bibio</sort-name>
|
296
|
+
</artist>
|
297
|
+
</name-credit>
|
298
|
+
</artist-credit>
|
299
|
+
<release-group type="EP" id="54494aea-4596-464c-b3fa-e984b13b59b7"/>
|
300
|
+
<date>2009-11-09</date>
|
301
|
+
<country>GB</country>
|
302
|
+
<barcode>0801061019020</barcode>
|
303
|
+
<asin>B002QXIO20</asin>
|
304
|
+
<label-info-list>
|
305
|
+
<label-info>
|
306
|
+
<catalog-number>WARPCD190</catalog-number>
|
307
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
308
|
+
<name>Warp Records</name>
|
309
|
+
</label>
|
310
|
+
</label-info>
|
311
|
+
</label-info-list>
|
312
|
+
<medium-list count="1">
|
313
|
+
<track-count>12</track-count>
|
314
|
+
<medium>
|
315
|
+
<format>CD</format>
|
316
|
+
<disc-list count="1"/>
|
317
|
+
<track-list count="12"/>
|
318
|
+
</medium>
|
319
|
+
</medium-list>
|
320
|
+
</release>
|
321
|
+
<release ext:score="100" id="f98ddb9c-98a1-3695-ace2-7be211730663">
|
322
|
+
<title>The Apple and The Tooth</title>
|
323
|
+
<status>Official</status>
|
324
|
+
<text-representation>
|
325
|
+
<language>eng</language>
|
326
|
+
<script>Latn</script>
|
327
|
+
</text-representation>
|
328
|
+
<artist-credit>
|
329
|
+
<name-credit>
|
330
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
331
|
+
<name>Bibio</name>
|
332
|
+
<sort-name>Bibio</sort-name>
|
333
|
+
</artist>
|
334
|
+
</name-credit>
|
335
|
+
</artist-credit>
|
336
|
+
<release-group type="EP" id="54494aea-4596-464c-b3fa-e984b13b59b7"/>
|
337
|
+
<date>2009-11-09</date>
|
338
|
+
<country>GB</country>
|
339
|
+
<barcode>0801061019013</barcode>
|
340
|
+
<label-info-list>
|
341
|
+
<label-info>
|
342
|
+
<catalog-number>WARPLP190</catalog-number>
|
343
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
344
|
+
<name>Warp Records</name>
|
345
|
+
</label>
|
346
|
+
</label-info>
|
347
|
+
</label-info-list>
|
348
|
+
<medium-list count="1">
|
349
|
+
<track-count>12</track-count>
|
350
|
+
<medium>
|
351
|
+
<format>Vinyl</format>
|
352
|
+
<disc-list count="0"/>
|
353
|
+
<track-list count="12"/>
|
354
|
+
</medium>
|
355
|
+
</medium-list>
|
356
|
+
</release>
|
357
|
+
<release ext:score="100" id="8ac778dd-18f8-3593-9475-5315407f05f3">
|
358
|
+
<title>The Apple and The Tooth</title>
|
359
|
+
<status>Official</status>
|
360
|
+
<text-representation>
|
361
|
+
<language>eng</language>
|
362
|
+
<script>Latn</script>
|
363
|
+
</text-representation>
|
364
|
+
<artist-credit>
|
365
|
+
<name-credit>
|
366
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
367
|
+
<name>Bibio</name>
|
368
|
+
<sort-name>Bibio</sort-name>
|
369
|
+
</artist>
|
370
|
+
</name-credit>
|
371
|
+
</artist-credit>
|
372
|
+
<release-group type="EP" id="54494aea-4596-464c-b3fa-e984b13b59b7"/>
|
373
|
+
<date>2009-11-10</date>
|
374
|
+
<country>US</country>
|
375
|
+
<barcode>0801061019013</barcode>
|
376
|
+
<label-info-list>
|
377
|
+
<label-info>
|
378
|
+
<catalog-number>WARPLP190</catalog-number>
|
379
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
380
|
+
<name>Warp Records</name>
|
381
|
+
</label>
|
382
|
+
</label-info>
|
383
|
+
</label-info-list>
|
384
|
+
<medium-list count="1">
|
385
|
+
<track-count>12</track-count>
|
386
|
+
<medium>
|
387
|
+
<format>Vinyl</format>
|
388
|
+
<disc-list count="0"/>
|
389
|
+
<track-list count="12"/>
|
390
|
+
</medium>
|
391
|
+
</medium-list>
|
392
|
+
</release>
|
393
|
+
<release ext:score="100" id="a1c72efd-ec9d-40c3-8331-ad10077a152f">
|
394
|
+
<title>Mind Bokeh</title>
|
395
|
+
<status>Official</status>
|
396
|
+
<text-representation>
|
397
|
+
<language>eng</language>
|
398
|
+
<script>Latn</script>
|
399
|
+
</text-representation>
|
400
|
+
<artist-credit>
|
401
|
+
<name-credit>
|
402
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
403
|
+
<name>Bibio</name>
|
404
|
+
<sort-name>Bibio</sort-name>
|
405
|
+
</artist>
|
406
|
+
</name-credit>
|
407
|
+
</artist-credit>
|
408
|
+
<release-group type="Album" id="2f155de9-53b1-4167-b206-ccbaffcece50"/>
|
409
|
+
<date>2011-04-04</date>
|
410
|
+
<country>GB</country>
|
411
|
+
<barcode>801061020927</barcode>
|
412
|
+
<asin>B004IMDCJC</asin>
|
413
|
+
<label-info-list>
|
414
|
+
<label-info>
|
415
|
+
<catalog-number>WARPCD209</catalog-number>
|
416
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
417
|
+
<name>Warp Records</name>
|
418
|
+
</label>
|
419
|
+
</label-info>
|
420
|
+
</label-info-list>
|
421
|
+
<medium-list count="1">
|
422
|
+
<track-count>12</track-count>
|
423
|
+
<medium>
|
424
|
+
<format>CD</format>
|
425
|
+
<disc-list count="1"/>
|
426
|
+
<track-list count="12"/>
|
427
|
+
</medium>
|
428
|
+
</medium-list>
|
429
|
+
</release>
|
430
|
+
<release ext:score="100" id="d548c96b-0852-3933-b8cd-f7e5b0407df9">
|
431
|
+
<title>Mind Bokeh</title>
|
432
|
+
<status>Official</status>
|
433
|
+
<text-representation>
|
434
|
+
<language>eng</language>
|
435
|
+
<script>Latn</script>
|
436
|
+
</text-representation>
|
437
|
+
<artist-credit>
|
438
|
+
<name-credit>
|
439
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
440
|
+
<name>Bibio</name>
|
441
|
+
<sort-name>Bibio</sort-name>
|
442
|
+
</artist>
|
443
|
+
</name-credit>
|
444
|
+
</artist-credit>
|
445
|
+
<release-group type="Album" id="2f155de9-53b1-4167-b206-ccbaffcece50"/>
|
446
|
+
<date>2011-03-29</date>
|
447
|
+
<country>US</country>
|
448
|
+
<barcode>801061020927</barcode>
|
449
|
+
<asin>B004IMDCJC</asin>
|
450
|
+
<label-info-list>
|
451
|
+
<label-info>
|
452
|
+
<catalog-number>WARPCD209</catalog-number>
|
453
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
454
|
+
<name>Warp Records</name>
|
455
|
+
</label>
|
456
|
+
</label-info>
|
457
|
+
</label-info-list>
|
458
|
+
<medium-list count="1">
|
459
|
+
<track-count>12</track-count>
|
460
|
+
<medium>
|
461
|
+
<format>CD</format>
|
462
|
+
<disc-list count="1"/>
|
463
|
+
<track-list count="12"/>
|
464
|
+
</medium>
|
465
|
+
</medium-list>
|
466
|
+
</release>
|
467
|
+
<release ext:score="100" id="d9990af1-9604-3324-bf90-9f6ea46a3b02">
|
468
|
+
<title>Mind Bokeh</title>
|
469
|
+
<status>Official</status>
|
470
|
+
<text-representation>
|
471
|
+
<language>eng</language>
|
472
|
+
<script>Latn</script>
|
473
|
+
</text-representation>
|
474
|
+
<artist-credit>
|
475
|
+
<name-credit>
|
476
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
477
|
+
<name>Bibio</name>
|
478
|
+
<sort-name>Bibio</sort-name>
|
479
|
+
</artist>
|
480
|
+
</name-credit>
|
481
|
+
</artist-credit>
|
482
|
+
<release-group type="Album" id="2f155de9-53b1-4167-b206-ccbaffcece50"/>
|
483
|
+
<date>2011-03-29</date>
|
484
|
+
<country>US</country>
|
485
|
+
<label-info-list>
|
486
|
+
<label-info>
|
487
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
488
|
+
<name>Warp Records</name>
|
489
|
+
</label>
|
490
|
+
</label-info>
|
491
|
+
</label-info-list>
|
492
|
+
<medium-list count="1">
|
493
|
+
<track-count>12</track-count>
|
494
|
+
<medium>
|
495
|
+
<format>Digital Media</format>
|
496
|
+
<disc-list count="0"/>
|
497
|
+
<track-list count="12"/>
|
498
|
+
</medium>
|
499
|
+
</medium-list>
|
500
|
+
</release>
|
501
|
+
<release ext:score="100" id="35a6a938-b84c-3239-851e-3ded19b79cff">
|
502
|
+
<title>Mind Bokeh</title>
|
503
|
+
<status>Official</status>
|
504
|
+
<text-representation>
|
505
|
+
<language>eng</language>
|
506
|
+
<script>Latn</script>
|
507
|
+
</text-representation>
|
508
|
+
<artist-credit>
|
509
|
+
<name-credit>
|
510
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
511
|
+
<name>Bibio</name>
|
512
|
+
<sort-name>Bibio</sort-name>
|
513
|
+
</artist>
|
514
|
+
</name-credit>
|
515
|
+
</artist-credit>
|
516
|
+
<release-group type="Album" id="2f155de9-53b1-4167-b206-ccbaffcece50"/>
|
517
|
+
<date>2011-04-04</date>
|
518
|
+
<country>XW</country>
|
519
|
+
<label-info-list>
|
520
|
+
<label-info>
|
521
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
522
|
+
<name>Warp Records</name>
|
523
|
+
</label>
|
524
|
+
</label-info>
|
525
|
+
</label-info-list>
|
526
|
+
<medium-list count="1">
|
527
|
+
<track-count>12</track-count>
|
528
|
+
<medium>
|
529
|
+
<format>Digital Media</format>
|
530
|
+
<disc-list count="0"/>
|
531
|
+
<track-list count="12"/>
|
532
|
+
</medium>
|
533
|
+
</medium-list>
|
534
|
+
</release>
|
535
|
+
<release ext:score="100" id="039f78b8-6c06-4b8f-9451-93a2aba37c0c">
|
536
|
+
<title>Excuses</title>
|
537
|
+
<status>Official</status>
|
538
|
+
<text-representation>
|
539
|
+
<language>eng</language>
|
540
|
+
<script>Latn</script>
|
541
|
+
</text-representation>
|
542
|
+
<artist-credit>
|
543
|
+
<name-credit>
|
544
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
545
|
+
<name>Bibio</name>
|
546
|
+
<sort-name>Bibio</sort-name>
|
547
|
+
</artist>
|
548
|
+
</name-credit>
|
549
|
+
</artist-credit>
|
550
|
+
<release-group type="Single" id="9c1db9c1-2b92-419a-9fc2-3db348f8d524"/>
|
551
|
+
<date>2011-02-28</date>
|
552
|
+
<country>GB</country>
|
553
|
+
<barcode>0801061931414</barcode>
|
554
|
+
<asin>B004MCH0SC</asin>
|
555
|
+
<label-info-list>
|
556
|
+
<label-info>
|
557
|
+
<catalog-number>10WAP314</catalog-number>
|
558
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
559
|
+
<name>Warp Records</name>
|
560
|
+
</label>
|
561
|
+
</label-info>
|
562
|
+
</label-info-list>
|
563
|
+
<medium-list count="1">
|
564
|
+
<track-count>2</track-count>
|
565
|
+
<medium>
|
566
|
+
<format>Vinyl</format>
|
567
|
+
<disc-list count="0"/>
|
568
|
+
<track-list count="2"/>
|
569
|
+
</medium>
|
570
|
+
</medium-list>
|
571
|
+
</release>
|
572
|
+
<release ext:score="100" id="0e5c7946-9b8f-457c-802d-a3154b3caae7">
|
573
|
+
<title>Willenhall / Baskerville Grinch</title>
|
574
|
+
<status>Official</status>
|
575
|
+
<text-representation>
|
576
|
+
<language>eng</language>
|
577
|
+
<script>Latn</script>
|
578
|
+
</text-representation>
|
579
|
+
<artist-credit>
|
580
|
+
<name-credit joinphrase=" / ">
|
581
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
582
|
+
<name>Bibio</name>
|
583
|
+
<sort-name>Bibio</sort-name>
|
584
|
+
</artist>
|
585
|
+
</name-credit>
|
586
|
+
<name-credit>
|
587
|
+
<name>Clark</name>
|
588
|
+
<artist id="5d0c202c-e30f-40c4-abf5-c0007af0d1cc">
|
589
|
+
<name>Chris Clark</name>
|
590
|
+
<sort-name>Clark, Chris</sort-name>
|
591
|
+
<disambiguation>of Warp Records</disambiguation>
|
592
|
+
</artist>
|
593
|
+
</name-credit>
|
594
|
+
</artist-credit>
|
595
|
+
<release-group type="Single" id="5fcfd2af-4a90-4eb8-84df-5cdb7c14d90d"/>
|
596
|
+
<date>2011-04-16</date>
|
597
|
+
<country>GB</country>
|
598
|
+
<barcode>801061931810</barcode>
|
599
|
+
<label-info-list>
|
600
|
+
<label-info>
|
601
|
+
<catalog-number>WAP318</catalog-number>
|
602
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
603
|
+
<name>Warp Records</name>
|
604
|
+
</label>
|
605
|
+
</label-info>
|
606
|
+
</label-info-list>
|
607
|
+
<medium-list count="1">
|
608
|
+
<track-count>2</track-count>
|
609
|
+
<medium>
|
610
|
+
<format>Vinyl</format>
|
611
|
+
<disc-list count="0"/>
|
612
|
+
<track-list count="2"/>
|
613
|
+
</medium>
|
614
|
+
</medium-list>
|
615
|
+
</release>
|
616
|
+
<release ext:score="100" id="eb980750-8eb2-4ac3-8328-0f0ca8d9e414">
|
617
|
+
<title>K Is for Kelson</title>
|
618
|
+
<status>Official</status>
|
619
|
+
<text-representation>
|
620
|
+
<language>eng</language>
|
621
|
+
<script>Latn</script>
|
622
|
+
</text-representation>
|
623
|
+
<artist-credit>
|
624
|
+
<name-credit>
|
625
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
626
|
+
<name>Bibio</name>
|
627
|
+
<sort-name>Bibio</sort-name>
|
628
|
+
</artist>
|
629
|
+
</name-credit>
|
630
|
+
</artist-credit>
|
631
|
+
<release-group type="Single" id="abeec470-b316-4795-a2df-4f4e8d7bd5eb"/>
|
632
|
+
<date>2011-05-23</date>
|
633
|
+
<country>GB</country>
|
634
|
+
<asin>B004XKBD5E</asin>
|
635
|
+
<label-info-list>
|
636
|
+
<label-info>
|
637
|
+
<catalog-number>WAP316</catalog-number>
|
638
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
639
|
+
<name>Warp Records</name>
|
640
|
+
</label>
|
641
|
+
</label-info>
|
642
|
+
</label-info-list>
|
643
|
+
<medium-list count="1">
|
644
|
+
<track-count>4</track-count>
|
645
|
+
<medium>
|
646
|
+
<format>12" Vinyl</format>
|
647
|
+
<disc-list count="0"/>
|
648
|
+
<track-list count="4"/>
|
649
|
+
</medium>
|
650
|
+
</medium-list>
|
651
|
+
</release>
|
652
|
+
<release ext:score="100" id="4ec17c32-daca-4c95-ad5e-10fef55bf876">
|
653
|
+
<title>K Is for Kelson</title>
|
654
|
+
<status>Official</status>
|
655
|
+
<text-representation>
|
656
|
+
<language>eng</language>
|
657
|
+
<script>Latn</script>
|
658
|
+
</text-representation>
|
659
|
+
<artist-credit>
|
660
|
+
<name-credit>
|
661
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
662
|
+
<name>Bibio</name>
|
663
|
+
<sort-name>Bibio</sort-name>
|
664
|
+
</artist>
|
665
|
+
</name-credit>
|
666
|
+
</artist-credit>
|
667
|
+
<release-group type="Single" id="abeec470-b316-4795-a2df-4f4e8d7bd5eb"/>
|
668
|
+
<date>2011-05-23</date>
|
669
|
+
<country>GB</country>
|
670
|
+
<asin>B005099E1W</asin>
|
671
|
+
<label-info-list>
|
672
|
+
<label-info>
|
673
|
+
<catalog-number>WAP316D</catalog-number>
|
674
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
675
|
+
<name>Warp Records</name>
|
676
|
+
</label>
|
677
|
+
</label-info>
|
678
|
+
</label-info-list>
|
679
|
+
<medium-list count="1">
|
680
|
+
<track-count>4</track-count>
|
681
|
+
<medium>
|
682
|
+
<format>Digital Media</format>
|
683
|
+
<disc-list count="0"/>
|
684
|
+
<track-list count="4"/>
|
685
|
+
</medium>
|
686
|
+
</medium-list>
|
687
|
+
</release>
|
688
|
+
<release ext:score="100" id="4b53cfcc-ae4c-4c5b-9881-ffcee23709b3">
|
689
|
+
<title>T.O.Y.S.</title>
|
690
|
+
<status>Official</status>
|
691
|
+
<text-representation>
|
692
|
+
<language>eng</language>
|
693
|
+
<script>Latn</script>
|
694
|
+
</text-representation>
|
695
|
+
<artist-credit>
|
696
|
+
<name-credit>
|
697
|
+
<artist id="9f9953f0-68bb-4ce3-aace-2f44c87f0aa3">
|
698
|
+
<name>Bibio</name>
|
699
|
+
<sort-name>Bibio</sort-name>
|
700
|
+
</artist>
|
701
|
+
</name-credit>
|
702
|
+
</artist-credit>
|
703
|
+
<release-group type="Single" id="7d0bcfad-54cd-4fde-973c-ff934004a0d1"/>
|
704
|
+
<date>2011-08-01</date>
|
705
|
+
<country>GB</country>
|
706
|
+
<label-info-list>
|
707
|
+
<label-info>
|
708
|
+
<catalog-number>WAP320D</catalog-number>
|
709
|
+
<label id="46f0f4cd-8aab-4b33-b698-f459faf64190">
|
710
|
+
<name>Warp Records</name>
|
711
|
+
</label>
|
712
|
+
</label-info>
|
713
|
+
</label-info-list>
|
714
|
+
<medium-list count="1">
|
715
|
+
<track-count>4</track-count>
|
716
|
+
<medium>
|
717
|
+
<format>Digital Media</format>
|
718
|
+
<disc-list count="0"/>
|
719
|
+
<track-list count="4"/>
|
720
|
+
</medium>
|
721
|
+
</medium-list>
|
722
|
+
</release>
|
723
|
+
</release-list>
|
724
|
+
</metadata>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe BrainzReleases::Release do
|
4
|
+
|
5
|
+
|
6
|
+
describe "build_from_node" do
|
7
|
+
|
8
|
+
before do
|
9
|
+
node = Nokogiri::XML(File.read("spec/fixtures/ok.xml")).xpath('//xmlns:release').first
|
10
|
+
@release = BrainzReleases::Release.build_from_node(node)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set the attributes" do
|
14
|
+
@release.mbid.should == "4a46ee61-75b5-4e2b-ac2e-81ef2ccec0f9"
|
15
|
+
@release.artist.should == "Bibio"
|
16
|
+
@release.artist_mbid.should == "9f9953f0-68bb-4ce3-aace-2f44c87f0aa3"
|
17
|
+
@release.title.should == "Fi"
|
18
|
+
@release.release_type.should == "Album"
|
19
|
+
@release.date_available.should == "2005-02-08"
|
20
|
+
@release.track_count.should == "17"
|
21
|
+
@release.format.should == "CD"
|
22
|
+
@release.label.should == "Mush Records"
|
23
|
+
@release.country.should == "US"
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/spec/search_spec.rb
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe BrainzReleases::Search do
|
4
|
+
|
5
|
+
before { FakeWeb.allow_net_connect = false }
|
6
|
+
after { FakeWeb.allow_net_connect = true }
|
7
|
+
|
8
|
+
describe "initialize" do
|
9
|
+
|
10
|
+
context "when all attributes are set" do
|
11
|
+
before do
|
12
|
+
@brainz_search = BrainzReleases::Search.new do |search|
|
13
|
+
search.user_agent = "Testing/0.1"
|
14
|
+
search.start_date = Date.parse("1/1/2011")
|
15
|
+
search.end_date = Date.parse("5/5/2011")
|
16
|
+
search.name = "Bonobo"
|
17
|
+
search.mbid = "123"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should initialize the user agent" do
|
22
|
+
@brainz_search.user_agent.should == "Testing/0.1"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should initialize the start date" do
|
26
|
+
@brainz_search.start_date.should == Date.parse("1/1/2011")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should initialize the end date" do
|
30
|
+
@brainz_search.end_date.should == Date.parse("5/5/2011")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should initialize the name" do
|
34
|
+
@brainz_search.name.should == "Bonobo"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should initialize the mbid" do
|
38
|
+
@brainz_search.mbid.should == "123"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when the name and mbid are missing" do
|
43
|
+
it "should raise an exception" do
|
44
|
+
lambda {BrainzReleases::Search.new { |search| search.user_agent = "Foo"}}.should raise_exception(BrainzReleases::Search::ConfigError)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when the user agent is missing" do
|
49
|
+
it "should raise an exception" do
|
50
|
+
lambda {BrainzReleases::Search.new { |search| search.mbid = "123"}}.should raise_exception(BrainzReleases::Search::ConfigError)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when start date and end date are missing" do
|
55
|
+
before do
|
56
|
+
Date.stub(:now){Date.parse("1/1/2011")}
|
57
|
+
@brainz_search = BrainzReleases::Search.new do |search|
|
58
|
+
search.user_agent = "Testing/0.1"
|
59
|
+
search.name = "Bonobo"
|
60
|
+
search.mbid = "123"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should initialize the start date" do
|
65
|
+
@brainz_search.start_date.should_not be_nil
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should initialize the end date" do
|
69
|
+
@brainz_search.end_date.should_not be_nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "uri" do
|
76
|
+
|
77
|
+
context "when both the name and mbid are set" do
|
78
|
+
before do
|
79
|
+
@brainz_search = BrainzReleases::Search.new do |search|
|
80
|
+
search.user_agent = "Testing/0.1"
|
81
|
+
search.start_date = Date.parse("1/1/2011")
|
82
|
+
search.end_date = Date.parse("5/5/2011")
|
83
|
+
search.name = "Bonobo"
|
84
|
+
search.mbid = "123"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should use the mbid" do
|
89
|
+
@brainz_search.uri.should == URI.parse("http://musicbrainz.org/ws/2/release/?type=xml&query=arid%3A123+AND+date%3A%5B2011-01-01+TO+2011-05-05%5D")
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
# Note that you cannot compare two Nokogiri documents that have been parsed, even if you are parsing the same document
|
97
|
+
# In any case we're not testing that Nokogiri works, we're testing that Nokogiri is called with the correct options
|
98
|
+
describe "releases_xml" do
|
99
|
+
|
100
|
+
before do
|
101
|
+
@brainz_search = BrainzReleases::Search.new do |search|
|
102
|
+
search.user_agent = "Testing/0.1"
|
103
|
+
search.start_date = Date.parse("1/1/2011")
|
104
|
+
search.end_date = Date.parse("5/5/2011")
|
105
|
+
search.name = "Bonobo"
|
106
|
+
search.mbid = "123"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "when the result is ok" do
|
111
|
+
before do
|
112
|
+
FakeWeb.register_uri(:get, "http://example.com", :body => File.read("spec/fixtures/ok.xml"))
|
113
|
+
@brainz_search.stub(:uri){URI.parse("http://example.com")}
|
114
|
+
end
|
115
|
+
it "should call the artists url with Nokogiri parse to get the xml" do
|
116
|
+
Nokogiri::XML::Document.should_receive(:parse).with(Net::HTTP.get(URI.parse("http://example.com")), nil, nil, 1)
|
117
|
+
@brainz_search.releases_xml
|
118
|
+
end
|
119
|
+
it "should not raise the error message as an exception" do
|
120
|
+
lambda {@brainz_search.releases_xml}.should_not raise_exception(BrainzReleases::Search::ResponseError)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
context "when the result is failed" do
|
124
|
+
before do
|
125
|
+
FakeWeb.register_uri(:get, "http://example.com", :body => "Some problem", :status => ["403", "Forbidden"])
|
126
|
+
@brainz_search.stub(:uri){URI.parse("http://example.com")}
|
127
|
+
end
|
128
|
+
it "should raise the a ResponseError exception" do
|
129
|
+
lambda {@brainz_search.releases_xml}.should raise_exception(BrainzReleases::Search::ResponseError)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "results" do
|
135
|
+
|
136
|
+
before do
|
137
|
+
@brainz_search = BrainzReleases::Search.new do |search|
|
138
|
+
search.user_agent = "Testing/0.1"
|
139
|
+
search.start_date = Date.parse("1/1/2011")
|
140
|
+
search.end_date = Date.parse("5/5/2011")
|
141
|
+
search.name = "Bonobo"
|
142
|
+
search.mbid = "123"
|
143
|
+
end
|
144
|
+
@brainz_search.stub(:releases_xml).and_return(Nokogiri::XML(File.read("spec/fixtures/ok.xml")))
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should include the releases returned by releases_xml" do
|
148
|
+
@brainz_search.results.map(&:artist).should include("Bibio")
|
149
|
+
@brainz_search.results.map(&:title).should include("Mind Bokeh")
|
150
|
+
@brainz_search.results.first.should be_kind_of(BrainzReleases::Release)
|
151
|
+
@brainz_search.results.length.should == 20
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brainz_releases
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paul Sturgess
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-09-13 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: nokogiri
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "1.4"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "2.6"
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: fakeweb
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.3.0
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
description: Uses the MusicBrainz XML Web Service (version 2) to extract the releases for an artist and turn them into nice ruby objects.
|
50
|
+
email:
|
51
|
+
- paulsturgess@gmail.com
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .DS_Store
|
60
|
+
- .gitignore
|
61
|
+
- Gemfile
|
62
|
+
- README.rdoc
|
63
|
+
- Rakefile
|
64
|
+
- brainz_releases.gemspec
|
65
|
+
- lib/.DS_Store
|
66
|
+
- lib/brainz_releases.rb
|
67
|
+
- lib/brainz_releases/release.rb
|
68
|
+
- lib/brainz_releases/search.rb
|
69
|
+
- lib/brainz_releases/version.rb
|
70
|
+
- spec/brainz_releases_spec.rb
|
71
|
+
- spec/fixtures/ok.xml
|
72
|
+
- spec/release_spec.rb
|
73
|
+
- spec/search_spec.rb
|
74
|
+
- spec/spec_helper.rb
|
75
|
+
has_rdoc: true
|
76
|
+
homepage: https://github.com/paulsturgess/brainz_releases
|
77
|
+
licenses: []
|
78
|
+
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "0"
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project: brainz_releases
|
99
|
+
rubygems_version: 1.6.2
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: Provides a ruby inteface for extracting the releases for an artist from MusicBrainz
|
103
|
+
test_files:
|
104
|
+
- spec/brainz_releases_spec.rb
|
105
|
+
- spec/fixtures/ok.xml
|
106
|
+
- spec/release_spec.rb
|
107
|
+
- spec/search_spec.rb
|
108
|
+
- spec/spec_helper.rb
|