rockstar-custom 0.6.1
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/.travis.yml +6 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +22 -0
- data/History.txt +6 -0
- data/MIT-LICENSE +19 -0
- data/Manifest +72 -0
- data/README.md +135 -0
- data/Rakefile +34 -0
- data/VERSION +1 -0
- data/examples/.gitignore +1 -0
- data/examples/album.rb +16 -0
- data/examples/artist.rb +23 -0
- data/examples/geo.rb +9 -0
- data/examples/lastfm.yml_example +3 -0
- data/examples/scrobble.rb +45 -0
- data/examples/tag.rb +20 -0
- data/examples/track.rb +14 -0
- data/examples/user.rb +18 -0
- data/lib/rockstar.rb +50 -0
- data/lib/rockstar/album.rb +109 -0
- data/lib/rockstar/artist.rb +182 -0
- data/lib/rockstar/auth.rb +21 -0
- data/lib/rockstar/base.rb +48 -0
- data/lib/rockstar/chart.rb +31 -0
- data/lib/rockstar/event.rb +73 -0
- data/lib/rockstar/geo.rb +22 -0
- data/lib/rockstar/metro.rb +26 -0
- data/lib/rockstar/playing.rb +50 -0
- data/lib/rockstar/rest.rb +66 -0
- data/lib/rockstar/scrobble.rb +68 -0
- data/lib/rockstar/session.rb +19 -0
- data/lib/rockstar/simpleauth.rb +62 -0
- data/lib/rockstar/tag.rb +100 -0
- data/lib/rockstar/tokenauth.rb +84 -0
- data/lib/rockstar/track.rb +260 -0
- data/lib/rockstar/user.rb +200 -0
- data/lib/rockstar/venue.rb +59 -0
- data/lib/rockstar/version.rb +3 -0
- data/rockstar.gemspec +174 -0
- data/test/fixtures/xml/album/getinfo_album_Radio_Retalation_artist_Thievery_Corporation.xml +21 -0
- data/test/fixtures/xml/album/getinfo_album_Some_Hearts_artist_Carrie_Underwood.xml +63 -0
- data/test/fixtures/xml/artist/getevents_artist_Metallica.xml +1064 -0
- data/test/fixtures/xml/artist/getimages_artist_Metallica_page_2.xml +1074 -0
- data/test/fixtures/xml/artist/getinfo_artist_Metallica.xml +115 -0
- data/test/fixtures/xml/artist/getsimilar_artist_Metallica.xml +1203 -0
- data/test/fixtures/xml/artist/gettopalbums_artist_Metallica.xml +704 -0
- data/test/fixtures/xml/artist/gettopfans_artist_Metallica.xml +504 -0
- data/test/fixtures/xml/artist/gettoptags_artist_Metallica.xml +403 -0
- data/test/fixtures/xml/artist/gettoptracks_artist_Metallica.xml +800 -0
- data/test/fixtures/xml/geo/getevents_location_london.xml +531 -0
- data/test/fixtures/xml/geo/getmetros_country_germany.xml +44 -0
- data/test/fixtures/xml/tag/gettopalbums_tag_rock.xml +654 -0
- data/test/fixtures/xml/tag/gettopartists_tag_rock.xml +504 -0
- data/test/fixtures/xml/tag/gettoptags.xml +1253 -0
- data/test/fixtures/xml/tag/gettoptracks_tag_rock.xml +704 -0
- data/test/fixtures/xml/track/getinfo_artist_Carrie_Underwood_track_Before_He_Cheats.xml +55 -0
- data/test/fixtures/xml/track/gettopfans_artist_Carrie_Underwood_track_Before_He_Cheats.xml +504 -0
- data/test/fixtures/xml/track/gettoptags_artist_Carrie_Underwood_track_Before_He_Cheats.xml +403 -0
- data/test/fixtures/xml/track/love_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml +2 -0
- data/test/fixtures/xml/track/updatenowplaying_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml +10 -0
- data/test/fixtures/xml/user/getevents_sk_token_user_bodot.xml +513 -0
- data/test/fixtures/xml/user/getfriends_user_jnunemaker.xml +173 -0
- data/test/fixtures/xml/user/getinfo_user_jnunemaker.xml +22 -0
- data/test/fixtures/xml/user/getinfo_user_oaknd1.xml +22 -0
- data/test/fixtures/xml/user/getinfo_user_wharle.xml +22 -0
- data/test/fixtures/xml/user/getlovedtracks_user_jnunemaker.xml +775 -0
- data/test/fixtures/xml/user/getneighbours_user_jnunemaker.xml +503 -0
- data/test/fixtures/xml/user/getrecenttracks_user_jnunemaker.xml +133 -0
- data/test/fixtures/xml/user/getrecommendedartists_sk_token_user_jnunemaker.xml +553 -0
- data/test/fixtures/xml/user/gettopalbums_user_jnunemaker.xml +704 -0
- data/test/fixtures/xml/user/gettopartists_period_overall_user_jnunemaker.xml +554 -0
- data/test/fixtures/xml/user/gettoptags_user_jnunemaker.xml +63 -0
- data/test/fixtures/xml/user/gettoptracks_user_jnunemaker.xml +750 -0
- data/test/fixtures/xml/user/getweeklyalbumchart_from_1138536002_to_1139140802_user_jnunemaker.xml +143 -0
- data/test/fixtures/xml/user/getweeklyalbumchart_from__to__user_jnunemaker.xml +31 -0
- data/test/fixtures/xml/user/getweeklyartistchart_from_1138536002_to_1139140802_user_jnunemaker.xml +201 -0
- data/test/fixtures/xml/user/getweeklyartistchart_from__to__user_jnunemaker.xml +21 -0
- data/test/fixtures/xml/user/getweeklychartlist_user_jnunemaker.xml +232 -0
- data/test/fixtures/xml/user/getweeklytrackchart_from_1138536002_to_1139140802_user_jnunemaker.xml +883 -0
- data/test/fixtures/xml/user/getweeklytrackchart_from__to__user_jnunemaker.xml +423 -0
- data/test/fixtures/xml/venue/getevents_venue_8807850.xml +280 -0
- data/test/fixtures/xml/venue/search_country__limit__page__venue_country_DE_venue_cotton.xml +72 -0
- data/test/mocks/rest.rb +67 -0
- data/test/test_helper.rb +18 -0
- data/test/unit/test_album.rb +76 -0
- data/test/unit/test_artist.rb +102 -0
- data/test/unit/test_chart.rb +35 -0
- data/test/unit/test_geo.rb +25 -0
- data/test/unit/test_playing.rb +53 -0
- data/test/unit/test_scrobble.rb +69 -0
- data/test/unit/test_simpleauth.rb +45 -0
- data/test/unit/test_tag.rb +57 -0
- data/test/unit/test_tokenauth.rb +45 -0
- data/test/unit/test_track.rb +82 -0
- data/test/unit/test_user.rb +299 -0
- data/test/unit/test_venue.rb +20 -0
- metadata +269 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<lfm status="ok">
|
|
3
|
+
<results for="cotton" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
|
|
4
|
+
<opensearch:Query role="request" searchTerms="cotton" startPage="1" />
|
|
5
|
+
<opensearch:totalResults>3</opensearch:totalResults>
|
|
6
|
+
<opensearch:startIndex>0</opensearch:startIndex>
|
|
7
|
+
<opensearch:itemsPerPage>50</opensearch:itemsPerPage><venuematches>
|
|
8
|
+
<venue>
|
|
9
|
+
<id>8891678</id>
|
|
10
|
+
<name>Cotton Club</name>
|
|
11
|
+
<location>
|
|
12
|
+
<city>Hamburg</city>
|
|
13
|
+
<country>Germany</country>
|
|
14
|
+
<street>Alter Steinweg 10</street>
|
|
15
|
+
<postalcode>20459</postalcode>
|
|
16
|
+
<geo:point>
|
|
17
|
+
<geo:lat>53.550374</geo:lat>
|
|
18
|
+
<geo:long>9.98205</geo:long>
|
|
19
|
+
</geo:point>
|
|
20
|
+
</location>
|
|
21
|
+
<url>http://www.last.fm/venue/8891678+Cotton+Club</url>
|
|
22
|
+
<website>http://www.cotton-club.de/</website>
|
|
23
|
+
<phonenumber>+49 (0)40 343878</phonenumber>
|
|
24
|
+
<image size="small"></image>
|
|
25
|
+
<image size="medium"></image>
|
|
26
|
+
<image size="large"></image>
|
|
27
|
+
<image size="extralarge"></image>
|
|
28
|
+
<image size="mega"></image>
|
|
29
|
+
</venue> <venue>
|
|
30
|
+
<id>9036090</id>
|
|
31
|
+
<name>Cotton Club</name>
|
|
32
|
+
<location>
|
|
33
|
+
<city>Künzelsau</city>
|
|
34
|
+
<country>Germany</country>
|
|
35
|
+
<street></street>
|
|
36
|
+
<postalcode></postalcode>
|
|
37
|
+
<geo:point>
|
|
38
|
+
<geo:lat>49.280909</geo:lat>
|
|
39
|
+
<geo:long>9.690339</geo:long>
|
|
40
|
+
</geo:point>
|
|
41
|
+
</location>
|
|
42
|
+
<url>http://www.last.fm/venue/9036090+Cotton+Club</url>
|
|
43
|
+
<website></website>
|
|
44
|
+
<phonenumber></phonenumber>
|
|
45
|
+
<image size="small"></image>
|
|
46
|
+
<image size="medium"></image>
|
|
47
|
+
<image size="large"></image>
|
|
48
|
+
<image size="extralarge"></image>
|
|
49
|
+
<image size="mega"></image>
|
|
50
|
+
</venue> <venue>
|
|
51
|
+
<id>9087817</id>
|
|
52
|
+
<name>CottonClub</name>
|
|
53
|
+
<location>
|
|
54
|
+
<city>Kaiserslautern</city>
|
|
55
|
+
<country>Germany</country>
|
|
56
|
+
<street></street>
|
|
57
|
+
<postalcode></postalcode>
|
|
58
|
+
<geo:point>
|
|
59
|
+
<geo:lat>49.44702</geo:lat>
|
|
60
|
+
<geo:long>7.756832</geo:long>
|
|
61
|
+
</geo:point>
|
|
62
|
+
</location>
|
|
63
|
+
<url>http://www.last.fm/venue/9087817+CottonClub</url>
|
|
64
|
+
<website></website>
|
|
65
|
+
<phonenumber></phonenumber>
|
|
66
|
+
<image size="small"></image>
|
|
67
|
+
<image size="medium"></image>
|
|
68
|
+
<image size="large"></image>
|
|
69
|
+
<image size="extralarge"></image>
|
|
70
|
+
<image size="mega"></image>
|
|
71
|
+
</venue></venuematches>
|
|
72
|
+
</results></lfm>
|
data/test/mocks/rest.rb
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../lib/rockstar/rest'
|
|
2
|
+
require 'digest/md5'
|
|
3
|
+
|
|
4
|
+
module Rockstar
|
|
5
|
+
module REST
|
|
6
|
+
class Connection
|
|
7
|
+
|
|
8
|
+
def flatten(arg)
|
|
9
|
+
if arg.class == Hash
|
|
10
|
+
return arg.keys.sort_by{|a|a.to_s}.collect { |k| "%s_%s" % [k.to_s, flatten(arg[k])] }.join("_").gsub(" ", "_")
|
|
11
|
+
end
|
|
12
|
+
arg.to_s
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# reads xml fixture file instead of hitting up the internets
|
|
16
|
+
def request(resource, method = "get", args = {}, sign_request=false)
|
|
17
|
+
@now_playing_url = 'http://62.216.251.203:80/nowplaying'
|
|
18
|
+
@submission_url = 'http://62.216.251.205:80/protocol_1.2'
|
|
19
|
+
@session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'
|
|
20
|
+
|
|
21
|
+
if @base_url == Rockstar::API_URL + Rockstar::API_VERSION + "/"
|
|
22
|
+
folder, file = resource.downcase.split(".")
|
|
23
|
+
|
|
24
|
+
query = ""
|
|
25
|
+
if args.size > 0
|
|
26
|
+
query = "_" + flatten(args)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
file = File.dirname(__FILE__) + "/../fixtures/xml/#{folder}/#{file}#{query}.xml"
|
|
30
|
+
|
|
31
|
+
if (!File.exists? file)
|
|
32
|
+
puts "Mock file not found : #{file}"
|
|
33
|
+
else
|
|
34
|
+
File.read(file)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
elsif @base_url == Rockstar::AUTH_URL
|
|
38
|
+
# Test Simple Auth
|
|
39
|
+
if args[:hs] == "true" && args[:p] == Rockstar::AUTH_VER.to_s && args[:c] == 'rck' &&
|
|
40
|
+
args[:v] == Rockstar::Version.to_s && args[:u] == 'chunky' && !args[:t].blank?
|
|
41
|
+
|
|
42
|
+
"OK\n#{@session_id}\n#{@now_playing_url}\n#{@submission_url}"
|
|
43
|
+
|
|
44
|
+
# Test Token Auth
|
|
45
|
+
elsif args[:u]=="chunky" && args[:a]==Digest::MD5.hexdigest("secret#{Time.now.to_i}") && args[:v]=="0.3.0" &&
|
|
46
|
+
args[:c]=="rck" && args[:sk]=="bacon" && args[:hs]=="true" &&
|
|
47
|
+
args[:p]=="1.2.1" && args[:t]==Time.now.to_i.to_s
|
|
48
|
+
|
|
49
|
+
"OK\n#{@session_id}\n#{@now_playing_url}\n#{@submission_url}"
|
|
50
|
+
else
|
|
51
|
+
puts "WRONG!!"
|
|
52
|
+
end
|
|
53
|
+
elsif @base_url == @now_playing_url
|
|
54
|
+
if args[:s] == @session_id && args.length == 7 && ![args[:a], args[:t], args[:b], args[:n]].any?(&:blank?)
|
|
55
|
+
'OK'
|
|
56
|
+
end
|
|
57
|
+
elsif @base_url == @submission_url
|
|
58
|
+
if args[:s] == @session_id && args.length == 10 &&
|
|
59
|
+
![args['a[0]'], args['t[0]'], args['i[0]'], args['o[0]'], args['l[0]'], args['b[0]']].any?(&:blank?)
|
|
60
|
+
'OK'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
|
|
3
|
+
require File.expand_path('../../lib/rockstar', __FILE__)
|
|
4
|
+
require File.expand_path('..//mocks/rest', __FILE__)
|
|
5
|
+
|
|
6
|
+
class << Test::Unit::TestCase
|
|
7
|
+
def test(name, &block)
|
|
8
|
+
test_name = :"test_#{name.gsub(' ','_')}"
|
|
9
|
+
raise ArgumentError, "#{test_name} is already defined" if self.instance_methods.include? test_name.to_s
|
|
10
|
+
define_method test_name, &block
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def expect(expected_value, &block)
|
|
14
|
+
define_method :"test_#{caller.first.split("/").last}" do
|
|
15
|
+
assert_equal expected_value, instance_eval(&block)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require File.expand_path('../../test_helper.rb', __FILE__)
|
|
2
|
+
|
|
3
|
+
class TestAlbum < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@album = Rockstar::Album.new('Carrie Underwood', 'Some Hearts')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
test 'should require the artist name' do
|
|
9
|
+
assert_raises(ArgumentError) { Rockstar::Album.new('', 'Some Hearts') }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
test 'should require the track name' do
|
|
13
|
+
assert_raises(ArgumentError) { Rockstar::Album.new('Carrie Underwood', '') }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
test 'should know the artist' do
|
|
17
|
+
assert_equal('Carrie Underwood', @album.artist)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test "should know it's name" do
|
|
21
|
+
assert_equal('Some Hearts', @album.name)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test 'should be able to load album info' do
|
|
25
|
+
@album.load_info
|
|
26
|
+
assert_equal('http://www.last.fm/music/Carrie+Underwood/Some+Hearts', @album.url)
|
|
27
|
+
assert_equal(Time.mktime(2005, 11, 15, 00, 00, 00), @album.release_date)
|
|
28
|
+
assert_match(/debut album from fourth-season American Idol winner/, @album.summary)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
test 'should be able to find an ablum' do
|
|
32
|
+
album = Rockstar::Album.find('Carrie Underwood', 'Some Hearts')
|
|
33
|
+
assert_equal('Carrie Underwood', album.artist)
|
|
34
|
+
assert_equal('Some Hearts', album.name)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
test "should be able to find an ablum and load the album's info" do
|
|
38
|
+
album = Rockstar::Album.find('Carrie Underwood', 'Some Hearts', :include_info => true)
|
|
39
|
+
assert_equal('Carrie Underwood', album.artist)
|
|
40
|
+
assert_equal('Some Hearts', album.name)
|
|
41
|
+
assert_equal('http://www.last.fm/music/Carrie+Underwood/Some+Hearts', album.url)
|
|
42
|
+
assert_equal(Time.mktime(2005, 11, 15, 00, 00, 00), album.release_date)
|
|
43
|
+
assert_match(/debut album from fourth-season American Idol winner/, album.summary)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
test "should be able to request detailed album info on initialize" do
|
|
47
|
+
album = Rockstar::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)
|
|
48
|
+
assert_equal('Carrie Underwood', album.artist)
|
|
49
|
+
assert_equal('Some Hearts', album.name)
|
|
50
|
+
assert_equal('http://www.last.fm/music/Carrie+Underwood/Some+Hearts', album.url)
|
|
51
|
+
assert_equal(Time.mktime(2005, 11, 15, 00, 00, 00), album.release_date)
|
|
52
|
+
assert_match(/debut album from fourth-season American Idol winner/, album.summary)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
test 'should have an image method that accepts a type' do
|
|
56
|
+
@album.load_info
|
|
57
|
+
assert_equal('http://userserve-ak.last.fm/serve/34s/34894445.png', @album.image(:small))
|
|
58
|
+
assert_equal('http://userserve-ak.last.fm/serve/64s/34894445.png', @album.image(:medium))
|
|
59
|
+
assert_equal('http://userserve-ak.last.fm/serve/174s/34894445.png', @album.image(:large))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
test "should raise an argument error when attempting to get an image that doesn't exist" do
|
|
63
|
+
@album.load_info
|
|
64
|
+
assert_raises(ArgumentError) { @album.image(:fake) }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
test 'should load info when trying to access an image if the info has not been loaded' do
|
|
68
|
+
assert_equal('http://userserve-ak.last.fm/serve/34s/34894445.png', @album.image(:small))
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
test 'should parse empty album' do
|
|
72
|
+
album = Rockstar::Album.new('Thievery Corporation', 'Radio Retalation')
|
|
73
|
+
album.load_info
|
|
74
|
+
assert_nil album.summary
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require File.expand_path('../../test_helper.rb', __FILE__)
|
|
2
|
+
|
|
3
|
+
class TestArtist < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@artist = Rockstar::Artist.new('Metallica')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test 'should require name' do
|
|
10
|
+
assert_raises(ArgumentError) { Rockstar::Artist.new('') }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
test "should know it's name" do
|
|
14
|
+
assert_equal('Metallica', @artist.name)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test "should be able to load artist info" do
|
|
18
|
+
@artist.load_info
|
|
19
|
+
assert_equal("http://www.last.fm/music/Metallica", @artist.url)
|
|
20
|
+
assert_equal("65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab", @artist.mbid)
|
|
21
|
+
assert_match(/an American metal band formed in 1981/, @artist.summary)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test "should load artist info when initialized" do
|
|
25
|
+
artist = Rockstar::Artist.new("Metallica", :include_info => true)
|
|
26
|
+
assert_equal("http://www.last.fm/music/Metallica", artist.url)
|
|
27
|
+
assert_equal("65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab", artist.mbid)
|
|
28
|
+
assert_match(/an American metal band formed in 1981/, artist.summary)
|
|
29
|
+
assert_equal("http://userserve-ak.last.fm/serve/64/3679639.jpg", artist.images['medium'])
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test 'should return the default artist profile image' do
|
|
33
|
+
assert_equal("http://userserve-ak.last.fm/serve/64/3679639.jpg", @artist.image)
|
|
34
|
+
assert_equal("http://userserve-ak.last.fm/serve/126/3679639.jpg", @artist.image(:large))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
test 'should load additional user images' do
|
|
38
|
+
images = @artist.user_images(:page => 2)
|
|
39
|
+
assert_equal("http://userserve-ak.last.fm/serve/126/3679639.jpg", images[0]['large'])
|
|
40
|
+
assert_equal("http://userserve-ak.last.fm/serve/252/13440.jpg", images[1]['extralarge'])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
test 'should be able to find similar artists' do
|
|
44
|
+
assert_equal(["Megadeth", "Slayer", "Iron Maiden", "Pantera", "Anthrax", "Sepultura"], @artist.similar.collect(&:name)[0..5])
|
|
45
|
+
first = @artist.similar.first
|
|
46
|
+
assert_equal('Megadeth', first.name)
|
|
47
|
+
assert_equal('a9044915-8be3-4c7e-b11f-9e2d2ea0a91e', first.mbid)
|
|
48
|
+
assert_equal('1', first.match)
|
|
49
|
+
assert_equal('http://www.last.fm/music/Megadeth', first.url)
|
|
50
|
+
assert_equal('http://userserve-ak.last.fm/serve/34/598154.jpg', first.thumbnail)
|
|
51
|
+
assert_equal('http://userserve-ak.last.fm/serve/64/598154.jpg', first.image)
|
|
52
|
+
assert_equal('http://userserve-ak.last.fm/serve/126/598154.jpg', first.images['large'])
|
|
53
|
+
assert_equal('yes', first.streamable)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
test 'should be able to find top fans' do
|
|
57
|
+
assert_equal(["yIIyIIyIIy", "eliteveritas", "BrandonUCD", "Mithrandir93"], @artist.top_fans.collect(&:username)[0..3])
|
|
58
|
+
first = @artist.top_fans.first
|
|
59
|
+
assert_equal('yIIyIIyIIy', first.username)
|
|
60
|
+
assert_equal('http://www.last.fm/user/yIIyIIyIIy', first.url)
|
|
61
|
+
assert_equal('http://userserve-ak.last.fm/serve/34/40197285.jpg', first.avatar)
|
|
62
|
+
assert_equal('http://userserve-ak.last.fm/serve/34/40197285.jpg', first.images['small'])
|
|
63
|
+
assert_equal('http://userserve-ak.last.fm/serve/64/40197285.jpg', first.images['medium'])
|
|
64
|
+
assert_equal('http://userserve-ak.last.fm/serve/126/40197285.jpg', first.images['large'])
|
|
65
|
+
assert_equal('http://userserve-ak.last.fm/serve/252/40197285.jpg', first.images['extralarge'])
|
|
66
|
+
assert_equal('707560000', first.weight)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
test 'should be able to find top tracks' do
|
|
70
|
+
assert_equal(['Nothing Else Matters', 'Enter Sandman', 'One', 'Master Of Puppets'], @artist.top_tracks.collect(&:name)[0..3])
|
|
71
|
+
first = @artist.top_tracks.first
|
|
72
|
+
assert_equal('Nothing Else Matters', first.name)
|
|
73
|
+
assert_equal('', first.mbid)
|
|
74
|
+
assert_equal('http://www.last.fm/music/Metallica/_/Nothing+Else+Matters', first.url)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
test 'should be able to find top albums' do
|
|
78
|
+
assert_equal(["Master Of Puppets", "Death Magnetic", "Ride The Lightning"], @artist.top_albums.collect(&:name)[0..2])
|
|
79
|
+
first = @artist.top_albums.first
|
|
80
|
+
assert_equal('Master Of Puppets', first.name)
|
|
81
|
+
assert_equal('fed37cfc-2a6d-4569-9ac0-501a7c7598eb', first.mbid)
|
|
82
|
+
assert_equal('http://www.last.fm/music/Metallica/Master+Of+Puppets', first.url)
|
|
83
|
+
assert_equal('http://userserve-ak.last.fm/serve/34s/8622967.jpg', first.image(:small))
|
|
84
|
+
assert_equal('http://userserve-ak.last.fm/serve/64s/8622967.jpg', first.image(:medium))
|
|
85
|
+
assert_equal('http://userserve-ak.last.fm/serve/126/8622967.jpg', first.image(:large))
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
test 'should be able to find top tags' do
|
|
89
|
+
assert_equal(['thrash metal', 'metal', 'heavy metal'], @artist.top_tags.collect(&:name)[0..2])
|
|
90
|
+
first = @artist.top_tags.first
|
|
91
|
+
assert_equal('thrash metal', first.name)
|
|
92
|
+
assert_equal('100', first.count)
|
|
93
|
+
assert_equal('http://www.last.fm/tag/thrash%20metal', first.url)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
test 'should be able to find upcoming events' do
|
|
97
|
+
events = @artist.events
|
|
98
|
+
assert_equal(14, events.length)
|
|
99
|
+
assert_equal('The Big Four - Metallica, Slayer, Megadeth, Anthrax', events.first.title)
|
|
100
|
+
assert_equal('07/02/11', events.first.start_date.strftime("%D"))
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require File.expand_path('../../test_helper.rb', __FILE__)
|
|
2
|
+
|
|
3
|
+
class TestChart < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@chart = Rockstar::Chart.new('1108296002', '1108900802')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test 'should require from' do
|
|
10
|
+
assert_raise(ArgumentError) { Rockstar::Chart.new('', '1108900802') }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
test 'should require to' do
|
|
14
|
+
assert_raise(ArgumentError) { Rockstar::Chart.new('1108296002', '') }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test 'should be able to parse to and from that are unix timestamp strings' do
|
|
18
|
+
chart = Rockstar::Chart.new('1108296002', '1108900802')
|
|
19
|
+
assert_equal(1108296002, chart.from)
|
|
20
|
+
assert_equal(1108900802, chart.to)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test 'should be able to parse to and from that are unix timestamp fixnums' do
|
|
24
|
+
chart = Rockstar::Chart.new(1108296002, 1108900802)
|
|
25
|
+
assert_equal(1108296002, chart.from)
|
|
26
|
+
assert_equal(1108900802, chart.to)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test 'should be able to parse to and from that are times' do
|
|
30
|
+
chart = Rockstar::Chart.new(Time.at(1108296002), Time.at(1108900802))
|
|
31
|
+
assert_equal(1108296002, chart.from)
|
|
32
|
+
assert_equal(1108900802, chart.to)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.expand_path('../../test_helper.rb', __FILE__)
|
|
2
|
+
|
|
3
|
+
class TestGeo < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
test "should get events in london" do
|
|
6
|
+
geo = Rockstar::Geo.new
|
|
7
|
+
events = geo.events({:location => 'london'})
|
|
8
|
+
|
|
9
|
+
assert_equal(10, events.size)
|
|
10
|
+
assert_equal("Basement Scam", events.first.title)
|
|
11
|
+
assert_equal("Buffalo Bar", events.first.venue.name)
|
|
12
|
+
assert_equal("London", events.first.venue.city)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test "get cities for a country" do
|
|
16
|
+
geo = Rockstar::Geo.new
|
|
17
|
+
|
|
18
|
+
metros = geo.metros("germany")
|
|
19
|
+
assert_equal(10, metros.size)
|
|
20
|
+
assert_equal("Bremen", metros.first.name)
|
|
21
|
+
assert_equal("Germany", metros.first.country)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require File.expand_path('../../test_helper.rb', __FILE__)
|
|
2
|
+
|
|
3
|
+
class TestPlaying < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'
|
|
7
|
+
@now_playing_url = 'http://62.216.251.203:80/nowplaying'
|
|
8
|
+
@artist = 'Anberlin'
|
|
9
|
+
@track = 'A Day Late'
|
|
10
|
+
@album = 'Never Take Friendship Personal'
|
|
11
|
+
|
|
12
|
+
@playing = Rockstar::Playing.new(:session_id => @session_id, :now_playing_url => @now_playing_url,
|
|
13
|
+
:artist => @artist, :track => @track, :album => @album, :length => 214,
|
|
14
|
+
:track_number => 5)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test 'should require a session id' do
|
|
18
|
+
assert_raises(ArgumentError) { Rockstar::Playing.new(
|
|
19
|
+
:now_playing_url => @now_playing_url, :artist => @artist, :track => @track,
|
|
20
|
+
:album => @album, :length => 214, :track_number => 5) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test 'should require a now playing url' do
|
|
24
|
+
assert_raises(ArgumentError) { Rockstar::Playing.new(
|
|
25
|
+
:session_id => @session_id, :artist => @artist, :track => @track,
|
|
26
|
+
:album => @album, :length => 214, :track_number => 5) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test 'should require an artist' do
|
|
30
|
+
assert_raises(ArgumentError) { Rockstar::Playing.new(
|
|
31
|
+
:session_id => @session_id, :now_playing_url => @now_playing_url,
|
|
32
|
+
:track => @track, :album => @album, :length => 214, :track_number => 5) }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
test 'should require a track' do
|
|
36
|
+
assert_raises(ArgumentError) { Rockstar::Playing.new(
|
|
37
|
+
:session_id => @session_id, :now_playing_url => @now_playing_url,
|
|
38
|
+
:artist => @artist, :album => @album, :length => 214, :track_number => 5) }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test 'should require a length greater than 30 seconds' do
|
|
42
|
+
assert_raises(ArgumentError) { Rockstar::Playing.new(
|
|
43
|
+
:session_id => @session_id, :now_playing_url => @now_playing_url,
|
|
44
|
+
:artist => @artist, :track => @track, :album => @album, :length => 29,
|
|
45
|
+
:track_number => 5) }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
test 'should submit successfully' do
|
|
49
|
+
@playing.submit!
|
|
50
|
+
assert_equal('OK', @playing.status)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|