musicbrainz 0.7.6 → 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  ## musicbrainz (unreleased) ##
2
2
 
3
+ # 0.7.7 (Dezember 1, 2014) ##
4
+
5
+ * Handle nil values returned from Base model search at Artist#find_by_name and ReleaseGroup#find_by_artist_and_title [#24]
6
+
3
7
  # 0.7.6 (June 14, 2013) ##
4
8
 
5
9
  * Improves urls attribute to return an array if there are multiple urls for a relation type. [#19]
data/README.md CHANGED
@@ -158,4 +158,4 @@ bundle exec irb -r musicbrainz
158
158
 
159
159
  ### Copyright
160
160
 
161
- Copyright (c) 2011 Gregory Eremin. See [LICENSE](https://raw.github.com/magnolia-fan/musicbrainz/master/LICENSE) for further details.
161
+ Copyright (c) 2014 Gregory Eremin. See [LICENSE](https://raw.github.com/magnolia-fan/musicbrainz/master/LICENSE) for further details.
@@ -4,7 +4,7 @@ module MusicBrainz
4
4
  def get_contents(url)
5
5
  response = http.get(url)
6
6
  { body: response.body, status: response.status }
7
- rescue
7
+ rescue Faraday::Error::ClientError
8
8
  { body: nil, status: 500 }
9
9
  end
10
10
  end
@@ -36,7 +36,9 @@ module MusicBrainz
36
36
 
37
37
  def find_by_name(name)
38
38
  matches = search(name)
39
- matches.empty? ? nil : find(matches.first[:id])
39
+ if matches and not matches.empty?
40
+ find(matches.first[:id])
41
+ end
40
42
  end
41
43
  end
42
44
  end
@@ -35,7 +35,7 @@ module MusicBrainz
35
35
 
36
36
  def find_by_artist_and_title(artist_name, title, type = nil )
37
37
  matches = search(artist_name, title, type)
38
- matches.empty? ? nil : find(matches.first[:id])
38
+ matches.nil? || matches.empty? ? nil : find(matches.first[:id])
39
39
  end
40
40
  end
41
41
  end
@@ -1,3 +1,3 @@
1
1
  module MusicBrainz
2
- VERSION = "0.7.6"
2
+ VERSION = "0.7.7"
3
3
  end
@@ -18,4 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.add_dependency('nokogiri')
19
19
  gem.add_development_dependency('rspec')
20
20
  gem.add_development_dependency('awesome_print')
21
+ gem.add_development_dependency('rake', '~> 10.4.0')
21
22
  end
@@ -0,0 +1,344 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#">
3
+ <release-list count="8">
4
+ <release id="123eff45-b875-4aab-b659-fb6996691db6">
5
+ <title>Empire</title>
6
+ <status>Official</status>
7
+ <quality>normal</quality>
8
+ <packaging>Jewel Case</packaging>
9
+ <text-representation>
10
+ <language>eng</language>
11
+ <script>Latn</script>
12
+ </text-representation>
13
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
14
+ <title>Empire</title>
15
+ <first-release-date>2006-08-28</first-release-date>
16
+ <primary-type>Album</primary-type>
17
+ </release-group>
18
+ <date>2006</date>
19
+ <country>XE</country>
20
+ <release-event-list count="1">
21
+ <release-event>
22
+ <date>2006</date>
23
+ <area id="89a675c2-3e37-3518-b83c-418bad59a85a">
24
+ <name>Europe</name>
25
+ <sort-name>Europe</sort-name>
26
+ <iso-3166-1-code-list>
27
+ <iso-3166-1-code>XE</iso-3166-1-code>
28
+ </iso-3166-1-code-list>
29
+ </area>
30
+ </release-event>
31
+ </release-event-list>
32
+ <barcode>828768934227</barcode>
33
+ <cover-art-archive>
34
+ <artwork>false</artwork>
35
+ <count>0</count>
36
+ <front>false</front>
37
+ <back>false</back>
38
+ </cover-art-archive>
39
+ <medium-list count="1">
40
+ <medium>
41
+ <position>1</position>
42
+ <format>CD</format>
43
+ <track-list count="11" />
44
+ </medium>
45
+ </medium-list>
46
+ </release>
47
+ <release id="2225dd4c-ae9a-403b-8ea0-9e05014c778f">
48
+ <title>Empire</title>
49
+ <status>Official</status>
50
+ <quality>normal</quality>
51
+ <text-representation>
52
+ <language>eng</language>
53
+ <script>Latn</script>
54
+ </text-representation>
55
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
56
+ <title>Empire</title>
57
+ <first-release-date>2006-08-28</first-release-date>
58
+ <primary-type>Album</primary-type>
59
+ </release-group>
60
+ <date>2006-08-28</date>
61
+ <country>GB</country>
62
+ <release-event-list count="1">
63
+ <release-event>
64
+ <date>2006-08-28</date>
65
+ <area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
66
+ <name>United Kingdom</name>
67
+ <sort-name>United Kingdom</sort-name>
68
+ <iso-3166-1-code-list>
69
+ <iso-3166-1-code>GB</iso-3166-1-code>
70
+ </iso-3166-1-code-list>
71
+ </area>
72
+ </release-event>
73
+ </release-event-list>
74
+ <asin>B000H49P28</asin>
75
+ <cover-art-archive>
76
+ <artwork>false</artwork>
77
+ <count>0</count>
78
+ <front>false</front>
79
+ <back>false</back>
80
+ </cover-art-archive>
81
+ <medium-list count="1">
82
+ <medium>
83
+ <position>1</position>
84
+ <track-list count="11" />
85
+ </medium>
86
+ </medium-list>
87
+ </release>
88
+ <release id="2bc94ddc-b872-3b7f-b0a7-98a4fffbe5ba">
89
+ <title>Empire</title>
90
+ <status>Official</status>
91
+ <quality>normal</quality>
92
+ <text-representation>
93
+ <language>eng</language>
94
+ <script>Latn</script>
95
+ </text-representation>
96
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
97
+ <title>Empire</title>
98
+ <first-release-date>2006-08-28</first-release-date>
99
+ <primary-type>Album</primary-type>
100
+ </release-group>
101
+ <date>2006-09-19</date>
102
+ <country>US</country>
103
+ <release-event-list count="1">
104
+ <release-event>
105
+ <date>2006-09-19</date>
106
+ <area id="489ce91b-6658-3307-9877-795b68554c98">
107
+ <name>United States</name>
108
+ <sort-name>United States</sort-name>
109
+ <iso-3166-1-code-list>
110
+ <iso-3166-1-code>US</iso-3166-1-code>
111
+ </iso-3166-1-code-list>
112
+ </area>
113
+ </release-event>
114
+ </release-event-list>
115
+ <barcode>828768832325</barcode>
116
+ <asin>B000HEVYQS</asin>
117
+ <cover-art-archive>
118
+ <artwork>false</artwork>
119
+ <count>0</count>
120
+ <front>false</front>
121
+ <back>false</back>
122
+ </cover-art-archive>
123
+ <medium-list count="1">
124
+ <medium>
125
+ <position>1</position>
126
+ <format>CD</format>
127
+ <track-list count="11" />
128
+ </medium>
129
+ </medium-list>
130
+ </release>
131
+ <release id="2c8dcfc6-4afe-4b33-abc7-dff1bb4c5386">
132
+ <title>Empire</title>
133
+ <status>Official</status>
134
+ <quality>normal</quality>
135
+ <text-representation>
136
+ <language>eng</language>
137
+ <script>Latn</script>
138
+ </text-representation>
139
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
140
+ <title>Empire</title>
141
+ <first-release-date>2006-08-28</first-release-date>
142
+ <primary-type>Album</primary-type>
143
+ </release-group>
144
+ <date>2006-09-22</date>
145
+ <country>XW</country>
146
+ <release-event-list count="1">
147
+ <release-event>
148
+ <date>2006-09-22</date>
149
+ <area id="525d4e18-3d00-31b9-a58b-a146a916de8f">
150
+ <name>[Worldwide]</name>
151
+ <sort-name>[Worldwide]</sort-name>
152
+ <iso-3166-1-code-list>
153
+ <iso-3166-1-code>XW</iso-3166-1-code>
154
+ </iso-3166-1-code-list>
155
+ </area>
156
+ </release-event>
157
+ </release-event-list>
158
+ <cover-art-archive>
159
+ <artwork>false</artwork>
160
+ <count>0</count>
161
+ <front>false</front>
162
+ <back>false</back>
163
+ </cover-art-archive>
164
+ <medium-list count="1">
165
+ <medium>
166
+ <position>1</position>
167
+ <format>Digital Media</format>
168
+ <track-list count="12" />
169
+ </medium>
170
+ </medium-list>
171
+ </release>
172
+ <release id="30d5e730-ce0a-464d-93e1-7d76e4bb3e31">
173
+ <title>Empire</title>
174
+ <status>Official</status>
175
+ <quality>normal</quality>
176
+ <text-representation>
177
+ <language>eng</language>
178
+ <script>Latn</script>
179
+ </text-representation>
180
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
181
+ <title>Empire</title>
182
+ <first-release-date>2006-08-28</first-release-date>
183
+ <primary-type>Album</primary-type>
184
+ </release-group>
185
+ <date>2006-08-28</date>
186
+ <country>GB</country>
187
+ <release-event-list count="1">
188
+ <release-event>
189
+ <date>2006-08-28</date>
190
+ <area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
191
+ <name>United Kingdom</name>
192
+ <sort-name>United Kingdom</sort-name>
193
+ <iso-3166-1-code-list>
194
+ <iso-3166-1-code>GB</iso-3166-1-code>
195
+ </iso-3166-1-code-list>
196
+ </area>
197
+ </release-event>
198
+ </release-event-list>
199
+ <barcode>828768849927</barcode>
200
+ <asin>B000H49P28</asin>
201
+ <cover-art-archive>
202
+ <artwork>false</artwork>
203
+ <count>0</count>
204
+ <front>false</front>
205
+ <back>false</back>
206
+ </cover-art-archive>
207
+ <medium-list count="1">
208
+ <medium>
209
+ <position>1</position>
210
+ <format>CD</format>
211
+ <track-list count="11" />
212
+ </medium>
213
+ </medium-list>
214
+ </release>
215
+ <release id="36ee86ab-0450-4d8f-a970-183c11f210c1">
216
+ <title>Empire</title>
217
+ <status>Official</status>
218
+ <quality>normal</quality>
219
+ <packaging>Jewel Case</packaging>
220
+ <text-representation>
221
+ <language>eng</language>
222
+ <script>Latn</script>
223
+ </text-representation>
224
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
225
+ <title>Empire</title>
226
+ <first-release-date>2006-08-28</first-release-date>
227
+ <primary-type>Album</primary-type>
228
+ </release-group>
229
+ <date>2006</date>
230
+ <country>GB</country>
231
+ <release-event-list count="1">
232
+ <release-event>
233
+ <date>2006</date>
234
+ <area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
235
+ <name>United Kingdom</name>
236
+ <sort-name>United Kingdom</sort-name>
237
+ <iso-3166-1-code-list>
238
+ <iso-3166-1-code>GB</iso-3166-1-code>
239
+ </iso-3166-1-code-list>
240
+ </area>
241
+ </release-event>
242
+ </release-event-list>
243
+ <barcode>828768934227</barcode>
244
+ <cover-art-archive>
245
+ <artwork>false</artwork>
246
+ <count>0</count>
247
+ <front>false</front>
248
+ <back>false</back>
249
+ </cover-art-archive>
250
+ <medium-list count="1">
251
+ <medium>
252
+ <position>1</position>
253
+ <format>CD</format>
254
+ <track-list count="11" />
255
+ </medium>
256
+ </medium-list>
257
+ </release>
258
+ <release id="9f068ed6-9f69-4a60-bf5a-0931176a9aba">
259
+ <title>Empire</title>
260
+ <status>Official</status>
261
+ <quality>normal</quality>
262
+ <text-representation>
263
+ <language>eng</language>
264
+ <script>Latn</script>
265
+ </text-representation>
266
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
267
+ <title>Empire</title>
268
+ <first-release-date>2006-08-28</first-release-date>
269
+ <primary-type>Album</primary-type>
270
+ </release-group>
271
+ <date>2006-12-20</date>
272
+ <country>JP</country>
273
+ <release-event-list count="1">
274
+ <release-event>
275
+ <date>2006-12-20</date>
276
+ <area id="2db42837-c832-3c27-b4a3-08198f75693c">
277
+ <name>Japan</name>
278
+ <sort-name>Japan</sort-name>
279
+ <iso-3166-1-code-list>
280
+ <iso-3166-1-code>JP</iso-3166-1-code>
281
+ </iso-3166-1-code-list>
282
+ </area>
283
+ </release-event>
284
+ </release-event-list>
285
+ <barcode>4988017645901</barcode>
286
+ <asin>B000K2QL9W</asin>
287
+ <cover-art-archive>
288
+ <artwork>false</artwork>
289
+ <count>0</count>
290
+ <front>false</front>
291
+ <back>false</back>
292
+ </cover-art-archive>
293
+ <medium-list count="1">
294
+ <medium>
295
+ <position>1</position>
296
+ <format>CD</format>
297
+ <track-list count="16" />
298
+ </medium>
299
+ </medium-list>
300
+ </release>
301
+ <release id="dd34af03-37ab-460a-b20a-54629336d81a">
302
+ <title>Empire</title>
303
+ <status>Official</status>
304
+ <quality>normal</quality>
305
+ <packaging>Jewel Case</packaging>
306
+ <text-representation>
307
+ <language>eng</language>
308
+ <script>Latn</script>
309
+ </text-representation>
310
+ <release-group type="Album" id="6f33e0f0-cde2-38f9-9aee-2c60af8d1a61">
311
+ <title>Empire</title>
312
+ <first-release-date>2006-08-28</first-release-date>
313
+ <primary-type>Album</primary-type>
314
+ </release-group>
315
+ <date>2006-12-18</date>
316
+ <country>GB</country>
317
+ <release-event-list count="1">
318
+ <release-event>
319
+ <date>2006-12-18</date>
320
+ <area id="8a754a16-0027-3a29-b6d7-2b40ea0481ed">
321
+ <name>United Kingdom</name>
322
+ <sort-name>United Kingdom</sort-name>
323
+ <iso-3166-1-code-list>
324
+ <iso-3166-1-code>GB</iso-3166-1-code>
325
+ </iso-3166-1-code-list>
326
+ </area>
327
+ </release-event>
328
+ </release-event-list>
329
+ <cover-art-archive>
330
+ <artwork>true</artwork>
331
+ <count>1</count>
332
+ <front>true</front>
333
+ <back>false</back>
334
+ </cover-art-archive>
335
+ <medium-list count="1">
336
+ <medium>
337
+ <position>1</position>
338
+ <format>Digital Media</format>
339
+ <track-list count="16" />
340
+ </medium>
341
+ </medium-list>
342
+ </release>
343
+ </release-list>
344
+ </metadata>
@@ -66,9 +66,15 @@ describe MusicBrainz::ReleaseGroup do
66
66
 
67
67
  describe '#releases' do
68
68
  it "gets correct release group's releases" do
69
+ MusicBrainz::Client.any_instance.stub(:get_contents).with('http://musicbrainz.org/ws/2/release-group/6f33e0f0-cde2-38f9-9aee-2c60af8d1a61?inc=url-rels').
70
+ and_return({ status: 200, body: File.open(File.join(File.dirname(__FILE__), "../fixtures/release_group/entity.xml")).read})
71
+
72
+ MusicBrainz::Client.any_instance.stub(:get_contents).with('http://musicbrainz.org/ws/2/release?release-group=6f33e0f0-cde2-38f9-9aee-2c60af8d1a61&inc=media+release-groups&limit=100').
73
+ and_return({ status: 200, body: File.open(File.join(File.dirname(__FILE__), "../fixtures/release/list.xml")).read})
74
+
69
75
  releases = MusicBrainz::ReleaseGroup.find("6f33e0f0-cde2-38f9-9aee-2c60af8d1a61").releases
70
76
  releases.length.should be >= 5
71
- releases.first.id.should == "2225dd4c-ae9a-403b-8ea0-9e05014c778f"
77
+ releases.first.id.should == "30d5e730-ce0a-464d-93e1-7d76e4bb3e31"
72
78
  releases.first.status.should == "Official"
73
79
  releases.first.title.should == "Empire"
74
80
  releases.first.date.should == Date.new(2006, 8, 28)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: musicbrainz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-14 00:00:00.000000000 Z
12
+ date: 2014-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 10.4.0
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 10.4.0
78
94
  description:
79
95
  email:
80
96
  - magnolia_fan@me.com
@@ -127,6 +143,7 @@ files:
127
143
  - spec/deprecated/proxy_config_spec.rb
128
144
  - spec/fixtures/artist/search.xml
129
145
  - spec/fixtures/kasabian.xml
146
+ - spec/fixtures/release/list.xml
130
147
  - spec/fixtures/release_group/entity.xml
131
148
  - spec/fixtures/release_group/search.xml
132
149
  - spec/models/artist_spec.rb
@@ -150,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
167
  version: '0'
151
168
  segments:
152
169
  - 0
153
- hash: 85383648681558491
170
+ hash: -3495484927768384955
154
171
  required_rubygems_version: !ruby/object:Gem::Requirement
155
172
  none: false
156
173
  requirements:
@@ -159,10 +176,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
176
  version: '0'
160
177
  segments:
161
178
  - 0
162
- hash: 85383648681558491
179
+ hash: -3495484927768384955
163
180
  requirements: []
164
181
  rubyforge_project:
165
- rubygems_version: 1.8.24
182
+ rubygems_version: 1.8.23
166
183
  signing_key:
167
184
  specification_version: 3
168
185
  summary: MusicBrainz Web Service wrapper with ActiveRecord-style models
@@ -176,6 +193,7 @@ test_files:
176
193
  - spec/deprecated/proxy_config_spec.rb
177
194
  - spec/fixtures/artist/search.xml
178
195
  - spec/fixtures/kasabian.xml
196
+ - spec/fixtures/release/list.xml
179
197
  - spec/fixtures/release_group/entity.xml
180
198
  - spec/fixtures/release_group/search.xml
181
199
  - spec/models/artist_spec.rb