firstfm 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +2 -2
- data/firstfm.gemspec +4 -2
- data/lib/firstfm/artist.rb +11 -0
- data/test/fixtures/get_correction.xml +11 -0
- data/test/fixtures/get_correction_blank.xml +5 -0
- data/test/test_artist.rb +14 -0
- metadata +5 -3
data/VERSION.yml
CHANGED
data/firstfm.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "firstfm"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aleksandr Lossenko"]
|
12
|
-
s.date = "2013-01-
|
12
|
+
s.date = "2013-01-27"
|
13
13
|
s.description = "Firstfm is a ruby wrapper for the Last.fm APIs ( http://www.last.fm/api ). My main focus is to import events from Last.FM, but with time I will try to add support for all API methods."
|
14
14
|
s.email = "aleksandr.lossenko@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -41,6 +41,8 @@ Gem::Specification.new do |s|
|
|
41
41
|
"test/fixtures/geo_event.xml",
|
42
42
|
"test/fixtures/geo_events.xml",
|
43
43
|
"test/fixtures/geo_get_metro_artist_chart.xml",
|
44
|
+
"test/fixtures/get_correction.xml",
|
45
|
+
"test/fixtures/get_correction_blank.xml",
|
44
46
|
"test/fixtures/get_images.xml",
|
45
47
|
"test/fixtures/top_tracks.xml",
|
46
48
|
"test/fixtures/tracks.xml",
|
data/lib/firstfm/artist.rb
CHANGED
@@ -60,6 +60,17 @@ module Firstfm
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
def self.get_correction(artist)
|
64
|
+
response = get("/2.0/", {:query => {:method => 'artist.getcorrection', :artist => artist, :api_key => Firstfm.config.api_key}})
|
65
|
+
if response && response["lfm"] && response["lfm"] && response["lfm"]["status"] == "ok"
|
66
|
+
if response["lfm"]["corrections"] && response["lfm"]["corrections"]["correction"]
|
67
|
+
init_from_hash(response["lfm"]["corrections"]["correction"]["artist"]) rescue nil
|
68
|
+
elsif response["lfm"].key?("corrections")
|
69
|
+
init_from_hash({"name" => artist})
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
63
74
|
def self.init_from_array(array)
|
64
75
|
return [] unless array.is_a?(Array)
|
65
76
|
array.inject([]) do |arr, artist|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<lfm status="ok">
|
3
|
+
<corrections>
|
4
|
+
<correction index='0'>
|
5
|
+
<artist>
|
6
|
+
<name>Guns N' Roses</name>
|
7
|
+
<mbid>6e40312c-2a6d-445b-b2c9-f68e86f6a0a3</mbid>
|
8
|
+
<url>http://www.last.fm/music/Guns+N%27+Roses</url>
|
9
|
+
</artist> </correction>
|
10
|
+
</corrections>
|
11
|
+
</lfm>
|
data/test/test_artist.rb
CHANGED
@@ -54,4 +54,18 @@ class TestArtist < Test::Unit::TestCase
|
|
54
54
|
assert (tags - ["pop", "female vocalists", "80s", "dance", "rock"]).empty?
|
55
55
|
end
|
56
56
|
|
57
|
+
def test_should_get_correction
|
58
|
+
FakeWeb.register_uri(:get, %r|http://ws.audioscrobbler.com/|, :body => File.read(File.dirname(__FILE__) + "/fixtures/get_correction.xml"))
|
59
|
+
artist = Firstfm::Artist.get_correction("Guns")
|
60
|
+
assert_equal "Guns N' Roses", artist.name
|
61
|
+
assert_equal "6e40312c-2a6d-445b-b2c9-f68e86f6a0a3", artist.mbid
|
62
|
+
assert_equal "http://www.last.fm/music/Guns+N%27+Roses", artist.url
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_should_get_correction_even_if_correct
|
66
|
+
FakeWeb.register_uri(:get, %r|http://ws.audioscrobbler.com/|, :body => File.read(File.dirname(__FILE__) + "/fixtures/get_correction_blank.xml"))
|
67
|
+
artist = Firstfm::Artist.get_correction("Eminem")
|
68
|
+
assert_equal "Eminem", artist.name
|
69
|
+
end
|
70
|
+
|
57
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firstfm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
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-01-
|
12
|
+
date: 2013-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -173,6 +173,8 @@ files:
|
|
173
173
|
- test/fixtures/geo_event.xml
|
174
174
|
- test/fixtures/geo_events.xml
|
175
175
|
- test/fixtures/geo_get_metro_artist_chart.xml
|
176
|
+
- test/fixtures/get_correction.xml
|
177
|
+
- test/fixtures/get_correction_blank.xml
|
176
178
|
- test/fixtures/get_images.xml
|
177
179
|
- test/fixtures/top_tracks.xml
|
178
180
|
- test/fixtures/tracks.xml
|
@@ -198,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
200
|
version: '0'
|
199
201
|
segments:
|
200
202
|
- 0
|
201
|
-
hash:
|
203
|
+
hash: 3155602274475506363
|
202
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
205
|
none: false
|
204
206
|
requirements:
|