Skip to content

Commit

Permalink
Generated a skeleton for user
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerhendrix committed Apr 22, 2009
1 parent 45e154d commit 3a91a56
Show file tree
Hide file tree
Showing 20 changed files with 440 additions and 8 deletions.
48 changes: 40 additions & 8 deletions lib/scrobbler2/user.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
module Scrobbler2
class User < Base

def initialize(username)
@username = username
def initialize()
@query = {}#TODO eg. {:artist => artist, :track => track}
end

def info(options={}, query={})
return @info if @info && !options[:force]
@info = self.class.get_with_auth("user.getinfo", query, options)["lfm"]["user"]
end


get_resource :events, :root => "events"

get_resource :info, :root => "info"

get_resource :friends, :root => "friends"

get_resource :loved_tracks, :root => "loved_tracks"

get_resource :neighbours, :root => "neighbours"

get_resource :past_events, :root => "past_events"

get_resource :playlists, :root => "playlists"

get_resource :recent_tracks, :root => "recent_tracks"

get_resource :recommended_artists, :root => "recommended_artists"

get_resource :recommended_events, :root => "recommended_events"

get_resource :shouts, :root => "shouts"

get_resource :top_albums, :root => "top_albums"

get_resource :top_artists, :root => "top_artists"

get_resource :top_tags, :root => "top_tags"

get_resource :top_tracks, :root => "top_tracks"

get_resource :weekly_album_chart, :root => "weekly_album_chart"

get_resource :weekly_artist_chart, :root => "weekly_artist_chart"

get_resource :weekly_chart_list, :root => "weekly_chart_list"

get_resource :weekly_track_chart, :root => "weekly_track_chart"

end
end
14 changes: 14 additions & 0 deletions test/acceptance/user/events_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "events for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@events = @user.events
end

it "should be hash" do
@events.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/friends_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "friends for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@friends = @user.friends
end

it "should be hash" do
@friends.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/loved_tracks_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "loved_tracks for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@loved_tracks = @user.loved_tracks
end

it "should be hash" do
@loved_tracks.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/neighbours_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "neighbours for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@neighbours = @user.neighbours
end

it "should be hash" do
@neighbours.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/past_events_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "past_events for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@past_events = @user.past_events
end

it "should be hash" do
@past_events.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/playlists_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "playlists for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@playlists = @user.playlists
end

it "should be hash" do
@playlists.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/recent_tracks_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "recent_tracks for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@recent_tracks = @user.recent_tracks
end

it "should be hash" do
@recent_tracks.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/recommended_artists_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "recommended_artists for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@recommended_artists = @user.recommended_artists
end

it "should be hash" do
@recommended_artists.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/recommended_events_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "recommended_events for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@recommended_events = @user.recommended_events
end

it "should be hash" do
@recommended_events.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/shouts_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "shouts for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@shouts = @user.shouts
end

it "should be hash" do
@shouts.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/top_albums_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "top_albums for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@top_albums = @user.top_albums
end

it "should be hash" do
@top_albums.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/top_artists_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "top_artists for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@top_artists = @user.top_artists
end

it "should be hash" do
@top_artists.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/top_tags_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "top_tags for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@top_tags = @user.top_tags
end

it "should be hash" do
@top_tags.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/top_tracks_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "top_tracks for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@top_tracks = @user.top_tracks
end

it "should be hash" do
@top_tracks.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/weekly_album_chart_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "weekly_album_chart for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@weekly_album_chart = @user.weekly_album_chart
end

it "should be hash" do
@weekly_album_chart.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/weekly_artist_chart_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "weekly_artist_chart for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@weekly_artist_chart = @user.weekly_artist_chart
end

it "should be hash" do
@weekly_artist_chart.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/weekly_chart_list_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "weekly_chart_list for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@weekly_chart_list = @user.weekly_chart_list
end

it "should be hash" do
@weekly_chart_list.should be_kind_of Hash
end

end
14 changes: 14 additions & 0 deletions test/acceptance/user/weekly_track_chart_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.dirname(__FILE__) + '/../test_helper.rb'

describe "weekly_track_chart for user ..." do

before(:all) do #We only want to hit the webservice once.
@user = Scrobbler2::user.new "..."
@weekly_track_chart = @user.weekly_track_chart
end

it "should be hash" do
@weekly_track_chart.should be_kind_of Hash
end

end
Loading

0 comments on commit 3a91a56

Please sign in to comment.