Navigation Menu

Skip to content
This repository has been archived by the owner on Dec 6, 2018. It is now read-only.

Commit

Permalink
refactor recommender class
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesea committed Jul 12, 2012
1 parent 3a8dcdf commit 7c66c5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion app/models/recommender.rb
@@ -1,6 +1,14 @@
class Recommender class Recommender


def self.recommend_tracks_from_artists(artists=[], client=Nestling.new) class << self
attr_accessor :client
end

# Instantiate a client to communicate with Echonest
# Nestling is a wrapper gem for Echonest's API
@client ||= Nestling.new

def self.recommend_tracks_from_artists(artists=[])
response = client.playlist.static( response = client.playlist.static(
artist: artists, artist: artists,
bucket: "id:rdio-us-streaming", bucket: "id:rdio-us-streaming",
Expand Down
2 changes: 1 addition & 1 deletion spec/models/recommender_spec.rb
Expand Up @@ -22,7 +22,7 @@
end end


it "returns a collection of tracks with populated values" do it "returns a collection of tracks with populated values" do
rec = Recommender.recommend_tracks_from_artists(artists, client) rec = Recommender.recommend_tracks_from_artists(artists)
rec.each do |track| rec.each do |track|
track.class.should be Track track.class.should be Track
track.artist_name.should_not be nil track.artist_name.should_not be nil
Expand Down

0 comments on commit 7c66c5e

Please sign in to comment.