musicbrainz 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  === Api
22
22
 
23
- MusicBrainzArtist
23
+ MusicBrainz::Artist
24
24
 
25
25
  @artists = MusicBrainz::Artist.search(query)
26
26
  @artist = MusicBrainz::Artist.find_by_name(name)
@@ -33,7 +33,7 @@ MusicBrainzArtist
33
33
  @artist.date_end
34
34
  @artist.release_groups
35
35
 
36
- MusicBrainzReleaseGroup
36
+ MusicBrainz::ReleaseGroup
37
37
 
38
38
  @release_group = MusicBrainz::ReleaseGroup.find(mbid)
39
39
  @release_group.id
@@ -42,7 +42,7 @@ MusicBrainzReleaseGroup
42
42
  @release_group.first_release_date
43
43
  @release_group.releases
44
44
 
45
- MusicBrainzRelease
45
+ MusicBrainz::Release
46
46
 
47
47
  @release = MusicBrainz::Release.find(mbid)
48
48
  @release.id
@@ -52,7 +52,7 @@ MusicBrainzRelease
52
52
  @release.country
53
53
  @release.tracks
54
54
 
55
- MusicBrainzTrack
55
+ MusicBrainz::Track
56
56
 
57
57
  @track = MusicBrainz::Track.find(mbid)
58
58
  @track.position
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -1,6 +1,10 @@
1
1
  module MusicBrainz
2
2
  @@last_query_time = 0
3
- @@query_interval = 1.1
3
+ @@query_interval = 1.5 # Min: 1.0 Safe: 1.5
4
+
5
+ def self.query_interval sec
6
+ @@query_interval = sec.to_f
7
+ end
4
8
 
5
9
  def self.load url
6
10
  sleep @@query_interval - (Time.now.to_f - @@last_query_time) if Time.now.to_f - @@last_query_time < @@query_interval
@@ -10,7 +14,7 @@ module MusicBrainz
10
14
  response = open(url, "User-Agent" => "gem musicbrainz (https://github.com/magnolia-fan/musicbrainz) @ " + Socket.gethostname)
11
15
  @@last_query_time = Time.now.to_f
12
16
  rescue => e
13
- p "MusicBrainz: 503"
17
+ # MusicBrainz: 503
14
18
  end
15
19
  break unless response.nil?
16
20
  end
@@ -12,7 +12,7 @@ module MusicBrainz
12
12
  @release_groups << MusicBrainz::ReleaseGroup.parse_xml(rg)
13
13
  end
14
14
  end
15
- @release_groups
15
+ @release_groups.sort{ |a, b| a.first_release_date <=> b.first_release_date }
16
16
  end
17
17
 
18
18
  def self.find mbid
@@ -10,7 +10,7 @@ module MusicBrainz
10
10
  @tracks << MusicBrainz::Track.parse_xml(r)
11
11
  end
12
12
  end
13
- @tracks
13
+ @tracks.sort{ |a, b| a.position <=> b.position }
14
14
  end
15
15
 
16
16
  def self.find mbid
@@ -23,17 +23,16 @@ module MusicBrainz
23
23
  @release.id = xml.attr('id')
24
24
  @release.title = xml.css('title').text unless xml.css('title').empty?
25
25
  @release.status = xml.css('status').text unless xml.css('status').empty?
26
- date = nil
27
- date = xml.css('date').text unless xml.css('date').empty?
28
- unless date.nil? or date.empty?
29
- if date.length == 4
30
- date += '-01-01'
31
- elsif date.length == 7
32
- date += '-01'
33
- end
34
- date = Time.parse(date)
26
+ date = xml.css('date').empty? ? '9999-12-31' : xml.css('date').text
27
+ if date.length == 0
28
+ date = '9999-12-31'
29
+ elsif date.length == 4
30
+ date += '-12-31'
31
+ elsif date.length == 7
32
+ date += '-31'
35
33
  end
36
- @release.date = date
34
+ date = date.split('-')
35
+ @release.date = Time.utc(date[0], date[1], date[2])
37
36
  @release.country = xml.css('country').text unless xml.css('country').empty?
38
37
  @release
39
38
  end
@@ -1,6 +1,6 @@
1
1
  module MusicBrainz
2
2
  class ReleaseGroup
3
- attr_accessor :id, :type, :title, :first_release_date
3
+ attr_accessor :id, :type, :title, :disambiguation, :first_release_date
4
4
  @releases
5
5
 
6
6
  def releases
@@ -10,7 +10,7 @@ module MusicBrainz
10
10
  @releases << MusicBrainz::Release.parse_xml(r)
11
11
  end
12
12
  end
13
- @releases
13
+ @releases.sort{ |a, b| a.date <=> b.date }
14
14
  end
15
15
 
16
16
  def self.find mbid
@@ -22,18 +22,18 @@ module MusicBrainz
22
22
  @release_group = MusicBrainz::ReleaseGroup.new
23
23
  @release_group.id = xml.attr('id')
24
24
  @release_group.type = xml.attr('type')
25
- @release_group.title = xml.css('title').text unless xml.css('title').empty?
26
- date = nil
27
- date = xml.css('first-release-date').text unless xml.css('first-release-date').empty?
28
- unless date.nil? or date.empty?
29
- if date.length == 4
30
- date += '-01-01'
31
- elsif date.length == 7
32
- date += '-01'
33
- end
34
- date = Time.parse(date)
25
+ @release_group.title = xml.css('title').text
26
+ @release_group.disambiguation = xml.css('disambiguation').empty? ? '' : xml.css('disambiguation').text
27
+ date = xml.css('first-release-date').empty? ? '9999-12-31' : xml.css('first-release-date').text
28
+ if date.length == 0
29
+ date = '9999-12-31'
30
+ elsif date.length == 4
31
+ date += '-12-31'
32
+ elsif date.length == 7
33
+ date += '-31'
35
34
  end
36
- @release_group.first_release_date = date
35
+ date = date.split('-')
36
+ @release_group.first_release_date = Time.utc(date[0], date[1], date[2])
37
37
  @release_group
38
38
  end
39
39
  end
data/musicbrainz.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{musicbrainz}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Gregory Eremin}]
@@ -38,10 +38,10 @@ class TestMusicbrainz < Test::Unit::TestCase
38
38
  should "load release groups" do
39
39
  release_groups = @artist.release_groups
40
40
  assert_operator(16, :<=, release_groups.length)
41
- assert_equal('0244b82e-0796-36fc-a629-2507d5441124', release_groups[0].id)
42
- assert_equal('Single', release_groups[0].type)
43
- assert_equal('Shoot the Runner', release_groups[0].title)
44
- assert_equal(Time.parse('2006-01-01'), release_groups[0].first_release_date)
41
+ assert_equal('533cbc5f-ec7e-32ab-95f3-8d1f804a5176', release_groups.first.id)
42
+ assert_equal('Single', release_groups.first.type)
43
+ assert_equal('Club Foot', release_groups.first.title)
44
+ assert_equal(Time.utc(2004, 5, 10), release_groups.first.first_release_date)
45
45
  end
46
46
  end
47
47
 
@@ -64,17 +64,17 @@ class TestMusicbrainz < Test::Unit::TestCase
64
64
  assert_equal("6f33e0f0-cde2-38f9-9aee-2c60af8d1a61", @release_group.id)
65
65
  assert_equal("Album", @release_group.type)
66
66
  assert_equal("Empire", @release_group.title)
67
- assert_equal(Time.parse('2006-08-28'), @release_group.first_release_date)
67
+ assert_equal(Time.utc(2006, 8, 28), @release_group.first_release_date)
68
68
  end
69
69
 
70
70
  should "load releases" do
71
71
  releases = @release_group.releases
72
72
  assert_operator(5, :<=, releases.length)
73
- assert_equal('2225dd4c-ae9a-403b-8ea0-9e05014c778f', releases[0].id)
74
- assert_equal('Official', releases[0].status)
75
- assert_equal('Empire', releases[0].title)
76
- assert_equal(Time.parse('2006-08-28'), releases[0].date)
77
- assert_equal('GB', releases[0].country)
73
+ assert_equal('2225dd4c-ae9a-403b-8ea0-9e05014c778f', releases.first.id)
74
+ assert_equal('Official', releases.first.status)
75
+ assert_equal('Empire', releases.first.title)
76
+ assert_equal(Time.utc(2006, 8, 28), releases.first.date)
77
+ assert_equal('GB', releases.first.country)
78
78
  end
79
79
  end
80
80
 
@@ -97,17 +97,17 @@ class TestMusicbrainz < Test::Unit::TestCase
97
97
  assert_equal("2225dd4c-ae9a-403b-8ea0-9e05014c778f", @release.id)
98
98
  assert_equal("Empire", @release.title)
99
99
  assert_equal("Official", @release.status)
100
- assert_equal(Time.parse('2006-08-28'), @release.date)
100
+ assert_equal(Time.utc(2006, 8, 28), @release.date)
101
101
  assert_equal("GB", @release.country)
102
102
  end
103
103
 
104
104
  should "load tracks" do
105
105
  tracks = @release.tracks
106
106
  assert_equal(11, tracks.length)
107
- assert_equal(1, tracks[0].position)
108
- assert_equal('b3015bab-1540-4d4e-9f30-14872a1525f7', tracks[0].recording_id)
109
- assert_equal('Empire', tracks[0].title)
110
- assert_equal(233013, tracks[0].length)
107
+ assert_equal(1, tracks.first.position)
108
+ assert_equal('b3015bab-1540-4d4e-9f30-14872a1525f7', tracks.first.recording_id)
109
+ assert_equal('Empire', tracks.first.title)
110
+ assert_equal(233013, tracks.first.length)
111
111
  end
112
112
  end
113
113
 
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.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &2153634900 !ruby/object:Gem::Requirement
16
+ requirement: &2153420120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153634900
24
+ version_requirements: *2153420120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: shoulda
27
- requirement: &2153634260 !ruby/object:Gem::Requirement
27
+ requirement: &2153419520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2153634260
35
+ version_requirements: *2153419520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2153633420 !ruby/object:Gem::Requirement
38
+ requirement: &2153418920 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2153633420
46
+ version_requirements: *2153418920
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &2153632720 !ruby/object:Gem::Requirement
49
+ requirement: &2153418380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.6.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2153632720
57
+ version_requirements: *2153418380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &2153631960 !ruby/object:Gem::Requirement
60
+ requirement: &2153417720 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2153631960
68
+ version_requirements: *2153417720
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdoc
71
- requirement: &2153631100 !ruby/object:Gem::Requirement
71
+ requirement: &2153417040 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2153631100
79
+ version_requirements: *2153417040
80
80
  description: MusicBrainz Web Service wrapper with ActiveRecord-style models
81
81
  email: magnolia_fan@me.com
82
82
  executables: []
@@ -114,9 +114,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  - - ! '>='
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
- segments:
118
- - 0
119
- hash: 1855770896645439952
120
117
  required_rubygems_version: !ruby/object:Gem::Requirement
121
118
  none: false
122
119
  requirements: