rbrainz 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/CHANGES +31 -0
  2. data/LICENSE +1 -1
  3. data/README +3 -2
  4. data/Rakefile +40 -22
  5. data/TODO +6 -23
  6. data/doc/README.rdoc +50 -21
  7. data/examples/getartist.rb +6 -4
  8. data/examples/getuser.rb +30 -0
  9. data/examples/searchartists.rb +35 -0
  10. data/lib/rbrainz.rb +12 -7
  11. data/lib/rbrainz/core_ext.rb +8 -0
  12. data/lib/rbrainz/core_ext/mbid.rb +30 -0
  13. data/lib/rbrainz/core_ext/net_http_digest.rb +52 -0
  14. data/lib/rbrainz/core_ext/range.rb +28 -0
  15. data/lib/rbrainz/core_ext/range/equality.rb +232 -0
  16. data/lib/rbrainz/data/countrynames.rb +7 -5
  17. data/lib/rbrainz/data/languagenames.rb +8 -5
  18. data/lib/rbrainz/data/releasetypenames.rb +34 -0
  19. data/lib/rbrainz/data/scriptnames.rb +8 -5
  20. data/lib/rbrainz/model.rb +27 -35
  21. data/lib/rbrainz/model/alias.rb +31 -7
  22. data/lib/rbrainz/model/artist.rb +30 -41
  23. data/lib/rbrainz/model/collection.rb +102 -0
  24. data/lib/rbrainz/model/default_factory.rb +78 -0
  25. data/lib/rbrainz/model/disc.rb +45 -8
  26. data/lib/rbrainz/model/entity.rb +122 -53
  27. data/lib/rbrainz/model/incomplete_date.rb +31 -47
  28. data/lib/rbrainz/model/individual.rb +103 -0
  29. data/lib/rbrainz/model/label.rb +42 -33
  30. data/lib/rbrainz/model/mbid.rb +111 -40
  31. data/lib/rbrainz/model/relation.rb +78 -14
  32. data/lib/rbrainz/model/release.rb +119 -31
  33. data/lib/rbrainz/model/release_event.rb +38 -9
  34. data/lib/rbrainz/model/scored_collection.rb +99 -0
  35. data/lib/rbrainz/model/tag.rb +39 -0
  36. data/lib/rbrainz/model/track.rb +37 -13
  37. data/lib/rbrainz/model/user.rb +48 -0
  38. data/lib/rbrainz/utils.rb +9 -0
  39. data/lib/rbrainz/utils/data.rb +78 -0
  40. data/lib/rbrainz/utils/helper.rb +22 -0
  41. data/lib/rbrainz/version.rb +15 -0
  42. data/lib/rbrainz/webservice.rb +32 -6
  43. data/lib/rbrainz/webservice/filter.rb +124 -47
  44. data/lib/rbrainz/webservice/includes.rb +49 -10
  45. data/lib/rbrainz/webservice/mbxml.rb +228 -173
  46. data/lib/rbrainz/webservice/query.rb +312 -25
  47. data/lib/rbrainz/webservice/webservice.rb +164 -27
  48. data/test/lib/mock_webservice.rb +53 -0
  49. data/test/lib/test_entity.rb +27 -8
  50. data/test/lib/test_factory.rb +47 -0
  51. data/test/lib/testing_helper.rb +7 -5
  52. data/test/test-data/invalid/artist/tags_1.xml +6 -0
  53. data/test/test-data/valid/artist/Tchaikovsky-2.xml +12 -0
  54. data/test/test-data/valid/label/Atlantic_Records_2.xml +3 -0
  55. data/test/test-data/valid/label/Atlantic_Records_3.xml +11 -0
  56. data/test/test-data/valid/release/Highway_61_Revisited_2.xml +12 -0
  57. data/test/test-data/valid/track/Silent_All_These_Years_6.xml +8 -0
  58. data/test/test_alias.rb +13 -7
  59. data/test/test_artist.rb +26 -4
  60. data/test/test_artist_filter.rb +11 -6
  61. data/test/test_artist_includes.rb +11 -6
  62. data/test/test_collection.rb +66 -0
  63. data/test/test_default_factory.rb +75 -0
  64. data/test/test_disc.rb +9 -4
  65. data/test/test_incomplete_date.rb +21 -14
  66. data/test/test_label.rb +56 -18
  67. data/test/test_label_filter.rb +10 -5
  68. data/test/test_label_includes.rb +11 -6
  69. data/test/test_mbid.rb +34 -19
  70. data/test/test_mbxml.rb +242 -72
  71. data/test/test_query.rb +92 -7
  72. data/test/test_range_equality.rb +144 -0
  73. data/test/test_relation.rb +18 -7
  74. data/test/test_release.rb +15 -4
  75. data/test/test_release_event.rb +16 -4
  76. data/test/test_release_filter.rb +11 -5
  77. data/test/test_release_includes.rb +11 -6
  78. data/test/test_scored_collection.rb +86 -0
  79. data/test/test_tag.rb +39 -0
  80. data/test/test_track.rb +15 -4
  81. data/test/test_track_filter.rb +11 -5
  82. data/test/test_track_includes.rb +11 -6
  83. data/test/test_utils.rb +41 -0
  84. data/test/test_webservice.rb +16 -17
  85. metadata +93 -57
@@ -1,9 +1,24 @@
1
- # $Id: webservice.rb 36 2007-05-29 18:43:36Z phw $
2
- # Copyright (c) 2007, Philipp Wolfer
3
- # All rights reserved.
4
- # See LICENSE for permissions.
1
+ # $Id: webservice.rb 146 2007-07-19 16:33:38Z phw $
2
+ #
3
+ # Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
4
+ # Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
5
+ # License:: RBrainz is free software distributed under a BSD style license.
6
+ # See LICENSE[file:../LICENSE.html] for permissions.
5
7
 
6
- module MusicBrainz
8
+ module MusicBrainz # :nodoc:
9
+
10
+ # Classes for interacting with the MusicBrainz XML web service.
11
+ #
12
+ # The WebService class talks to a server implementing the MusicBrainz XML
13
+ # web service. It mainly handles URL generation and network I/O. Use this
14
+ # if maximum control is needed.
15
+ #
16
+ # The Query class provides a convenient interface to the most commonly used
17
+ # features of the web service. By default it uses Webservice to retrieve data
18
+ # and the MBXML parser to parse the responses. The results are object trees
19
+ # using the MusicBrainz domain model.
20
+ #
21
+ # See:: Model
7
22
  module Webservice
8
23
 
9
24
  # Connecting to the web service failed.
@@ -14,7 +29,10 @@ module MusicBrainz
14
29
  class ConnectionError < Exception
15
30
  end
16
31
 
17
- # An invalid request was made (invalid IDs or parameters).
32
+ # An invalid request was made.
33
+ #
34
+ # This exception is raised if the client made an invalid request. That could
35
+ # be syntactically invalid identifiers or unknown or invalid parameter values.
18
36
  class RequestError < Exception
19
37
  end
20
38
 
@@ -29,6 +47,14 @@ module MusicBrainz
29
47
  # The requested resource doesn't exist.
30
48
  class ResourceNotFoundError < Exception
31
49
  end
50
+
51
+ # The returned resource was invalid.
52
+ #
53
+ # This may be due to a malformed XML document or if the requested data
54
+ # wasn't part of the response. It can only occur in case of bugs in the web
55
+ # service itself.
56
+ class ResponseError < Exception
57
+ end
32
58
 
33
59
  end
34
60
  end
@@ -1,7 +1,9 @@
1
- # $Id: filter.rb 4 2007-05-21 02:04:26Z phw $
2
- # Copyright (c) 2007, Philipp Wolfer
3
- # All rights reserved.
4
- # See LICENSE for permissions.
1
+ # $Id: filter.rb 148 2007-07-19 17:26:33Z phw $
2
+ #
3
+ # Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
4
+ # Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
5
+ # License:: RBrainz is free software distributed under a BSD style license.
6
+ # See LICENSE[file:../LICENSE.html] for permissions.
5
7
 
6
8
  require 'uri'
7
9
 
@@ -9,17 +11,33 @@ module MusicBrainz
9
11
  module Webservice
10
12
 
11
13
  # Base class for all filter classes.
14
+ #
15
+ # Filter classes are initialized with a set of criteria and are then
16
+ # applied to collections of items. The criteria are usually strings
17
+ # or integer values, depending on the filter.
12
18
  class AbstractFilter
13
19
 
14
- # The parameter +filter+ is a hash with filter options.
15
- # The the concrete classes for a description of those
20
+ # The parameter _filter_ is a hash with filter options.
21
+ # See the concrete classes for a description of those
16
22
  # options.
23
+ #
24
+ # The following options are available for all filters:
25
+ # [:limit] The maximum number of entries returned. Defaults
26
+ # to 25, the maximum allowed value is 100.
27
+ # [:offset] Return search results starting at a given offset. Used
28
+ # for paging through more than one page of results.
29
+ # [:query] A Lucene search query. The query parameter is a search
30
+ # string which will be passed to the underlying Lucene search
31
+ # engine. It must follow the syntax described in
32
+ # http://musicbrainz.org/doc/TextSearchSyntax.
17
33
  def initialize(filter)
18
- raise 'Tried to initialize abstract class.'
34
+ @filter = Hash.new
35
+ @filter[:limit] = filter[:limit] if filter[:limit]
36
+ @filter[:offset] = filter[:offset] if filter[:offset]
37
+ @filter[:query] = filter[:query] if filter[:query]
19
38
  end
20
39
 
21
- # Returns the filter list as a query string
22
- # (without leading +&+).
40
+ # Returns the filter list as a query string (without leading <em>&</em>).
23
41
  def to_s
24
42
  @filter.to_a.map {|name, value|
25
43
  '%s=%s' % [URI.escape(name.to_s), URI.escape(value.to_s)]
@@ -28,23 +46,37 @@ module MusicBrainz
28
46
 
29
47
  end
30
48
 
49
+ # A filter for the artist collection.
31
50
  class ArtistFilter < AbstractFilter
32
51
 
33
- # The parameter +filter+ is a hash with filter options:
34
- # [:name] Fetch a list of artists with a matching name.
35
- # [:limit] The maximum number of artists returned. Defaults
36
- # to 25, the maximum allowed value is 100.
52
+ # The parameter _filter_ is a hash with filter options. At least the
53
+ # <tt>:name</tt> filter must be specified.
54
+ #
55
+ # Available filter options:
56
+ # [:name] Fetch a list of artists with a matching name.
57
+ # [:limit] The maximum number of artists returned. Defaults
58
+ # to 25, the maximum allowed value is 100.
59
+ # [:offset] Return search results starting at a given offset. Used
60
+ # for paging through more than one page of results.
61
+ # [:query] A Lucene search query. The query parameter is a search
62
+ # string which will be passed to the underlying Lucene search
63
+ # engine. It must follow the syntax described in
64
+ # http://musicbrainz.org/doc/TextSearchSyntax.
37
65
  def initialize(filter)
38
- @filter = Hash.new
39
- @filter[:name] = filter[:name] if filter[:name]
40
- @filter[:limit] = filter[:limit] if filter[:limit]
66
+ Utils.check_options filter, :name, :limit, :offset, :query
67
+ super(filter)
68
+ @filter[:name] = filter[:name] if filter[:name]
41
69
  end
42
70
 
43
71
  end
44
72
 
73
+ # A filter for the release collection.
45
74
  class ReleaseFilter < AbstractFilter
46
75
 
47
- # The parameter +filter+ is a hash with filter options:
76
+ # The parameter _filter_ is a hash with filter options. At least one
77
+ # filter despite <tt>:limit</tt> and <tt>:offset</tt> must be specified.
78
+ #
79
+ # Available filter options:
48
80
  # [:title] Fetch a list of releases with a matching title.
49
81
  # [:discid] Fetch all releases matching to the given DiscID.
50
82
  # [:artist] The returned releases should match the given artist name.
@@ -61,26 +93,38 @@ module MusicBrainz
61
93
  # [:script] The script used in this release.
62
94
  # [:limit] The maximum number of tracks returned. Defaults
63
95
  # to 25, the maximum allowed value is 100.
96
+ # [:offset] Return search results starting at a given offset. Used
97
+ # for paging through more than one page of results.
98
+ # [:query] A Lucene search query. The query parameter is a search
99
+ # string which will be passed to the underlying Lucene search
100
+ # engine. It must follow the syntax described in
101
+ # http://musicbrainz.org/doc/TextSearchSyntax.
64
102
  def initialize(filter)
65
- @filter = Hash.new
66
- @filter[:title] = filter[:title] if filter[:title]
67
- @filter[:discid] = filter[:discid] if filter[:discid]
68
- @filter[:artist] = filter[:artist] if filter[:artist]
69
- @filter[:artistid] = filter[:artistid] if filter[:artistid]
103
+ Utils.check_options filter,
104
+ :limit, :offset, :query, :title, :discid, :artist, :artistid,
105
+ :releasetypes, :count, :date, :asin, :lang, :script
106
+ super(filter)
107
+ @filter[:title] = filter[:title] if filter[:title]
108
+ @filter[:discid] = filter[:discid] if filter[:discid]
109
+ @filter[:artist] = filter[:artist] if filter[:artist]
110
+ @filter[:artistid] = filter[:artistid] if filter[:artistid]
70
111
  @filter[:releasetypes] = filter[:releasetypes] if filter[:releasetypes]
71
- @filter[:count] = filter[:count] if filter[:count]
72
- @filter[:date] = filter[:date] if filter[:date]
73
- @filter[:asin] = filter[:asin] if filter[:asin]
74
- @filter[:lang] = filter[:lang] if filter[:lang]
75
- @filter[:script] = filter[:script] if filter[:script]
76
- @filter[:limit] = filter[:limit] if filter[:limit]
112
+ @filter[:count] = filter[:count] if filter[:count]
113
+ @filter[:date] = filter[:date] if filter[:date]
114
+ @filter[:asin] = filter[:asin] if filter[:asin]
115
+ @filter[:lang] = filter[:lang] if filter[:lang]
116
+ @filter[:script] = filter[:script] if filter[:script]
77
117
  end
78
118
 
79
119
  end
80
120
 
121
+ # A filter for the track collection.
81
122
  class TrackFilter < AbstractFilter
82
123
 
83
- # The parameter +filter+ is a hash with filter options:
124
+ # The parameter _filter_ is a hash with filter options. At least the
125
+ # <tt>:title</tt> filter must be specified.
126
+ #
127
+ # Available filter options:
84
128
  # [:title] Fetch a list of tracks with a matching title.
85
129
  # [:artist] The returned tracks have to match the given
86
130
  # artist name.
@@ -97,36 +141,69 @@ module MusicBrainz
97
141
  # [:releasetype] The type of the release this track appears on
98
142
  # [:limit] The maximum number of tracks returned. Defaults
99
143
  # to 25, the maximum allowed value is 100.
144
+ # [:offset] Return search results starting at a given offset. Used
145
+ # for paging through more than one page of results.
146
+ # [:query] A Lucene search query. The query parameter is a search
147
+ # string which will be passed to the underlying Lucene search
148
+ # engine. It must follow the syntax described in
149
+ # http://musicbrainz.org/doc/TextSearchSyntax.
100
150
  def initialize(filter)
101
- @filter = Hash.new
102
- @filter[:title] = filter[:title] if filter[:title]
103
- @filter[:artist] = filter[:artist] if filter[:artist]
104
- @filter[:release] = filter[:release] if filter[:release]
105
- @filter[:duration] = filter[:duration] if filter[:duration]
106
- @filter[:tracknum] = filter[:tracknum] if filter[:tracknum]
107
- @filter[:artistid] = filter[:artistid] if filter[:artistid]
108
- @filter[:releaseid] = filter[:releaseid] if filter[:releaseid]
109
- @filter[:puid] = filter[:puid] if filter[:puid]
110
- @filter[:count] = filter[:count] if filter[:count]
151
+ Utils.check_options filter,
152
+ :limit, :offset, :query, :title, :artist, :release, :duration,
153
+ :tracknum, :artistid, :releaseid, :puid, :count, :releasetype
154
+ super(filter)
155
+ @filter[:title] = filter[:title] if filter[:title]
156
+ @filter[:artist] = filter[:artist] if filter[:artist]
157
+ @filter[:release] = filter[:release] if filter[:release]
158
+ @filter[:duration] = filter[:duration] if filter[:duration]
159
+ @filter[:tracknum] = filter[:tracknum] if filter[:tracknum]
160
+ @filter[:artistid] = filter[:artistid] if filter[:artistid]
161
+ @filter[:releaseid] = filter[:releaseid] if filter[:releaseid]
162
+ @filter[:puid] = filter[:puid] if filter[:puid]
163
+ @filter[:count] = filter[:count] if filter[:count]
111
164
  @filter[:releasetype] = filter[:releasetype] if filter[:releasetype]
112
- @filter[:limit] = filter[:limit] if filter[:limit]
113
165
  end
114
166
 
115
167
  end
116
168
 
169
+ # A filter for the label collection.
117
170
  class LabelFilter < AbstractFilter
118
171
 
119
- # The parameter +filter+ is a hash with filter options:
120
- # [:name] Fetch a list of labels with a matching name.
121
- # [:limit] The maximum number of labels returned. Defaults
122
- # to 25, the maximum allowed value is 100.
172
+ # The parameter _filter_ is a hash with filter options. At least the
173
+ # <tt>:name</tt> filter must be specified.
174
+ #
175
+ # Available filter options:
176
+ # [:name] Fetch a list of labels with a matching name.
177
+ # [:limit] The maximum number of labels returned. Defaults
178
+ # to 25, the maximum allowed value is 100.
179
+ # [:offset] Return search results starting at a given offset. Used
180
+ # for paging through more than one page of results.
181
+ # [:query] A Lucene search query. The query parameter is a search
182
+ # string which will be passed to the underlying Lucene search
183
+ # engine. It must follow the syntax described in
184
+ # http://musicbrainz.org/doc/TextSearchSyntax.
123
185
  def initialize(filter)
124
- @filter = Hash.new
125
- @filter[:name] = filter[:name] if filter[:name]
126
- @filter[:limit] = filter[:limit] if filter[:limit]
186
+ Utils.check_options filter, :limit, :offset, :query, :name
187
+ super(filter)
188
+ @filter[:name] = filter[:name] if filter[:name]
127
189
  end
128
190
 
129
191
  end
130
192
 
193
+ # A filter to query a user by his username.
194
+ class UserFilter
195
+ def initialize(name=nil)
196
+ @filter = Hash.new
197
+ @filter[:name] = name if name
198
+ end
199
+
200
+ # Returns the filter list as a query string (without leading <em>&</em>).
201
+ def to_s
202
+ @filter.to_a.map {|name, value|
203
+ '%s=%s' % [URI.escape(name.to_s), URI.escape(value.to_s)]
204
+ }.join('&')
205
+ end
206
+ end
207
+
131
208
  end
132
209
  end
@@ -1,7 +1,9 @@
1
- # $Id: includes.rb 4 2007-05-21 02:04:26Z phw $
2
- # Copyright (c) 2007, Philipp Wolfer
3
- # All rights reserved.
4
- # See LICENSE for permissions.
1
+ # $Id: includes.rb 148 2007-07-19 17:26:33Z phw $
2
+ #
3
+ # Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
4
+ # Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
5
+ # License:: RBrainz is free software distributed under a BSD style license.
6
+ # See LICENSE[file:../LICENSE.html] for permissions.
5
7
 
6
8
  require 'uri'
7
9
 
@@ -9,12 +11,17 @@ module MusicBrainz
9
11
  module Webservice
10
12
 
11
13
  # Base class for all include classes.
14
+ #
15
+ # Includes are used to specify which detail information should be returned
16
+ # for an entity search. There is one include class for each entity type.
12
17
  class AbstractIncludes
13
18
 
14
19
  def initialize(includes)
15
20
  raise 'Tried to initialize abstract class.'
16
21
  end
17
22
 
23
+ # Returns the includes as a parameter that can be used in a MusicBrainz
24
+ # XML web service URI.
18
25
  def to_s
19
26
  if @parameters.size > 0
20
27
  return 'inc=' + URI.escape(@parameters.join(' '))
@@ -22,9 +29,15 @@ module MusicBrainz
22
29
  return ''
23
30
  end
24
31
  end
25
-
32
+
26
33
  end
27
34
 
35
+ # A specification on how much data to return with an artist.
36
+ #
37
+ # The MusicBrainz server only supports some combinations of release types
38
+ # for the releases and vaReleases include tags. At the moment, not more
39
+ # than two release types should be selected, while one of them has to be
40
+ # Release.TYPE_OFFICIAL, Release.TYPE_PROMOTION or Release.TYPE_BOOTLEG.
28
41
  class ArtistIncludes < AbstractIncludes
29
42
 
30
43
  # Includes is a hash with the following fields:
@@ -32,20 +45,26 @@ module MusicBrainz
32
45
  # [:releases] Array of release types that should be included
33
46
  # in the result. All releases of the artist that match
34
47
  # all of those types will be included. Use the constants
35
- # defined in Model::Releases for the release types.
48
+ # defined in Model::Release for the release types.
36
49
  # [:va_releases] Array of release types. All various artist releases
37
50
  # the artist appears on and that match all of those
38
51
  # types will be included. Use the constants
39
- # defined in Model::Releases for the release types.
52
+ # defined in Model::Release for the release types.
40
53
  # [:artist_rels] Include artist relationships (boolean).
41
54
  # [:release_rels] Include release relationships (boolean).
42
55
  # [:track_rels] Include track relationships (boolean).
43
56
  # [:label_rels] Include label relationships (boolean).
44
57
  # [:url_rels] Include url relationships (boolean).
58
+ # [:tags] Include tags (boolean).
45
59
  #
46
- # TODO: Check release types. It's possible that :releases
47
- # and :va_releases can't be used in parallel.
60
+ #--
61
+ # TODO:: Check release types. It's possible that :releases
62
+ # and :va_releases can't be used in parallel.
63
+ #++
48
64
  def initialize(includes)
65
+ Utils.check_options includes,
66
+ :aliases, :artist_rels, :release_rels, :track_rels,
67
+ :label_rels, :url_rels, :tags, :releases, :va_releases
49
68
  @parameters = Array.new
50
69
  @parameters << 'aliases' if includes[:aliases]
51
70
  @parameters << 'artist-rels' if includes[:artist_rels]
@@ -53,6 +72,7 @@ module MusicBrainz
53
72
  @parameters << 'track-rels' if includes[:track_rels]
54
73
  @parameters << 'label-rels' if includes[:label_rels]
55
74
  @parameters << 'url-rels' if includes[:url_rels]
75
+ @parameters << 'tags' if includes[:tags]
56
76
 
57
77
  includes[:releases].each {|release_type|
58
78
  @parameters << 'sa-' + release_type.to_s
@@ -65,6 +85,7 @@ module MusicBrainz
65
85
 
66
86
  end
67
87
 
88
+ # A specification on how much data to return with a release.
68
89
  class ReleaseIncludes < AbstractIncludes
69
90
 
70
91
  # Includes is a hash with the following fields:
@@ -74,7 +95,7 @@ module MusicBrainz
74
95
  # [:discs] Include the disc IDs (boolean).
75
96
  # [:tracks] Include the release tracks (boolean).
76
97
  # [:labels] Include the labels under which the release
77
- # was publlished (boolean).
98
+ # was published (boolean).
78
99
  # [:artist_rels] Include artist relationships (boolean).
79
100
  # [:release_rels] Include release relationships (boolean).
80
101
  # [:track_rels] Include track relationships (boolean).
@@ -82,7 +103,12 @@ module MusicBrainz
82
103
  # [:url_rels] Include url relationships (boolean).
83
104
  # [:track_level_rels] Include the relationships for the
84
105
  # single tracks as well (boolean).
106
+ # [:tags] Include tags (boolean).
85
107
  def initialize(includes)
108
+ Utils.check_options includes,
109
+ :artist, :counts, :release_events, :discs, :tracks,
110
+ :labels, :artist_rels, :release_rels, :track_rels,
111
+ :label_rels, :url_rels, :track_level_rels, :tags
86
112
  @parameters = Array.new
87
113
  @parameters << 'artist' if includes[:artist]
88
114
  @parameters << 'counts' if includes[:counts]
@@ -96,10 +122,12 @@ module MusicBrainz
96
122
  @parameters << 'label-rels' if includes[:label_rels]
97
123
  @parameters << 'url-rels' if includes[:url_rels]
98
124
  @parameters << 'track-level-rels' if includes[:track_level_rels]
125
+ @parameters << 'tags' if includes[:tags]
99
126
  end
100
127
 
101
128
  end
102
129
 
130
+ # A specification on how much data to return with a track.
103
131
  class TrackIncludes < AbstractIncludes
104
132
 
105
133
  # Includes is a hash with the following fields:
@@ -111,7 +139,11 @@ module MusicBrainz
111
139
  # [:track_rels] Include track relationships (boolean).
112
140
  # [:label_rels] Include label relationships (boolean).
113
141
  # [:url_rels] Include url relationships (boolean).
142
+ # [:tags] Include tags (boolean).
114
143
  def initialize(includes)
144
+ Utils.check_options includes,
145
+ :artist, :releases, :puids, :artist_rels, :release_rels,
146
+ :track_rels, :label_rels, :url_rels, :tags
115
147
  @parameters = Array.new
116
148
  @parameters << 'artist' if includes[:artist]
117
149
  @parameters << 'releases' if includes[:releases]
@@ -121,10 +153,12 @@ module MusicBrainz
121
153
  @parameters << 'track-rels' if includes[:track_rels]
122
154
  @parameters << 'label-rels' if includes[:label_rels]
123
155
  @parameters << 'url-rels' if includes[:url_rels]
156
+ @parameters << 'tags' if includes[:tags]
124
157
  end
125
158
 
126
159
  end
127
160
 
161
+ # A specification on how much data to return with a label.
128
162
  class LabelIncludes < AbstractIncludes
129
163
 
130
164
  # Includes is a hash with the following fields:
@@ -134,7 +168,11 @@ module MusicBrainz
134
168
  # [:track_rels] Include track relationships (boolean).
135
169
  # [:label_rels] Include label relationships (boolean).
136
170
  # [:url_rels] Include url relationships (boolean).
171
+ # [:tags] Include tags (boolean).
137
172
  def initialize(includes)
173
+ Utils.check_options includes,
174
+ :aliases, :artist_rels, :release_rels,
175
+ :track_rels, :label_rels, :url_rels, :tags
138
176
  @parameters = Array.new
139
177
  @parameters << 'aliases' if includes[:aliases]
140
178
  @parameters << 'artist-rels' if includes[:artist_rels]
@@ -142,6 +180,7 @@ module MusicBrainz
142
180
  @parameters << 'track-rels' if includes[:track_rels]
143
181
  @parameters << 'label-rels' if includes[:label_rels]
144
182
  @parameters << 'url-rels' if includes[:url_rels]
183
+ @parameters << 'tags' if includes[:tags]
145
184
  end
146
185
 
147
186
  end