scrobbler 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,3 @@
1
+ * v 0.2.2: a bunch of changes from titanous, mostly refactoring
1
2
  * v 0.2.0: added support for scrobbling tracks and now playing submission (Titanous)
2
3
  * v 0.1.0: initial release
data/Manifest CHANGED
@@ -21,7 +21,7 @@ lib/scrobbler.rb
21
21
  Manifest
22
22
  MIT-LICENSE
23
23
  Rakefile
24
- README.txt
24
+ README.rdoc
25
25
  scrobbler.gemspec
26
26
  setup.rb
27
27
  test/fixtures/xml/album/info.xml
@@ -59,8 +59,9 @@ test/test_helper.rb
59
59
  test/unit/album_test.rb
60
60
  test/unit/artist_test.rb
61
61
  test/unit/chart_test.rb
62
+ test/unit/playing_test.rb
63
+ test/unit/scrobble_test.rb
64
+ test/unit/simpleauth_test.rb
62
65
  test/unit/tag_test.rb
63
66
  test/unit/track_test.rb
64
67
  test/unit/user_test.rb
65
- website/css/common.css
66
- website/index.html
File without changes
data/Rakefile CHANGED
@@ -7,13 +7,14 @@ require 'lib/scrobbler/version'
7
7
  WEBSITE_PATH = 'jnunemaker@rubyforge.org:/var/www/gforge-projects/scrobbler'
8
8
 
9
9
  Echoe.new('scrobbler', Scrobbler::Version) do |p|
10
- p.description = "wrapper for audioscrobbler (last.fm) web services"
11
- p.url = "http://scrobbler.rubyforge.org"
12
- p.author = "John Nunemaker"
13
- p.email = "nunemaker@gmail.com"
14
- p.extra_deps = [['hpricot', '>=0.4.86'], ['activesupport', '>=1.4.2']]
15
- p.need_tar_gz = false
16
- p.docs_host = WEBSITE_PATH
10
+ p.description = "wrapper for audioscrobbler (last.fm) web services"
11
+ p.url = "http://scrobbler.rubyforge.org"
12
+ p.author = ['John Nunemaker', 'Jonathan Rudenberg']
13
+ p.email = "nunemaker@gmail.com"
14
+ p.extra_deps = [['hpricot', '>=0.4.86'], ['activesupport', '>=1.4.2']]
15
+ p.need_tar_gz = false
16
+ p.docs_host = WEBSITE_PATH
17
+ p.ignore_pattern = /website/
17
18
  end
18
19
 
19
20
  desc 'Upload website files to rubyforge'
@@ -12,7 +12,7 @@ scrobble = Scrobbler::Scrobble.new(:session_id => auth.session_id,
12
12
  :submission_url => auth.submission_url,
13
13
  :artist => 'Coldplay',
14
14
  :track => 'Viva La Vida',
15
- :album => "Viva La Vida",
15
+ :album => 'Viva La Vida',
16
16
  :time => Time.new,
17
17
  :length => 244,
18
18
  :track_number => 7)
@@ -16,7 +16,7 @@ module Scrobbler
16
16
  @track_number = args[:track_number] || '' # track number (optional)
17
17
  @mb_track_id = args[:mb_track_id] || '' # MusicBrainz track ID (optional)
18
18
 
19
- if [@session_id, @now_playing_url, @artist, @track].any?(&:empty?)
19
+ if [@session_id, @now_playing_url, @artist, @track].any?(&:blank?)
20
20
  raise ArgumentError, 'Missing required argument'
21
21
  elsif !@length.to_s.empty? && @length.to_i <= 30 # see last.fm/api
22
22
  raise ArgumentError, 'Length must be greater than 30 seconds'
@@ -22,15 +22,15 @@ module Scrobbler
22
22
  @track_number = args[:track_number] || '' # track number (optional)
23
23
  @mb_track_id = args[:mb_track_id] || '' # MusicBrainz track ID (optional)
24
24
 
25
- if [@session_id, @submission_url, @artist, @track].any?(&:empty?)
25
+ if [@session_id, @submission_url, @artist, @track].any?(&:blank?)
26
26
  raise ArgumentError, 'Missing required argument'
27
27
  elsif @time.class.to_s != 'Time'
28
28
  raise ArgumentError, ":time must be a Time object"
29
29
  elsif !['P','R','E','U'].include?(@source) # see last.fm/api/submissions#subs
30
30
  raise ArgumentError, "Invalid source"
31
- elsif @source == 'P' && @length.empty? # length is not optional if source is P
31
+ elsif @source == 'P' && @length.blank? # length is not optional if source is P
32
32
  raise ArgumentError, 'Length must be set'
33
- elsif !@length.empty? && @length.to_i <= 30 # see last.fm/api/submissions#subs
33
+ elsif !@length.blank? && @length.to_i <= 30 # see last.fm/api/submissions#subs
34
34
  raise ArgumentError, 'Length must be greater than 30 seconds'
35
35
  end
36
36
 
@@ -43,7 +43,7 @@ module Scrobbler
43
43
  't[0]' => @track,
44
44
  'i[0]' => @time.utc.to_i,
45
45
  'o[0]' => @source,
46
- 'r[0]' => @rating,
46
+ 'r[0]' => '',
47
47
  'l[0]' => @length,
48
48
  'b[0]' => @album,
49
49
  'n[0]' => @track_number,
@@ -40,7 +40,7 @@ module Scrobbler
40
40
  result = @connection.get('/', query)
41
41
 
42
42
  @status = result.split(/\n/)[0]
43
- case @status
43
+ case @status
44
44
  when /OK/
45
45
  @session_id, @now_playing_url, @submission_url = result.split(/\n/)[1,3]
46
46
  when /BANNED/
@@ -1,3 +1,3 @@
1
1
  module Scrobbler
2
- Version = '0.2.1'
2
+ Version = '0.2.2'
3
3
  end
@@ -2,23 +2,23 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{scrobbler}
5
- s.version = "0.2.1"
5
+ s.version = "0.2.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["John Nunemaker"]
9
- s.date = %q{2008-12-03}
8
+ s.authors = ["John Nunemaker, Jonathan Rudenberg"]
9
+ s.date = %q{2008-12-23}
10
10
  s.description = %q{wrapper for audioscrobbler (last.fm) web services}
11
11
  s.email = %q{nunemaker@gmail.com}
12
- s.extra_rdoc_files = ["lib/scrobbler/album.rb", "lib/scrobbler/artist.rb", "lib/scrobbler/base.rb", "lib/scrobbler/chart.rb", "lib/scrobbler/playing.rb", "lib/scrobbler/rest.rb", "lib/scrobbler/scrobble.rb", "lib/scrobbler/simpleauth.rb", "lib/scrobbler/tag.rb", "lib/scrobbler/track.rb", "lib/scrobbler/user.rb", "lib/scrobbler/version.rb", "lib/scrobbler.rb", "README.txt"]
13
- s.files = ["examples/album.rb", "examples/artist.rb", "examples/scrobble.rb", "examples/tag.rb", "examples/track.rb", "examples/user.rb", "History.txt", "lib/scrobbler/album.rb", "lib/scrobbler/artist.rb", "lib/scrobbler/base.rb", "lib/scrobbler/chart.rb", "lib/scrobbler/playing.rb", "lib/scrobbler/rest.rb", "lib/scrobbler/scrobble.rb", "lib/scrobbler/simpleauth.rb", "lib/scrobbler/tag.rb", "lib/scrobbler/track.rb", "lib/scrobbler/user.rb", "lib/scrobbler/version.rb", "lib/scrobbler.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README.txt", "scrobbler.gemspec", "setup.rb", "test/fixtures/xml/album/info.xml", "test/fixtures/xml/artist/fans.xml", "test/fixtures/xml/artist/similar.xml", "test/fixtures/xml/artist/topalbums.xml", "test/fixtures/xml/artist/toptags.xml", "test/fixtures/xml/artist/toptracks.xml", "test/fixtures/xml/tag/topalbums.xml", "test/fixtures/xml/tag/topartists.xml", "test/fixtures/xml/tag/toptags.xml", "test/fixtures/xml/tag/toptracks.xml", "test/fixtures/xml/track/fans.xml", "test/fixtures/xml/track/toptags.xml", "test/fixtures/xml/user/friends.xml", "test/fixtures/xml/user/neighbours.xml", "test/fixtures/xml/user/profile.xml", "test/fixtures/xml/user/recentbannedtracks.xml", "test/fixtures/xml/user/recentlovedtracks.xml", "test/fixtures/xml/user/recenttracks.xml", "test/fixtures/xml/user/systemrecs.xml", "test/fixtures/xml/user/topalbums.xml", "test/fixtures/xml/user/topartists.xml", "test/fixtures/xml/user/toptags.xml", "test/fixtures/xml/user/toptracks.xml", "test/fixtures/xml/user/weeklyalbumchart.xml", "test/fixtures/xml/user/weeklyalbumchart_from_1138536002_to_1139140802.xml", "test/fixtures/xml/user/weeklyartistchart.xml", "test/fixtures/xml/user/weeklyartistchart_from_1138536002_to_1139140802.xml", "test/fixtures/xml/user/weeklychartlist.xml", "test/fixtures/xml/user/weeklytrackchart.xml", "test/fixtures/xml/user/weeklytrackchart_from_1138536002_to_1139140802.xml", "test/mocks/rest.rb", "test/test_helper.rb", "test/unit/album_test.rb", "test/unit/artist_test.rb", "test/unit/chart_test.rb", "test/unit/tag_test.rb", "test/unit/track_test.rb", "test/unit/user_test.rb", "website/css/common.css", "website/index.html"]
12
+ s.extra_rdoc_files = ["lib/scrobbler/album.rb", "lib/scrobbler/artist.rb", "lib/scrobbler/base.rb", "lib/scrobbler/chart.rb", "lib/scrobbler/playing.rb", "lib/scrobbler/rest.rb", "lib/scrobbler/scrobble.rb", "lib/scrobbler/simpleauth.rb", "lib/scrobbler/tag.rb", "lib/scrobbler/track.rb", "lib/scrobbler/user.rb", "lib/scrobbler/version.rb", "lib/scrobbler.rb", "README.rdoc"]
13
+ s.files = ["examples/album.rb", "examples/artist.rb", "examples/scrobble.rb", "examples/tag.rb", "examples/track.rb", "examples/user.rb", "History.txt", "lib/scrobbler/album.rb", "lib/scrobbler/artist.rb", "lib/scrobbler/base.rb", "lib/scrobbler/chart.rb", "lib/scrobbler/playing.rb", "lib/scrobbler/rest.rb", "lib/scrobbler/scrobble.rb", "lib/scrobbler/simpleauth.rb", "lib/scrobbler/tag.rb", "lib/scrobbler/track.rb", "lib/scrobbler/user.rb", "lib/scrobbler/version.rb", "lib/scrobbler.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README.rdoc", "scrobbler.gemspec", "setup.rb", "test/fixtures/xml/album/info.xml", "test/fixtures/xml/artist/fans.xml", "test/fixtures/xml/artist/similar.xml", "test/fixtures/xml/artist/topalbums.xml", "test/fixtures/xml/artist/toptags.xml", "test/fixtures/xml/artist/toptracks.xml", "test/fixtures/xml/tag/topalbums.xml", "test/fixtures/xml/tag/topartists.xml", "test/fixtures/xml/tag/toptags.xml", "test/fixtures/xml/tag/toptracks.xml", "test/fixtures/xml/track/fans.xml", "test/fixtures/xml/track/toptags.xml", "test/fixtures/xml/user/friends.xml", "test/fixtures/xml/user/neighbours.xml", "test/fixtures/xml/user/profile.xml", "test/fixtures/xml/user/recentbannedtracks.xml", "test/fixtures/xml/user/recentlovedtracks.xml", "test/fixtures/xml/user/recenttracks.xml", "test/fixtures/xml/user/systemrecs.xml", "test/fixtures/xml/user/topalbums.xml", "test/fixtures/xml/user/topartists.xml", "test/fixtures/xml/user/toptags.xml", "test/fixtures/xml/user/toptracks.xml", "test/fixtures/xml/user/weeklyalbumchart.xml", "test/fixtures/xml/user/weeklyalbumchart_from_1138536002_to_1139140802.xml", "test/fixtures/xml/user/weeklyartistchart.xml", "test/fixtures/xml/user/weeklyartistchart_from_1138536002_to_1139140802.xml", "test/fixtures/xml/user/weeklychartlist.xml", "test/fixtures/xml/user/weeklytrackchart.xml", "test/fixtures/xml/user/weeklytrackchart_from_1138536002_to_1139140802.xml", "test/mocks/rest.rb", "test/test_helper.rb", "test/unit/album_test.rb", "test/unit/artist_test.rb", "test/unit/chart_test.rb", "test/unit/playing_test.rb", "test/unit/scrobble_test.rb", "test/unit/simpleauth_test.rb", "test/unit/tag_test.rb", "test/unit/track_test.rb", "test/unit/user_test.rb"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://scrobbler.rubyforge.org}
16
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Scrobbler", "--main", "README.txt"]
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Scrobbler", "--main", "README.rdoc"]
17
17
  s.require_paths = ["lib"]
18
18
  s.rubyforge_project = %q{scrobbler}
19
19
  s.rubygems_version = %q{1.3.1}
20
20
  s.summary = %q{wrapper for audioscrobbler (last.fm) web services}
21
- s.test_files = ["test/test_helper.rb", "test/unit/album_test.rb", "test/unit/artist_test.rb", "test/unit/chart_test.rb", "test/unit/tag_test.rb", "test/unit/track_test.rb", "test/unit/user_test.rb"]
21
+ s.test_files = ["test/test_helper.rb", "test/unit/album_test.rb", "test/unit/artist_test.rb", "test/unit/chart_test.rb", "test/unit/playing_test.rb", "test/unit/scrobble_test.rb", "test/unit/simpleauth_test.rb", "test/unit/tag_test.rb", "test/unit/track_test.rb", "test/unit/user_test.rb"]
22
22
 
23
23
  if s.respond_to? :specification_version then
24
24
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -1,25 +1,49 @@
1
1
  require File.dirname(__FILE__) + '/../../lib/scrobbler/rest'
2
+ require 'digest/md5'
2
3
 
3
4
  module Scrobbler
4
5
  module REST
5
6
  class Connection
6
7
  # reads xml fixture file instead of hitting up the internets
7
8
  def request(resource, method = "get", args = nil)
8
- pieces = resource.split('/')
9
- pieces.shift
10
- pieces.shift
11
- folder = pieces.shift
12
- file = pieces.last[0, pieces.last.index('.xml')]
13
- base_pieces = pieces.last.split('?')
9
+ @now_playing_url = 'http://62.216.251.203:80/nowplaying'
10
+ @submission_url = 'http://62.216.251.205:80/protocol_1.2'
11
+ @session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'
14
12
 
15
- file = if base_pieces.size > 1
16
- # if query string params are in resource they are underscore separated for filenames
17
- base_pieces.last.split('&').inject("#{file}_") { |str, pair| str << pair.split('=').join('_') + '_'; str }.chop!
18
- else
19
- file
20
- end
13
+ if @base_url == Scrobbler::API_URL
14
+ pieces = resource.split('/')
15
+ pieces.shift
16
+ pieces.shift
17
+ folder = pieces.shift
18
+ file = pieces.last[0, pieces.last.index('.xml')]
19
+ base_pieces = pieces.last.split('?')
21
20
 
22
- File.read(File.dirname(__FILE__) + "/../fixtures/xml/#{folder}/#{file}.xml")
21
+ file = if base_pieces.size > 1
22
+ # if query string params are in resource they are underscore separated for filenames
23
+ base_pieces.last.split('&').inject("#{file}_") { |str, pair| str << pair.split('=').join('_') + '_'; str }.chop!
24
+ else
25
+ file
26
+ end
27
+
28
+ File.read(File.dirname(__FILE__) + "/../fixtures/xml/#{folder}/#{file}.xml")
29
+ elsif @base_url == Scrobbler::AUTH_URL
30
+ if args[:hs] == "true" && args[:p] == Scrobbler::AUTH_VER.to_s && args[:c] == 'rbs' &&
31
+ args[:v] == Scrobbler::Version.to_s && args[:u] == 'chunky' && !args[:t].blank? &&
32
+ args[:a] == Digest::MD5.hexdigest('7813258ef8c6b632dde8cc80f6bda62f' + args[:t])
33
+
34
+ "OK\n#{@session_id}\n#{@now_playing_url}\n#{@submission_url}"
35
+ end
36
+ elsif @base_url == @now_playing_url
37
+ if args[:s] == @session_id && ![args[:a], args[:t], args[:b], args[:n]].any?(&:blank?)
38
+ 'OK'
39
+ end
40
+ elsif @base_url == @submission_url
41
+ if args[:s] == @session_id &&
42
+ ![args['a[0]'], args['t[0]'], args['i[0]'], args['o[0]'], args['l[0]'], args['b[0]']].any?(&:blank?)
43
+ 'OK'
44
+ end
45
+ end
46
+
23
47
  end
24
48
  end
25
49
  end
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
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 = Scrobbler::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) { Scrobbler::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) { Scrobbler::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) { Scrobbler::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) { Scrobbler::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) { Scrobbler::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
@@ -0,0 +1,69 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class TestScrobble < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @session_id = '17E61E13454CDD8B68E8D7DEEEDF6170'
7
+ @submission_url = 'http://62.216.251.205:80/protocol_1.2'
8
+ @artist = 'Coldplay'
9
+ @name = 'Viva La Vida'
10
+
11
+ @scrobble = Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
12
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
13
+ :length => 244, :track_number => 7)
14
+ end
15
+
16
+ test 'should require a session id' do
17
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:submission_url => @submission_url,
18
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
19
+ :length => 244, :track_number => 7) }
20
+ end
21
+
22
+ test 'should require a submission url' do
23
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id,
24
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
25
+ :length => 244, :track_number => 7) }
26
+ end
27
+
28
+ test 'should require an artist' do
29
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
30
+ :track => @name, :album => @name, :time => Time.new,
31
+ :length => 244, :track_number => 7) }
32
+ end
33
+
34
+ test 'should require a track' do
35
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
36
+ :artist => @artist, :album => @name, :time => Time.new,
37
+ :length => 244, :track_number => 7) }
38
+ end
39
+
40
+ test 'should require a Time object' do
41
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
42
+ :artist => @artist, :track => @name, :album => @name, :time => 'chunky_bacon',
43
+ :length => 244, :track_number => 7) }
44
+ end
45
+
46
+ test 'should require a valid source' do
47
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
48
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
49
+ :length => 244, :track_number => 7, :source => 'Z') }
50
+ end
51
+
52
+ test 'should require a length if source is set to P' do
53
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
54
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
55
+ :track_number => 7, :source => 'P') }
56
+ end
57
+
58
+ test 'should require a length greater than 30 if source is set to P' do
59
+ assert_raises(ArgumentError) { Scrobbler::Scrobble.new(:session_id => @session_id, :submission_url => @submission_url,
60
+ :artist => @artist, :track => @name, :album => @name, :time => Time.new,
61
+ :length => 29, :track_number => 7, :source => 'P') }
62
+ end
63
+
64
+ test 'should submit successfully' do
65
+ @scrobble.submit!
66
+ assert_equal('OK', @scrobble.status)
67
+ end
68
+
69
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class TestSimpleAuth < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @auth = Scrobbler::SimpleAuth.new(:user => 'chunky', :password => 'bacon')
7
+ end
8
+
9
+ test 'should require a user' do
10
+ assert_raises(ArgumentError) { Scrobbler::SimpleAuth.new(:password => 'bacon') }
11
+ end
12
+
13
+ test 'should require a password' do
14
+ assert_raises(ArgumentError) { Scrobbler::SimpleAuth.new(:user => 'chunky') }
15
+ end
16
+
17
+ test 'should have the right client id' do
18
+ assert_equal('rbs', @auth.client_id)
19
+ end
20
+
21
+ test 'should have the right version' do
22
+ assert_equal(Scrobbler::Version, @auth.client_ver)
23
+ end
24
+
25
+ test 'should handshake successfully' do
26
+ @auth.handshake!
27
+ assert_equal('OK', @auth.status)
28
+ end
29
+
30
+ test 'should get a session id' do
31
+ @auth.handshake!
32
+ assert_equal('17E61E13454CDD8B68E8D7DEEEDF6170', @auth.session_id)
33
+ end
34
+
35
+ test 'should get a now playing url' do
36
+ @auth.handshake!
37
+ assert_equal('http://62.216.251.203:80/nowplaying', @auth.now_playing_url)
38
+ end
39
+
40
+ test 'should get a submission url' do
41
+ @auth.handshake!
42
+ assert_equal('http://62.216.251.205:80/protocol_1.2', @auth.submission_url)
43
+ end
44
+
45
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrobbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
- - John Nunemaker
7
+ - John Nunemaker, Jonathan Rudenberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-03 00:00:00 -05:00
12
+ date: 2008-12-23 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -62,7 +62,7 @@ extra_rdoc_files:
62
62
  - lib/scrobbler/user.rb
63
63
  - lib/scrobbler/version.rb
64
64
  - lib/scrobbler.rb
65
- - README.txt
65
+ - README.rdoc
66
66
  files:
67
67
  - examples/album.rb
68
68
  - examples/artist.rb
@@ -87,7 +87,7 @@ files:
87
87
  - Manifest
88
88
  - MIT-LICENSE
89
89
  - Rakefile
90
- - README.txt
90
+ - README.rdoc
91
91
  - scrobbler.gemspec
92
92
  - setup.rb
93
93
  - test/fixtures/xml/album/info.xml
@@ -125,11 +125,12 @@ files:
125
125
  - test/unit/album_test.rb
126
126
  - test/unit/artist_test.rb
127
127
  - test/unit/chart_test.rb
128
+ - test/unit/playing_test.rb
129
+ - test/unit/scrobble_test.rb
130
+ - test/unit/simpleauth_test.rb
128
131
  - test/unit/tag_test.rb
129
132
  - test/unit/track_test.rb
130
133
  - test/unit/user_test.rb
131
- - website/css/common.css
132
- - website/index.html
133
134
  has_rdoc: true
134
135
  homepage: http://scrobbler.rubyforge.org
135
136
  post_install_message:
@@ -139,7 +140,7 @@ rdoc_options:
139
140
  - --title
140
141
  - Scrobbler
141
142
  - --main
142
- - README.txt
143
+ - README.rdoc
143
144
  require_paths:
144
145
  - lib
145
146
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -166,6 +167,9 @@ test_files:
166
167
  - test/unit/album_test.rb
167
168
  - test/unit/artist_test.rb
168
169
  - test/unit/chart_test.rb
170
+ - test/unit/playing_test.rb
171
+ - test/unit/scrobble_test.rb
172
+ - test/unit/simpleauth_test.rb
169
173
  - test/unit/tag_test.rb
170
174
  - test/unit/track_test.rb
171
175
  - test/unit/user_test.rb
@@ -1,47 +0,0 @@
1
- @media screen, projection {
2
- /*
3
- Copyright (c) 2007, Yahoo! Inc. All rights reserved.
4
- Code licensed under the BSD License:
5
- http://developer.yahoo.net/yui/license.txt
6
- version: 2.2.0
7
- */
8
- body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}
9
- body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}/*ol,ul {list-style:none;}*/caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;}
10
- /* end of yahoo reset and fonts */
11
-
12
- body {color:#333; background:#4b1a1a; line-height:1.3;}
13
- p {margin:0 0 20px;}
14
- a {color:#4b1a1a;}
15
- a:hover {text-decoration:none;}
16
- strong {font-weight:bold;}
17
- em {font-style:italics;}
18
- h1,h2,h3,h4,h5,h6 {font-weight:bold;}
19
- h1 {font-size:197%; margin:30px 0; color:#4b1a1a;}
20
- h2 {font-size:174%; margin:20px 0; color:#b8111a;}
21
- h3 {font-size:152%; margin:10px 0;}
22
- h4 {font-size:129%; margin:10px 0;}
23
- pre {background:#eee; padding:20px; border:1px solid #ccc; font-size:100%; overflow:auto;}
24
- code {font-size:100%; margin:0; padding:0;}
25
- ul, ol {margin:10px 0 10px 25px;}
26
- ol li {margin:0 0 10px;}
27
-
28
-
29
-
30
-
31
-
32
- div#wrapper {background:#fff; width:560px; margin:0 auto; padding:20px; border:10px solid #bc8c46; border-width:0 10px;}
33
- div#header {position:relative; border-bottom:1px dotted; margin:0 0 10px; padding:0 0 10px;}
34
- div#header p {margin:0; padding:0;}
35
- div#header h1 {margin:0; padding:0;}
36
- ul#nav {position:absolute; top:0; right:0; list-style:none; margin:0; padding:0;}
37
- ul#nav li {display:inline; padding:0 0 0 5px;}
38
- ul#nav li a {}
39
- div#content {}
40
- div#footer {margin:40px 0 0; border-top:1px dotted; padding:10px 0 0;}
41
-
42
-
43
-
44
-
45
-
46
-
47
- }
@@ -1,113 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
- <title>Scrobbler by John Nunemaker</title>
6
- <link rel="stylesheet" href="css/common.css" type="text/css" />
7
- </head>
8
- <body>
9
-
10
- <div id="wrapper">
11
- <div id="header">
12
- <h1>Scrobbler</h1>
13
- <p>Get your music on.</p>
14
-
15
- <ul id="nav">
16
- <li><a href="docs/">Docs</a></li>
17
- <li><a href="http://rubyforge.org/projects/scrobbler/">Rubyforge Page</a></li>
18
- </ul>
19
- </div>
20
-
21
- <div id="content">
22
- <p>Scrobbler is a wrapper for the <a href="http://www.audioscrobbler.net/data/webservices/">audioscrobbler (last.fm) web services</a>.</p>
23
-
24
- <h2>Installation</h2>
25
-
26
- <pre><code>$ sudo gem install scrobbler</code></pre>
27
-
28
- <h2>Usage</h2>
29
-
30
- <p>Below is just a sampling of how easy this lib is to use.</p>
31
-
32
- <h3>Users</h3>
33
-
34
- <pre><code class="ruby">user = Scrobbler::User.new('jnunemaker')
35
-
36
- puts "#{user.username}'s Recent Tracks"
37
- puts "=" * (user.username.length + 16)
38
- user.recent_tracks.each { |t| puts t.name }
39
-
40
- puts
41
- puts
42
-
43
- puts "#{user.username}'s Top Tracks"
44
- puts "=" * (user.username.length + 13)
45
- user.top_tracks.each { |t| puts "(#{t.playcount}) #{t.name}" }</code></pre>
46
-
47
- <h3>Albums</h3>
48
-
49
- <pre><code class="ruby">album = Scrobbler::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)
50
-
51
- puts "Album: #{album.name}"
52
- puts "Artist: #{album.artist}"
53
- puts "Reach: #{album.reach}"
54
- puts "URL: #{album.url}"
55
- puts "Release Date: #{album.release_date.strftime('%m/%d/%Y')}"
56
-
57
- puts
58
- puts
59
-
60
- puts "Tracks"
61
- longest_track_name = album.tracks.collect(&:name).sort { |x, y| y.length <=> x.length }.first.length
62
- puts "=" * longest_track_name
63
- album.tracks.each { |t| puts t.name }</code></pre>
64
-
65
- <h3>Artists</h3>
66
-
67
- <pre><code class="ruby">artist = Scrobbler::Artist.new('Carrie Underwood')
68
-
69
- puts 'Top Tracks'
70
- puts "=" * 10
71
- artist.top_tracks.each { |t| puts "(#{t.reach}) #{t.name}" }
72
-
73
- puts
74
-
75
- puts 'Similar Artists'
76
- puts "=" * 15
77
- artist.similar.each { |a| puts "(#{a.match}%) #{a.name}" }</code></pre>
78
-
79
- <h3>Tags</h3>
80
-
81
- <pre><code class="ruby">tag = Scrobbler::Tag.new('country')
82
-
83
- puts 'Top Albums'
84
- tag.top_albums.each { |a| puts "(#{a.count}) #{a.name} by #{a.artist}" }
85
-
86
- puts
87
-
88
- puts 'Top Tracks'
89
- tag.top_tracks.each { |t| puts "(#{t.count}) #{t.name} by #{t.artist}" }</code></pre>
90
-
91
- <h3>Tracks</h3>
92
-
93
- <pre><code class="ruby">track = Scrobbler::Track.new('Carrie Underwood', 'Before He Cheats')
94
- puts 'Fans'
95
- puts "=" * 4
96
- track.fans.each { |u| puts "(#{u.weight}) #{u.username}" }</code></pre>
97
- </div>
98
-
99
- <div id="footer">
100
- <p>Created by <a href="http://addictedtonew.com/about/">John Nunemaker</a></p>
101
- </div>
102
-
103
- </div>
104
-
105
- <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
106
- <script type="text/javascript">_uacct = "UA-85301-11"; urchinTracker();</script>
107
-
108
- <!-- 103bees.com 'bee' code v1.11 - please do not make any changes! -->
109
- <script type="text/javascript" src="http://103bees.com/bees/?bee=3672&amp;fid=6687"></script>
110
- <!-- 103bees.com 'bee' code -->
111
-
112
- </body>
113
- </html>