musicbrainz 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  rvm:
2
2
  - 1.8.7
3
- - 1.9.2
3
+ - 1.9.2
4
+ - 1.9.3
data/Gemfile CHANGED
@@ -1,16 +1,15 @@
1
1
  source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
2
 
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
3
  group :development do
9
- gem "shoulda", ">= 0"
10
4
  gem "bundler", "~> 1.0.0"
11
5
  gem "jeweler", "~> 1.6.4"
12
6
  gem "rcov", ">= 0"
13
7
  gem "rdoc", ">= 0"
8
+ gem "shoulda"
9
+
10
+ gem "rspec"
11
+ gem "vcr"
12
+ gem "webmock"
14
13
  end
15
14
 
16
15
  gem "nokogiri", ">= 0"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  module MusicBrainz
2
4
  class Artist < MusicBrainz::Base
3
5
  attr_accessor :id, :type, :name, :country, :date_begin, :date_end, :urls
@@ -23,7 +25,7 @@ module MusicBrainz
23
25
  @artist = MusicBrainz::Artist.new
24
26
  @artist.id = self.safe_get_attr(xml, 'artist', 'id')
25
27
  @artist.type = self.safe_get_attr(xml, 'artist', 'type')
26
- @artist.name = self.safe_get_value(xml, 'artist > name')
28
+ @artist.name = self.safe_get_value(xml, 'artist > name').gsub(/[`’]/, "'")
27
29
  @artist.country = self.safe_get_value(xml, 'artist > country')
28
30
  @artist.date_begin = self.safe_get_value(xml, 'artist > life-span > begin')
29
31
  @artist.date_end = self.safe_get_value(xml, 'artist > life-span > end')
@@ -50,7 +52,8 @@ module MusicBrainz
50
52
  xml = Nokogiri::XML(MusicBrainz.load(:artist, :query => CGI.escape(name).gsub(/\!/, '') + '~', :limit => 50))
51
53
  xml.css('artist-list > artist').each do |a|
52
54
  artist = {
53
- :name => a.first_element_child.text,
55
+ :name => a.first_element_child.text.gsub(/[`’]/, "'"),
56
+ :sort_name => self.safe_get_value(a, 'sort-name').gsub(/[`’]/, "'"),
54
57
  :weight => 0,
55
58
  :desc => self.safe_get_value(a, 'disambiguation'),
56
59
  :type => self.safe_get_attr(a, nil, 'type'),
data/musicbrainz.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{musicbrainz}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Gregory Eremin}]
12
- s.date = %q{2011-10-06}
11
+ s.authors = ["Gregory Eremin"]
12
+ s.date = %q{2011-11-15}
13
13
  s.description = %q{MusicBrainz Web Service wrapper with ActiveRecord-style models}
14
14
  s.email = %q{magnolia_fan@me.com}
15
15
  s.extra_rdoc_files = [
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
20
20
  ".document",
21
21
  ".travis.yml",
22
22
  "Gemfile",
23
- "Gemfile.lock",
24
23
  "LICENSE.txt",
25
24
  "README.rdoc",
26
25
  "Rakefile",
@@ -33,6 +32,9 @@ Gem::Specification.new do |s|
33
32
  "lib/models/music_brainz/track.rb",
34
33
  "lib/musicbrainz.rb",
35
34
  "musicbrainz.gemspec",
35
+ "spec/requests/artist_spec.rb",
36
+ "spec/spec_helper.rb",
37
+ "spec/support/vcr.rb",
36
38
  "test/helper.rb",
37
39
  "test/test_musicbrainz_artist.rb",
38
40
  "test/test_musicbrainz_release.rb",
@@ -40,9 +42,9 @@ Gem::Specification.new do |s|
40
42
  "test/test_musicbrainz_track.rb"
41
43
  ]
42
44
  s.homepage = %q{http://github.com/magnolia-fan/musicbrainz}
43
- s.licenses = [%q{MIT}]
44
- s.require_paths = [%q{lib}]
45
- s.rubygems_version = %q{1.8.8}
45
+ s.licenses = ["MIT"]
46
+ s.require_paths = ["lib"]
47
+ s.rubygems_version = %q{1.6.2}
46
48
  s.summary = %q{MusicBrainz Web Service wrapper}
47
49
 
48
50
  if s.respond_to? :specification_version then
@@ -50,26 +52,35 @@ Gem::Specification.new do |s|
50
52
 
51
53
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
54
  s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
53
- s.add_development_dependency(%q<shoulda>, [">= 0"])
54
55
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
55
56
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
56
57
  s.add_development_dependency(%q<rcov>, [">= 0"])
57
58
  s.add_development_dependency(%q<rdoc>, [">= 0"])
59
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
60
+ s.add_development_dependency(%q<rspec>, [">= 0"])
61
+ s.add_development_dependency(%q<vcr>, [">= 0"])
62
+ s.add_development_dependency(%q<webmock>, [">= 0"])
58
63
  else
59
64
  s.add_dependency(%q<nokogiri>, [">= 0"])
60
- s.add_dependency(%q<shoulda>, [">= 0"])
61
65
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
62
66
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
63
67
  s.add_dependency(%q<rcov>, [">= 0"])
64
68
  s.add_dependency(%q<rdoc>, [">= 0"])
69
+ s.add_dependency(%q<shoulda>, [">= 0"])
70
+ s.add_dependency(%q<rspec>, [">= 0"])
71
+ s.add_dependency(%q<vcr>, [">= 0"])
72
+ s.add_dependency(%q<webmock>, [">= 0"])
65
73
  end
66
74
  else
67
75
  s.add_dependency(%q<nokogiri>, [">= 0"])
68
- s.add_dependency(%q<shoulda>, [">= 0"])
69
76
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
70
77
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
71
78
  s.add_dependency(%q<rcov>, [">= 0"])
72
79
  s.add_dependency(%q<rdoc>, [">= 0"])
80
+ s.add_dependency(%q<shoulda>, [">= 0"])
81
+ s.add_dependency(%q<rspec>, [">= 0"])
82
+ s.add_dependency(%q<vcr>, [">= 0"])
83
+ s.add_dependency(%q<webmock>, [">= 0"])
73
84
  end
74
85
  end
75
86
 
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe "artist" do
4
+ it "return valid instance", :vcr do
5
+ artist = MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033')
6
+ artist.should be_a_kind_of(MusicBrainz::Artist)
7
+ end
8
+
9
+ it "search by name", :vcr do
10
+ matches = MusicBrainz::Artist.search('Kasabian')
11
+ matches.should have_at_least(1).item
12
+ matches.first[:name].should eql('Kasabian')
13
+ end
14
+ #
15
+ # should "get correct result by name" do
16
+ # @artist = MusicBrainz::Artist.find_by_name('Kasabian')
17
+ # assert_equal("69b39eab-6577-46a4-a9f5-817839092033", @artist.id)
18
+ # end
19
+ #
20
+ # setup do
21
+ # @artist = MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033')
22
+ # end
23
+ #
24
+ # should "return valid instance" do
25
+ # assert_instance_of(MusicBrainz::Artist, @artist)
26
+ # end
27
+ #
28
+ # should "contain correct data" do
29
+ # assert_equal("69b39eab-6577-46a4-a9f5-817839092033", @artist.id)
30
+ # assert_equal("Group", @artist.type)
31
+ # assert_equal("Kasabian", @artist.name)
32
+ # assert_equal("GB", @artist.country)
33
+ # assert_equal("1999", @artist.date_begin)
34
+ # end
35
+ #
36
+ # should "load release groups" do
37
+ # release_groups = @artist.release_groups
38
+ # assert_operator(16, :<=, release_groups.length)
39
+ # assert_equal('533cbc5f-ec7e-32ab-95f3-8d1f804a5176', release_groups.first.id)
40
+ # assert_equal('Single', release_groups.first.type)
41
+ # assert_equal('Club Foot', release_groups.first.title)
42
+ # assert_equal(Time.utc(2004, 5, 10), release_groups.first.first_release_date)
43
+ # end
44
+ end
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require "vcr"
11
+ require "musicbrainz"
12
+
13
+ # HTTPI.log = false
14
+ Dir[File.dirname(__FILE__)+"/../lib/*.rb"].each{ |f| require f }
15
+ Dir[File.dirname(__FILE__)+"/../spec/support/*.rb"].each{ |f| require f }
16
+
17
+ RSpec.configure do |config|
18
+ config.mock_with :rspec
19
+ end
@@ -0,0 +1,13 @@
1
+ VCR.config do |c|
2
+ c.cassette_library_dir = File.join(File.dirname(__FILE__), '..', '..', 'tmp', 'vcr')
3
+ c.stub_with :webmock
4
+ c.default_cassette_options = { :record => :new_episodes }
5
+ end
6
+
7
+ RSpec.configure do |c|
8
+ c.treat_symbols_as_metadata_keys_with_true_values = true
9
+ c.around(:each, :vcr) do |example|
10
+ name = example.metadata[:full_description].gsub(/\s/, '_')
11
+ VCR.use_cassette(name) { example.call }
12
+ end
13
+ end
data/test/helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
3
  begin
4
- Bundler.setup(:default, :development)
4
+ Bundler.setup(:default, :test)
5
5
  rescue Bundler::BundlerError => e
6
6
  $stderr.puts e.message
7
7
  $stderr.puts "Run `bundle install` to install missing gems"
metadata CHANGED
@@ -1,94 +1,130 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: musicbrainz
3
- version: !ruby/object:Gem::Version
4
- version: 0.5.0
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.5.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Gregory Eremin
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-06 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2011-11-15 00:00:00 +04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
15
17
  name: nokogiri
16
- requirement: &2156435880 !ruby/object:Gem::Requirement
18
+ requirement: &id001 !ruby/object:Gem::Requirement
17
19
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
22
24
  type: :runtime
23
25
  prerelease: false
24
- version_requirements: *2156435880
25
- - !ruby/object:Gem::Dependency
26
- name: shoulda
27
- requirement: &2156435060 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *2156435060
36
- - !ruby/object:Gem::Dependency
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
37
28
  name: bundler
38
- requirement: &2156434280 !ruby/object:Gem::Requirement
29
+ requirement: &id002 !ruby/object:Gem::Requirement
39
30
  none: false
40
- requirements:
31
+ requirements:
41
32
  - - ~>
42
- - !ruby/object:Gem::Version
33
+ - !ruby/object:Gem::Version
43
34
  version: 1.0.0
44
35
  type: :development
45
36
  prerelease: false
46
- version_requirements: *2156434280
47
- - !ruby/object:Gem::Dependency
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
48
39
  name: jeweler
49
- requirement: &2156211980 !ruby/object:Gem::Requirement
40
+ requirement: &id003 !ruby/object:Gem::Requirement
50
41
  none: false
51
- requirements:
42
+ requirements:
52
43
  - - ~>
53
- - !ruby/object:Gem::Version
44
+ - !ruby/object:Gem::Version
54
45
  version: 1.6.4
55
46
  type: :development
56
47
  prerelease: false
57
- version_requirements: *2156211980
58
- - !ruby/object:Gem::Dependency
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
59
50
  name: rcov
60
- requirement: &2156211280 !ruby/object:Gem::Requirement
51
+ requirement: &id004 !ruby/object:Gem::Requirement
61
52
  none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: '0'
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
66
57
  type: :development
67
58
  prerelease: false
68
- version_requirements: *2156211280
69
- - !ruby/object:Gem::Dependency
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
70
61
  name: rdoc
71
- requirement: &2156210560 !ruby/object:Gem::Requirement
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: shoulda
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: rspec
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: vcr
95
+ requirement: &id008 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ type: :development
102
+ prerelease: false
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: webmock
106
+ requirement: &id009 !ruby/object:Gem::Requirement
72
107
  none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
77
112
  type: :development
78
113
  prerelease: false
79
- version_requirements: *2156210560
114
+ version_requirements: *id009
80
115
  description: MusicBrainz Web Service wrapper with ActiveRecord-style models
81
116
  email: magnolia_fan@me.com
82
117
  executables: []
118
+
83
119
  extensions: []
84
- extra_rdoc_files:
120
+
121
+ extra_rdoc_files:
85
122
  - LICENSE.txt
86
123
  - README.rdoc
87
- files:
124
+ files:
88
125
  - .document
89
126
  - .travis.yml
90
127
  - Gemfile
91
- - Gemfile.lock
92
128
  - LICENSE.txt
93
129
  - README.rdoc
94
130
  - Rakefile
@@ -101,37 +137,44 @@ files:
101
137
  - lib/models/music_brainz/track.rb
102
138
  - lib/musicbrainz.rb
103
139
  - musicbrainz.gemspec
140
+ - spec/requests/artist_spec.rb
141
+ - spec/spec_helper.rb
142
+ - spec/support/vcr.rb
104
143
  - test/helper.rb
105
144
  - test/test_musicbrainz_artist.rb
106
145
  - test/test_musicbrainz_release.rb
107
146
  - test/test_musicbrainz_release_group.rb
108
147
  - test/test_musicbrainz_track.rb
148
+ has_rdoc: true
109
149
  homepage: http://github.com/magnolia-fan/musicbrainz
110
- licenses:
150
+ licenses:
111
151
  - MIT
112
152
  post_install_message:
113
153
  rdoc_options: []
114
- require_paths:
154
+
155
+ require_paths:
115
156
  - lib
116
- required_ruby_version: !ruby/object:Gem::Requirement
157
+ required_ruby_version: !ruby/object:Gem::Requirement
117
158
  none: false
118
- requirements:
119
- - - ! '>='
120
- - !ruby/object:Gem::Version
121
- version: '0'
122
- segments:
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ hash: -1300131029082120688
163
+ segments:
123
164
  - 0
124
- hash: 1738320966711740487
125
- required_rubygems_version: !ruby/object:Gem::Requirement
165
+ version: "0"
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
167
  none: false
127
- requirements:
128
- - - ! '>='
129
- - !ruby/object:Gem::Version
130
- version: '0'
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: "0"
131
172
  requirements: []
173
+
132
174
  rubyforge_project:
133
- rubygems_version: 1.8.8
175
+ rubygems_version: 1.6.2
134
176
  signing_key:
135
177
  specification_version: 3
136
178
  summary: MusicBrainz Web Service wrapper
137
179
  test_files: []
180
+
data/Gemfile.lock DELETED
@@ -1,24 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- git (1.2.5)
5
- jeweler (1.6.4)
6
- bundler (~> 1.0)
7
- git (>= 1.2.5)
8
- rake
9
- nokogiri (1.5.0)
10
- rake (0.9.2)
11
- rcov (0.9.9)
12
- rdoc (3.8)
13
- shoulda (2.11.3)
14
-
15
- PLATFORMS
16
- ruby
17
-
18
- DEPENDENCIES
19
- bundler (~> 1.0.0)
20
- jeweler (~> 1.6.4)
21
- nokogiri
22
- rcov
23
- rdoc
24
- shoulda