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
data/CHANGES ADDED
@@ -0,0 +1,31 @@
1
+ = Changelog
2
+
3
+ == 0.2.0 (2007-07-19)
4
+ * Querying of collections implemented
5
+ * Collection class to store search results (with support for search score and offset)
6
+ * User authentication
7
+ * Querying of user information
8
+ * Support POST in Webservice class to submit information.
9
+ * PUID submission.
10
+ * Made IncompleteDate behave like a range with corresponding equality operations
11
+ * Restructured MBID to use a ducktyping approach
12
+ * Introduced Individual as superclass for Artist and Label
13
+ * Added unique_name method for Artist and Label
14
+ * Label: Renamed founding_date and dissolving_date to begin_date
15
+ and end_date (to be more consistent with Artist)
16
+ * Support for label aliases
17
+ * Added label type "Unknown"
18
+ * Full text search (lucene search queries).
19
+ * Support entity tags as defined in the MB metadata scheme 1.2. Currently only
20
+ available on test.musicbrainz.org.
21
+ * New Model::DefaultFactory
22
+
23
+ == 0.1.1 (2007-05-29)
24
+ * Full support for relations
25
+ * Proper exception handling in Webservice class
26
+ * Minor corrections
27
+
28
+ == 0.1.0 (2007-05-23)
29
+ * Initial release
30
+
31
+ $Id: CHANGES 145 2007-07-19 13:11:44Z phw $
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007, Philipp Wolfer
1
+ RBrainz is Copyright (c) 2007 Philipp Wolfer and Nigel Graham.
2
2
 
3
3
  Redistribution and use in source and binary forms, with or without
4
4
  modification, are permitted provided that the following conditions
data/README CHANGED
@@ -7,5 +7,6 @@ To generate the complete RBrainz documentation run
7
7
 
8
8
  The documentation will be stored in doc/api.
9
9
 
10
- Copyright (c) 2007, Philipp Wolfer
11
- Licensing information can be found in the file LICENSE.
10
+ RBrainz is Copyright (c) 2007 Philipp Wolfer and Nigel Graham.
11
+ It is free softare distributed under a BSD style license. See
12
+ LICENSE for details.
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: Rakefile 34 2007-05-29 15:08:03Z phw $
1
+ # $Id: Rakefile 145 2007-07-19 13:11:44Z phw $
2
2
  # Copyright (c) 2007, Philipp Wolfer
3
3
  # All rights reserved.
4
4
  # See LICENSE for permissions.
@@ -9,48 +9,51 @@ require 'rubygems'
9
9
  require 'rake/gempackagetask'
10
10
  require 'rake/testtask'
11
11
  require 'rake/rdoctask'
12
+ require './lib/rbrainz/version'
13
+
14
+ task :default do
15
+ puts "Please see 'rake --tasks' for an overview of the available tasks."
16
+ end
12
17
 
13
18
  # Packaging tasks: -------------------------------------------------------
14
19
 
15
20
  PKG_NAME = 'rbrainz'
16
- PKG_VERSION = '0.1.1'
21
+ PKG_VERSION = MusicBrainz::RBRAINZ_VERSION
17
22
  PKG_FILES = FileList[
18
- "Rakefile", "LICENSE", "README", "TODO",
23
+ "Rakefile", "LICENSE", "README", "TODO", "CHANGES",
19
24
  "doc/README.rdoc",
20
- "examples/**/*",
25
+ "examples/**/*.rb",
21
26
  "lib/**/*.rb",
22
27
  "test/**/*.rb",
23
28
  "test/test-data/**/*"
24
29
  ]
30
+ PKG_EXTRA_RDOC_FILES = ['doc/README.rdoc', 'LICENSE', 'TODO', 'CHANGES']
25
31
 
26
32
  spec = Gem::Specification.new do |spec|
27
33
  spec.platform = Gem::Platform::RUBY
28
- spec.summary = 'Ruby library for the MusicBrainz XML webservice.'
34
+ spec.summary = 'Ruby library for the MusicBrainz XML web service.'
29
35
  spec.name = PKG_NAME
30
36
  spec.version = PKG_VERSION
31
- spec.requirements << 'none'
32
- spec.require_path = 'lib'
33
- spec.autorequire = 'rbrainz'
37
+ spec.requirements << 'Optional: mb-discid >= 0.1.2 (for calculating disc IDs)'
38
+ spec.autorequire = spec.name
34
39
  spec.files = PKG_FILES
35
40
  spec.description = <<EOF
36
41
  RBrainz is a Ruby client library to access the MusicBrainz XML
37
- webservice written in pure Ruby.
42
+ web service. RBrainz supports the MusicBrainz XML Metadata Version 1.2,
43
+ including support for labels and extended release events.
38
44
 
39
45
  RBrainz follows the design of python-musicbrainz2, the reference
40
46
  implementation for a MusicBrainz client library. Developers used to
41
47
  python-musicbrainz2 should already know most of RBrainz' interface.
42
48
  However, RBrainz differs from python-musicbrainz2 wherever it makes
43
49
  the library more Ruby like or easier to use.
44
-
45
- RBrainz supports the MusicBrainz XML Metadata Version 1.1, including
46
- support for labels and extended release events.
47
50
  EOF
48
- spec.author = 'Philipp Wolfer'
51
+ spec.author = ['Philipp Wolfer', 'Nigel Graham']
49
52
  spec.email = 'phw@rubyforge.org'
50
53
  spec.homepage = 'http://rbrainz.rubyforge.org'
51
54
  spec.rubyforge_project = 'rbrainz'
52
55
  spec.has_rdoc = true
53
- spec.extra_rdoc_files = ['doc/README.rdoc']
56
+ spec.extra_rdoc_files = PKG_EXTRA_RDOC_FILES
54
57
  end
55
58
 
56
59
  Rake::GemPackageTask.new(spec) do |pkg|
@@ -58,6 +61,16 @@ Rake::GemPackageTask.new(spec) do |pkg|
58
61
  pkg.need_tar_gz= true
59
62
  end
60
63
 
64
+ # Build the RBrainz gem and install it"
65
+ task :install => [:test, :gem] do
66
+ sh %{gem install pkg/#{PKG_NAME}-#{PKG_VERSION}.gem}
67
+ end
68
+
69
+ # Uninstall RBrainz"
70
+ task :uninstall => [:gem] do
71
+ sh %{gem uninstall #{PKG_NAME}}
72
+ end
73
+
61
74
  # Test tasks: ------------------------------------------------------------
62
75
 
63
76
  desc "Run the unit and functional tests"
@@ -83,9 +96,9 @@ Rake::RDocTask.new do |rdoc|
83
96
  rdoc.title = "RBrainz %s" % PKG_VERSION
84
97
  rdoc.main = 'doc/README.rdoc'
85
98
  rdoc.rdoc_dir = 'doc/api'
86
- rdoc.rdoc_files.include('doc/README.rdoc', 'lib/**/*.rb',
87
- 'LICENSE', 'TODO')
88
- rdoc.options << '--inline-source' << '--line-numbers'
99
+ rdoc.rdoc_files.include('lib/**/*.rb', PKG_EXTRA_RDOC_FILES)
100
+ rdoc.options << '--inline-source' << '--line-numbers' \
101
+ << '--charset=UTF-8' #<< '--diagram'
89
102
  end
90
103
 
91
104
  # Other tasks: -----------------------------------------------------------
@@ -95,10 +108,10 @@ def egrep(pattern)
95
108
  count = 0
96
109
  open(fn) do |f|
97
110
  while line = f.gets
98
- count += 1
99
- if line =~ pattern
100
- puts "#{fn}:#{count}:#{line}"
101
- end
111
+ count += 1
112
+ if line =~ pattern
113
+ puts "#{fn}:#{count}:#{line}"
114
+ end
102
115
  end
103
116
  end
104
117
  end
@@ -106,5 +119,10 @@ end
106
119
 
107
120
  desc "Look for TODO and FIXME tags in the code"
108
121
  task :todo do
109
- egrep /#.*(FIXME|TODO)/
122
+ egrep(/#.*(FIXME|TODO)/)
123
+ end
124
+
125
+ desc "Print version information"
126
+ task :version do
127
+ puts "%s %s" % [PKG_NAME, PKG_VERSION]
110
128
  end
data/TODO CHANGED
@@ -1,29 +1,12 @@
1
- =TODO
1
+ = TODO
2
2
 
3
- ==Short term tasks
4
- * Query collections (0.2.0)
5
- * Support for the score parameter in search result. Could be implemented
6
- a little bit like in PythonMusicBrainz2, but more flexible. Maybe a result
7
- object over which one can iterate to retrieve all results with the
8
- corresponding score. (0.2.0)
9
- result.each {|entity, score|
10
- ...
11
- }
12
- * Support for the offset parameter for queries on collections
13
- to retrieve results below the 100 results limit. Could be easily integrated
14
- into the result object (see previous point). (0.2.0)
15
- * Make it easier to create MBID objects or allow usage of ID strings
16
- where it makes life easier (>= 0.2.1).
17
- * Add usefull constructor parameters to the models (>= 0.2.1).
3
+ == Short term tasks
18
4
  * Improve API documentation.
19
5
 
20
- ==Longer term tasks
21
- * Calculation of disc IDs (0.3.0)
22
- * User authentication (0.4.0)
23
- * Querying of user information (0.4.0)
24
- * PUID submission
25
- * Full text search (lucene search queries).
6
+ == Longer term tasks
26
7
  * Implement a command line tool (+mbquery+) for querying the MusicBrainz
27
8
  database which will serve as a usefull example for RBrainz.
28
9
  * Support for common extensions (this could be implemented by adding
29
- additional extension libraries which extend the existing classes).
10
+ additional extension libraries which extend the existing classes).
11
+
12
+ $Id: TODO 129 2007-07-12 17:52:17Z phw $
data/doc/README.rdoc CHANGED
@@ -1,40 +1,45 @@
1
- =RBrainz - Ruby MusicBrainz library
2
- RBrainz is a Ruby client library to access the MusicBrainz XML webservice,
1
+ = RBrainz - Ruby MusicBrainz library
2
+ RBrainz is a Ruby client library to access the MusicBrainz XML web service,
3
3
  which can be used to query the MusicBrainz database.
4
4
 
5
- RBrainz is written in pure Ruby and follows the design of
5
+ RBrainz is written in Ruby and follows the design of
6
6
  PythonMusicBrainz2[http://musicbrainz.org/doc/PythonMusicBrainz2],
7
7
  the reference implementation for a MusicBrainz client library. Developers
8
8
  used to PythonMusicBrainz2 should already know most of RBrainz' interface.
9
9
  However, RBrainz differs from PythonMusicBrainz2 wherever it makes the
10
10
  library more Ruby like or easier to use.
11
11
 
12
- RBrainz supports the MusicBrainz XML Metadata Version 1.1, including support
12
+ RBrainz supports the MusicBrainz XML Metadata Version 1.2, including support
13
13
  for labels and extended release events.
14
14
 
15
- ==Installation
16
- ===Installing with RubyGems
15
+ == Installation
16
+ === Installing with RubyGems
17
17
  The easiest way to install the latest release of RBrainz is using
18
18
  RubyGems[http://rubygems.org] by executing the following command:
19
19
  gem install rbrainz
20
20
 
21
- ===Manual installation
22
- Not supported, yet.
21
+ === Manual installation
22
+ If you downloaded the RBRainz source package or checked out the latest version
23
+ from SVN you can install it with
24
+ rake install
25
+
26
+ You still need RubyGems for the installation to succeed.
23
27
 
24
- ==Basic usage
28
+ == Basic usage
25
29
  The most important classes in this library are the model classes
26
30
  MusicBrainz::Model::Artist, MusicBrainz::Model::Release,
27
31
  MusicBrainz::Model::Track and MusicBrainz::Model::Label
28
32
  together with MusicBrainz::Webservice::Query. The Query class
29
33
  provides an easy to use interface to query the MusicBrainz webservice.
30
- It will always return one of the model classes above or an
31
- array of those classes. The example below should make the usage clear:
34
+ It will always return one of the model classes above or a
35
+ MusicBrainz::Model::ScoredCollection of those classes. The example below
36
+ should make the usage clear:
32
37
 
33
38
  require 'rbrainz'
34
39
  include MusicBrainz
35
40
 
36
41
  # Create an MBID object which represents a MusicBrainz artist ID.
37
- mbid = Model::MBID.from_uuid(:artist, 'c0b2500e-0cef-4130-869d-732b23ed9df5')
42
+ mbid = Model::MBID.new('c0b2500e-0cef-4130-869d-732b23ed9df5', :artist)
38
43
 
39
44
  # With the ArtistInclude object we can control what kind of information
40
45
  # the MusicBrainz server will include in its answer.
@@ -48,21 +53,45 @@ array of those classes. The example below should make the usage clear:
48
53
  :url_rels => true
49
54
  )
50
55
 
51
- # Query the webservice for the artist with the above ID
52
- # The result will contain all the information specified
53
- # in artist_includes.
54
- q = Webservice::Query.new
55
- artist = q.get_artist_by_id(mbid, artist_includes)
56
+ # Query the webservice for the artist with the above ID. The result
57
+ # will contain all the information specified in artist_includes.
58
+ query = Webservice::Query.new
59
+ artist = query.get_artist_by_id(mbid, artist_includes)
60
+
61
+ # Display the fetched artist data together with all unique release titles.
62
+ print <<EOF
63
+ ID : #{artist.id.uuid}
64
+ Name : #{artist.name}
65
+ Sort name : #{artist.sort_name}
66
+ Disambiguation: #{artist.disambiguation}
67
+ Type : #{artist.type}
68
+ Begin date : #{artist.begin_date}
69
+ End date : #{artist.end_date}
70
+ Aliases : #{artist.aliases.to_a.join('; ')}
71
+ Releases : #{artist.releases.map{|r| r.title}.uniq.join("\r\n ")}
72
+ EOF
56
73
 
57
- ==The MusicBrainz webservice
74
+ == The MusicBrainz webservice
58
75
  For more information about the MusicBrainz webservice visit the
59
76
  following resources:
60
77
  - MusicBrainzXMLWebService[http://musicbrainz.org/doc/XMLWebService]
61
78
  - MusicBrainzXMLMetaData[http://musicbrainz.org/doc/MusicBrainzXMLMetaData]
62
79
 
63
- ==License
64
- RBrainz is Copyright (c) 2007 Philipp Wolfer.
80
+ == Contact
81
+ For more information about RBrainz visit http://rbrainz.rubyforge.org.
82
+
83
+ If you have any questions or suggestions regarding RBrainz please write to
84
+ the rbrainz-user mailinglist[http://rubyforge.org/mail/?group_id=3677].
85
+ If you find bugs or if you have any feature requests please use the
86
+ RBrainz bug tracker[http://rubyforge.org/tracker/?group_id=3677].
87
+
88
+ == Authors
89
+ * Nigel Graham
90
+ * Philipp Wolfer
91
+
92
+ == License
93
+ RBrainz is Copyright (c) 2007 Philipp Wolfer and Nigel Graham.
65
94
  It is free softare distributed under a BSD style license. See
66
95
  LICENSE[link:files/LICENSE.html] for details.
67
96
 
68
- $Id: README.rdoc 5 2007-05-21 16:51:22Z phw $
97
+ $Id: README.rdoc 145 2007-07-19 13:11:44Z phw $
@@ -3,7 +3,7 @@
3
3
  # Example script which queries the database for an
4
4
  # artist and displays the artist's data.
5
5
  #
6
- # $Id: getartist.rb 16 2007-05-23 15:49:06Z phw $
6
+ # $Id: getartist.rb 145 2007-07-19 13:11:44Z phw $
7
7
 
8
8
  # Just make sure we can run this example from the command
9
9
  # line even if RBrainz is not yet installed properly.
@@ -19,7 +19,7 @@ include MusicBrainz
19
19
  id = $*[0] ? $*[0] : '10bf95b6-30e3-44f1-817f-45762cdc0de0'
20
20
 
21
21
  # Generate a new artist MBID object from the ID:
22
- mbid = Model::MBID.from_uuid(:artist, id)
22
+ mbid = Model::MBID.parse(id, :artist)
23
23
 
24
24
  # Define what information about the artist
25
25
  # should be included in the result.
@@ -32,11 +32,13 @@ artist_includes = Webservice::ArtistIncludes.new(
32
32
  )
33
33
 
34
34
  # Create a new Query object which will provide
35
- # us an interface to the MusicBrainz webservice.
35
+ # us an interface to the MusicBrainz web service.
36
36
  query = Webservice::Query.new
37
37
 
38
38
  # Now query the MusicBrainz database for the artist
39
39
  # with the MBID defined above.
40
+ # We could as well use the ID string directly instead
41
+ # of the MBID object.
40
42
  artist = query.get_artist_by_id(mbid, artist_includes)
41
43
 
42
44
  # Display the fetched artist data together with all
@@ -49,6 +51,6 @@ Disambiguation: #{artist.disambiguation}
49
51
  Type : #{artist.type}
50
52
  Begin date : #{artist.begin_date}
51
53
  End date : #{artist.end_date}
52
- Aliases : #{artist.aliases.join('; ')}
54
+ Aliases : #{artist.aliases.to_a.join('; ')}
53
55
  Releases : #{artist.releases.map{|r| r.title}.uniq.join("\r\n ")}
54
56
  EOF
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Example script which queries the database for a
4
+ # User
5
+ #
6
+ # $Id: getuser.rb 145 2007-07-19 13:11:44Z phw $
7
+
8
+ # Just make sure we can run this example from the command
9
+ # line even if RBrainz is not yet installed properly.
10
+ $: << 'lib/' << '../lib/'
11
+
12
+ # Load RBrainz and include the MusicBrainz namespace.
13
+ require 'rbrainz'
14
+ include MusicBrainz
15
+
16
+ print 'Username: ' unless ARGV[0]
17
+ username = ARGV[0] ? ARGV[0] : STDIN.gets.strip
18
+ print 'Password: ' unless ARGV[1]
19
+ password = ARGV[1] ? ARGV[1] : STDIN.gets.strip
20
+
21
+ ws = Webservice::Webservice.new(:username=>username, :password=>password)
22
+
23
+ # Create a new Query object which will provide
24
+ # us an interface to the MusicBrainz web service.
25
+ query = Webservice::Query.new(ws)
26
+
27
+ user = query.get_user_by_name(username)
28
+ puts "Name : " + user.name
29
+ puts "ShowNag: " + user.show_nag?.to_s
30
+ puts "Types : " + user.types.join(' ')
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Example script which searches the database for
4
+ # artists and displays the artist's data.
5
+ #
6
+ # $Id: searchartists.rb 145 2007-07-19 13:11:44Z phw $
7
+
8
+ # Just make sure we can run this example from the command
9
+ # line even if RBrainz is not yet installed properly.
10
+ $: << 'lib/' << '../lib/'
11
+
12
+ # Load RBrainz and include the MusicBrainz namespace.
13
+ require 'rbrainz'
14
+ include MusicBrainz
15
+
16
+ # Define the search parameters: Search for artists with the
17
+ # name "Paradise Lost" and return a maximum of 10 artists.
18
+ artist_filter = Webservice::ArtistFilter.new(
19
+ :name => 'Paradise Lost',
20
+ :limit => 10
21
+ )
22
+
23
+ # Create a new Query object which will provide
24
+ # us an interface to the MusicBrainz web service.
25
+ query = Webservice::Query.new
26
+
27
+ # Now query the MusicBrainz database for artists
28
+ # with the search parameters defined above.
29
+ artists = query.get_artists(artist_filter)
30
+
31
+ # Display the fetched artist's names and the score, which
32
+ # indicates how good the artist matches the search parameters.
33
+ artists.each do |entry|
34
+ print "%s (%i%%)\r\n" % [entry.entity.unique_name, entry.score]
35
+ end
data/lib/rbrainz.rb CHANGED
@@ -1,11 +1,16 @@
1
- # $Id: rbrainz.rb 4 2007-05-21 02:04:26Z phw $
2
- # Copyright (c) 2007, Philipp Wolfer
3
- # All rights reserved.
4
- # See LICENSE for permissions.
5
-
1
+ # $Id: rbrainz.rb 145 2007-07-19 13:11:44Z phw $
2
+ #
6
3
  # This is actually just a convenient shortcut that allows
7
4
  # the user to use RBrainz by just using <tt>require 'rbrainz'</tt>.
8
- # This will include the whole RBrainz webservice library, which
5
+ # This will include the whole RBrainz web service library, which
9
6
  # should be ok most of the time.
7
+ #
8
+ # If you want only the models use <tt>require 'rbrainz/model'</tt>.
9
+ #
10
+ # Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
11
+ # Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
12
+ # License:: RBrainz is free software distributed under a BSD style license.
13
+ # See LICENSE[file:../LICENSE.html] for permissions.
10
14
 
11
- require 'rbrainz/webservice'
15
+ require 'rbrainz/webservice'
16
+ require 'rbrainz/core_ext'