Permalink
Browse files

initial commit of scrobbler gem

git-svn-id: http://svn.addictedtonew.com/public/gems/scrobbler@61 fe7eae16-9a24-0410-a59d-9e59979e88be
  • Loading branch information...
0 parents commit c13cb006675998dec6b13c90d9a1479b64bb7573 jnunemaker committed May 10, 2007
Showing with 4,658 additions and 0 deletions.
  1. +1 −0 History.txt
  2. +58 −0 Manifest.txt
  3. +71 −0 README.txt
  4. +89 −0 Rakefile
  5. +18 −0 examples/album.rb
  6. +14 −0 examples/artist.rb
  7. +12 −0 examples/tag.rb
  8. +7 −0 examples/track.rb
  9. +15 −0 examples/user.rb
  10. +13 −0 lib/scrobbler.rb
  11. +143 −0 lib/scrobbler/album.rb
  12. +127 −0 lib/scrobbler/artist.rb
  13. +29 −0 lib/scrobbler/base.rb
  14. +31 −0 lib/scrobbler/chart.rb
  15. +47 −0 lib/scrobbler/rest.rb
  16. +104 −0 lib/scrobbler/tag.rb
  17. +96 −0 lib/scrobbler/track.rb
  18. +192 −0 lib/scrobbler/user.rb
  19. +9 −0 lib/scrobbler/version.rb
  20. +1,585 −0 setup.rb
  21. +70 −0 test/fixtures/xml/album/info.xml
  22. +18 −0 test/fixtures/xml/artist/fans.xml
  23. +39 −0 test/fixtures/xml/artist/similar.xml
  24. +36 −0 test/fixtures/xml/artist/topalbums.xml
  25. +18 −0 test/fixtures/xml/artist/toptags.xml
  26. +27 −0 test/fixtures/xml/artist/toptracks.xml
  27. +39 −0 test/fixtures/xml/tag/topalbums.xml
  28. +39 −0 test/fixtures/xml/tag/topartists.xml
  29. +252 −0 test/fixtures/xml/tag/toptags.xml
  30. +30 −0 test/fixtures/xml/tag/toptracks.xml
  31. +28 −0 test/fixtures/xml/track/fans.xml
  32. +33 −0 test/fixtures/xml/track/toptags.xml
  33. +21 −0 test/fixtures/xml/user/friends.xml
  34. +18 −0 test/fixtures/xml/user/neighbours.xml
  35. +12 −0 test/fixtures/xml/user/profile.xml
  36. +24 −0 test/fixtures/xml/user/recentbannedtracks.xml
  37. +24 −0 test/fixtures/xml/user/recentlovedtracks.xml
  38. +27 −0 test/fixtures/xml/user/recenttracks.xml
  39. +18 −0 test/fixtures/xml/user/systemrecs.xml
  40. +42 −0 test/fixtures/xml/user/topalbums.xml
  41. +30 −0 test/fixtures/xml/user/topartists.xml
  42. +18 −0 test/fixtures/xml/user/toptags.xml
  43. +27 −0 test/fixtures/xml/user/toptracks.xml
  44. +35 −0 test/fixtures/xml/user/weeklyalbumchart.xml
  45. +35 −0 test/fixtures/xml/user/weeklyalbumchart_from_1138536002_to_1139140802.xml
  46. +38 −0 test/fixtures/xml/user/weeklyartistchart.xml
  47. +59 −0 test/fixtures/xml/user/weeklyartistchart_from_1138536002_to_1139140802.xml
  48. +74 −0 test/fixtures/xml/user/weeklychartlist.xml
  49. +35 −0 test/fixtures/xml/user/weeklytrackchart.xml
  50. +35 −0 test/fixtures/xml/user/weeklytrackchart_from_1138536002_to_1139140802.xml
  51. +26 −0 test/mocks/rest.rb
  52. +17 −0 test/test_helper.rb
  53. +86 −0 test/unit/album_test.rb
  54. +82 −0 test/unit/artist_test.rb
  55. +34 −0 test/unit/chart_test.rb
  56. +65 −0 test/unit/tag_test.rb
  57. +42 −0 test/unit/track_test.rb
  58. +291 −0 test/unit/user_test.rb
  59. +47 −0 website/css/common.css
  60. +106 −0 website/index.html
@@ -0,0 +1 @@
+* v 0.1.0: initial release
@@ -0,0 +1,58 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+setup.rb
+examples/album.rb
+examples/artist.rb
+examples/tag.rb
+examples/track.rb
+examples/user.rb
+lib/scrobbler.rb
+lib/scrobbler/album.rb
+lib/scrobbler/artist.rb
+lib/scrobbler/base.rb
+lib/scrobbler/chart.rb
+lib/scrobbler/rest.rb
+lib/scrobbler/tag.rb
+lib/scrobbler/track.rb
+lib/scrobbler/user.rb
+lib/scrobbler/version.rb
+test/test_helper.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/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
@@ -0,0 +1,71 @@
+=Scrobbler
+
+Scrobbler is a wrapper for the audioscrobbler web services (http://www.audioscrobbler.net/data/webservices/).
+
+Below is just a sampling of how easy this lib is to use.
+
+== Users
+
+ user = Scrobbler::User.new('jnunemaker')
+
+ puts "#{user.username}'s Recent Tracks"
+ puts "=" * (user.username.length + 16)
+ user.recent_tracks.each { |t| puts t.name }
+
+ puts
+ puts
+
+ puts "#{user.username}'s Top Tracks"
+ puts "=" * (user.username.length + 13)
+ user.top_tracks.each { |t| puts "(#{t.playcount}) #{t.name}" }
+
+== Albums
+
+ album = Scrobbler::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)
+
+ puts "Album: #{album.name}"
+ puts "Artist: #{album.artist}"
+ puts "Reach: #{album.reach}"
+ puts "URL: #{album.url}"
+ puts "Release Date: #{album.release_date.strftime('%m/%d/%Y')}"
+
+ puts
+ puts
+
+ puts "Tracks"
+ longest_track_name = album.tracks.collect(&:name).sort { |x, y| y.length <=> x.length }.first.length
+ puts "=" * longest_track_name
+ album.tracks.each { |t| puts t.name }
+
+==Artists
+
+ artist = Scrobbler::Artist.new('Carrie Underwood')
+
+ puts 'Top Tracks'
+ puts "=" * 10
+ artist.top_tracks.each { |t| puts "(#{t.reach}) #{t.name}" }
+
+ puts
+
+ puts 'Similar Artists'
+ puts "=" * 15
+ artist.similar.each { |a| puts "(#{a.match}%) #{a.name}" }
+
+==Tags
+
+ tag = Scrobbler::Tag.new('country')
+
+ puts 'Top Albums'
+ tag.top_albums.each { |a| puts "(#{a.count}) #{a.name} by #{a.artist}" }
+
+ puts
+
+ puts 'Top Tracks'
+ tag.top_tracks.each { |t| puts "(#{t.count}) #{t.name} by #{t.artist}" }
+
+==Tracks
+
+ track = Scrobbler::Track.new('Carrie Underwood', 'Before He Cheats')
+ puts 'Fans'
+ puts "=" * 4
+ track.fans.each { |u| puts "(#{u.weight}) #{u.username}" }
@@ -0,0 +1,89 @@
+require 'rubygems'
+require 'rake'
+require 'rake/clean'
+require 'rake/testtask'
+require 'rake/packagetask'
+require 'rake/gempackagetask'
+require 'rake/rdoctask'
+require 'rake/contrib/rubyforgepublisher'
+require 'fileutils'
+require 'hoe'
+include FileUtils
+require File.join(File.dirname(__FILE__), 'lib', 'scrobbler', 'version')
+
+AUTHOR = 'nunemaker' # can also be an array of Authors
+EMAIL = "nunemaker@gmail.com"
+DESCRIPTION = "wrapper for audioscrobbler (last.fm) web services"
+GEM_NAME = 'scrobbler' # what ppl will type to install your gem
+RUBYFORGE_PROJECT = 'scrobbler' # The unix name for your project
+HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
+DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
+
+NAME = "scrobbler"
+REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
+VERS = Scrobbler::VERSION::STRING + (REV ? ".#{REV}" : "")
+CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
+RDOC_OPTS = ['--quiet', '--title', 'scrobbler documentation',
+ "--opname", "index.html",
+ "--line-numbers",
+ "--main", "README",
+ "--inline-source"]
+
+class Hoe
+ def extra_deps
+ @extra_deps.reject { |x| Array(x).first == 'hoe' }
+ end
+end
+
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+hoe = Hoe.new(GEM_NAME, VERS) do |p|
+ p.author = AUTHOR
+ p.description = DESCRIPTION
+ p.email = EMAIL
+ p.summary = DESCRIPTION
+ p.url = HOMEPATH
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
+ p.test_globs = ["test/**/test_*.rb"]
+ p.clean_globs = CLEAN #An array of file patterns to delete on clean.
+
+ # == Optional
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
+ p.extra_deps = [['hpricot', '>=0.4.86'], ['activesupport', '>=1.4.2']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
+end
+
+
+desc 'Generate website files'
+task :website_generate do
+ Dir['website/**/*.txt'].each do |txt|
+ sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
+ end
+end
+
+desc 'Upload website files to rubyforge'
+task :website_upload do
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
+ host = "#{config["username"]}@rubyforge.org"
+ remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
+ # remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
+ local_dir = 'website'
+ sh %{rsync -av #{local_dir}/ #{host}:#{remote_dir}}
+end
+
+desc 'Generate and upload website files'
+task :website => [:website_generate, :website_upload]
+
+desc 'Release the website and new gem version'
+task :deploy => [:check_version, :website, :release]
+
+task :check_version do
+ unless ENV['VERSION']
+ puts 'Must pass a VERSION=x.y.z release version'
+ exit
+ end
+ unless ENV['VERSION'] == VERS
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
+ exit
+ end
+end
@@ -0,0 +1,18 @@
+require 'rubygems'
+require 'scrobbler'
+
+album = Scrobbler::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)
+
+puts "Album: #{album.name}"
+puts "Artist: #{album.artist}"
+puts "Reach: #{album.reach}"
+puts "URL: #{album.url}"
+puts "Release Date: #{album.release_date.strftime('%m/%d/%Y')}"
+
+puts
+puts
+
+puts "Tracks"
+longest_track_name = album.tracks.collect(&:name).sort { |x, y| y.length <=> x.length }.first.length
+puts "=" * longest_track_name
+album.tracks.each { |t| puts t.name }
@@ -0,0 +1,14 @@
+require 'rubygems'
+require 'scrobbler'
+
+artist = Scrobbler::Artist.new('Carrie Underwood')
+
+puts 'Top Tracks'
+puts "=" * 10
+artist.top_tracks.each { |t| puts "(#{t.reach}) #{t.name}" }
+
+puts
+
+puts 'Similar Artists'
+puts "=" * 15
+artist.similar.each { |a| puts "(#{a.match}%) #{a.name}" }
@@ -0,0 +1,12 @@
+require 'rubygems'
+require 'scrobbler'
+
+tag = Scrobbler::Tag.new('country')
+
+puts 'Top Albums'
+tag.top_albums.each { |a| puts "(#{a.count}) #{a.name} by #{a.artist}" }
+
+puts
+
+puts 'Top Tracks'
+tag.top_tracks.each { |t| puts "(#{t.count}) #{t.name} by #{t.artist}" }
@@ -0,0 +1,7 @@
+require 'rubygems'
+require 'scrobbler'
+
+track = Scrobbler::Track.new('Carrie Underwood', 'Before He Cheats')
+puts 'Fans'
+puts "=" * 4
+track.fans.each { |u| puts "(#{u.weight}) #{u.username}" }
@@ -0,0 +1,15 @@
+require 'rubygems'
+require 'scrobbler'
+
+user = Scrobbler::User.new('jnunemaker')
+
+puts "#{user.username}'s Recent Tracks"
+puts "=" * (user.username.length + 16)
+user.recent_tracks.each { |t| puts t.name }
+
+puts
+puts
+
+puts "#{user.username}'s Top Tracks"
+puts "=" * (user.username.length + 13)
+user.top_tracks.each { |t| puts "(#{t.playcount}) #{t.name}" }
@@ -0,0 +1,13 @@
+%w{cgi rubygems hpricot active_support}.each { |x| require x }
+
+require 'scrobbler/base'
+
+require 'scrobbler/album'
+require 'scrobbler/artist'
+require 'scrobbler/chart'
+require 'scrobbler/user'
+require 'scrobbler/tag'
+require 'scrobbler/track'
+
+require 'scrobbler/rest'
+require 'scrobbler/version'
Oops, something went wrong.

0 comments on commit c13cb00

Please sign in to comment.