gingerhendrix-echonest 0.2.0 → 0.3.0

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.
Files changed (68) hide show
  1. data/VERSION.yml +1 -1
  2. data/examples/artist_audio.rb +33 -0
  3. data/lib/echonest.rb +39 -29
  4. data/lib/echonest/artist.rb +57 -53
  5. data/lib/echonest/paged_result.rb +33 -0
  6. data/lib/echonest/xml/artist_doc.rb +23 -0
  7. data/lib/echonest/xml/artist_search_results.rb +14 -0
  8. data/lib/echonest/xml/audio_doc.rb +20 -0
  9. data/lib/echonest/xml/audio_result.rb +13 -0
  10. data/lib/echonest/xml/audio_results.rb +16 -0
  11. data/lib/echonest/xml/blogs_doc.rb +15 -0
  12. data/lib/echonest/xml/blogs_result.rb +14 -0
  13. data/lib/echonest/xml/blogs_results.rb +18 -0
  14. data/lib/echonest/xml/familiarity_result.rb +12 -0
  15. data/lib/echonest/xml/hotttnesss_result.rb +12 -0
  16. data/lib/echonest/xml/news_doc.rb +15 -0
  17. data/lib/echonest/xml/news_result.rb +14 -0
  18. data/lib/echonest/xml/news_results.rb +16 -0
  19. data/lib/echonest/xml/profile_result.rb +12 -0
  20. data/lib/echonest/xml/reviews_doc.rb +16 -0
  21. data/lib/echonest/xml/reviews_result.rb +15 -0
  22. data/lib/echonest/xml/reviews_results.rb +17 -0
  23. data/lib/echonest/xml/similar_doc.rb +15 -0
  24. data/lib/echonest/xml/similar_result.rb +14 -0
  25. data/lib/echonest/xml/similar_results.rb +16 -0
  26. data/lib/echonest/xml/urls_result.rb +14 -0
  27. data/lib/echonest/xml/video_doc.rb +16 -0
  28. data/lib/echonest/xml/video_result.rb +14 -0
  29. data/lib/echonest/xml/video_results.rb +17 -0
  30. data/spec/echonest/paged_result_spec.rb +66 -0
  31. data/spec/echonest/xml/artist_search_results_spec.rb +25 -0
  32. data/spec/echonest/{audio_result_spec.rb → xml/audio_result_spec.rb} +9 -9
  33. data/spec/echonest/{blog_result_spec.rb → xml/blogs_result_spec.rb} +10 -10
  34. data/spec/echonest/{familiarity_result_spec.rb → xml/familiarity_result_spec.rb} +7 -7
  35. data/spec/echonest/{hotttness_result_spec.rb → xml/hotttness_result_spec.rb} +7 -7
  36. data/spec/echonest/{news_result_spec.rb → xml/news_result_spec.rb} +9 -9
  37. data/spec/echonest/{profile_result_spec.rb → xml/profile_result_spec.rb} +5 -5
  38. data/spec/echonest/xml/refactor.rb +12 -0
  39. data/spec/echonest/{reviews_result_spec.rb → xml/reviews_result_spec.rb} +9 -9
  40. data/spec/echonest/{similar_result_spec.rb → xml/similar_result_spec.rb} +7 -7
  41. data/spec/echonest/{urls_result_spec.rb → xml/urls_result_spec.rb} +6 -6
  42. data/spec/echonest/{video_result_spec.rb → xml/video_result_spec.rb} +9 -9
  43. data/spec/spec_helper.rb +2 -0
  44. metadata +57 -48
  45. data/lib/echonest/artist_search.rb +0 -18
  46. data/lib/echonest/audio_doc.rb +0 -18
  47. data/lib/echonest/audio_result.rb +0 -12
  48. data/lib/echonest/audio_results.rb +0 -15
  49. data/lib/echonest/blog_doc.rb +0 -13
  50. data/lib/echonest/blog_result.rb +0 -12
  51. data/lib/echonest/blog_results.rb +0 -15
  52. data/lib/echonest/familiarity_result.rb +0 -11
  53. data/lib/echonest/hotttnesss_result.rb +0 -11
  54. data/lib/echonest/news_doc.rb +0 -13
  55. data/lib/echonest/news_result.rb +0 -12
  56. data/lib/echonest/news_results.rb +0 -15
  57. data/lib/echonest/profile_result.rb +0 -11
  58. data/lib/echonest/reviews_doc.rb +0 -15
  59. data/lib/echonest/reviews_result.rb +0 -12
  60. data/lib/echonest/reviews_results.rb +0 -15
  61. data/lib/echonest/similar_doc.rb +0 -13
  62. data/lib/echonest/similar_result.rb +0 -12
  63. data/lib/echonest/similar_results.rb +0 -11
  64. data/lib/echonest/urls_result.rb +0 -11
  65. data/lib/echonest/video_doc.rb +0 -14
  66. data/lib/echonest/video_result.rb +0 -12
  67. data/lib/echonest/video_results.rb +0 -15
  68. data/spec/echonest/search_spec.rb +0 -51
@@ -1,18 +0,0 @@
1
-
2
- module EchoNest
3
- class ArtistSearch
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- # has_one :status, RequestStatus
9
- # has_one :query, RequestQuery
10
- has_many :artists, Artist
11
-
12
- def self.search(query)
13
- request = ApiRequest.new("search_artists", {:query => query})
14
- parse(request.fetch)
15
- end
16
-
17
- end
18
- end
@@ -1,18 +0,0 @@
1
-
2
- module EchoNest
3
- class AudioDoc
4
- include HappyMapper
5
-
6
- tag :doc
7
-
8
- element :artist_id, String
9
- element :foreign_artist_id, String
10
- element :artist, String
11
- element :release, String
12
- element :title, String
13
- element :url, String
14
- element :link, String
15
- element :date, String
16
- element :length, String
17
- end
18
- end
@@ -1,12 +0,0 @@
1
-
2
- module EchoNest
3
- class AudioResult
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- has_one :artist, Artist
9
- has_one :results, AudioResults
10
-
11
- end
12
- end
@@ -1,15 +0,0 @@
1
-
2
- module EchoNest
3
- class AudioResults
4
- include HappyMapper
5
-
6
- tag :results
7
-
8
- attribute :found, String
9
- attribute :shown, String
10
- attribute :start, String
11
-
12
- has_many :docs, AudioDoc
13
-
14
- end
15
- end
@@ -1,13 +0,0 @@
1
-
2
- module EchoNest
3
- class BlogDoc
4
- include HappyMapper
5
-
6
- tag :doc
7
-
8
- element :name, String
9
- element :url, String
10
- element :summary, String
11
- element :date_found, String
12
- end
13
- end
@@ -1,12 +0,0 @@
1
-
2
- module EchoNest
3
- class BlogResult
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- has_one :artist, Artist
9
- has_one :results, BlogResults
10
-
11
- end
12
- end
@@ -1,15 +0,0 @@
1
-
2
- module EchoNest
3
- class BlogResults
4
- include HappyMapper
5
-
6
- tag :results
7
-
8
- attribute :found, String
9
- attribute :shown, String
10
- attribute :start, String
11
-
12
- has_many :docs, BlogDoc
13
-
14
- end
15
- end
@@ -1,11 +0,0 @@
1
-
2
- module EchoNest
3
- class FamiliarityResult
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- has_one :artist, Artist
9
-
10
- end
11
- end
@@ -1,11 +0,0 @@
1
-
2
- module EchoNest
3
- class HotttnesssResult
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- has_one :artist, Artist
9
-
10
- end
11
- end
@@ -1,13 +0,0 @@
1
-
2
- module EchoNest
3
- class NewsDoc
4
- include HappyMapper
5
-
6
- tag :doc
7
-
8
- element :name, String
9
- element :url, String
10
- element :summary, String
11
- element :date_found, String
12
- end
13
- end
@@ -1,12 +0,0 @@
1
-
2
- module EchoNest
3
- class NewsResult
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- has_one :artist, Artist
9
- has_one :results, NewsResults
10
-
11
- end
12
- end
@@ -1,15 +0,0 @@
1
-
2
- module EchoNest
3
- class NewsResults
4
- include HappyMapper
5
-
6
- tag :results
7
-
8
- attribute :found, String
9
- attribute :shown, String
10
- attribute :start, String
11
-
12
- has_many :docs, NewsDoc
13
-
14
- end
15
- end
@@ -1,11 +0,0 @@
1
-
2
- module EchoNest
3
- class ProfileResult
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- has_one :artist, Artist
9
-
10
- end
11
- end
@@ -1,15 +0,0 @@
1
-
2
- module EchoNest
3
- class ReviewsDoc
4
- include HappyMapper
5
-
6
- tag :doc
7
-
8
- #TODO: Add document elements
9
- element :name, String
10
- element :review_text, String
11
- element :url, String
12
- element :summary, String
13
- element :date_found, String
14
- end
15
- end
@@ -1,12 +0,0 @@
1
-
2
- module EchoNest
3
- class ReviewsResult
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- has_one :artist, Artist
9
- has_one :results, ReviewsResults
10
-
11
- end
12
- end
@@ -1,15 +0,0 @@
1
-
2
- module EchoNest
3
- class ReviewsResults
4
- include HappyMapper
5
-
6
- tag :results
7
-
8
- attribute :found, String
9
- attribute :shown, String
10
- attribute :start, String
11
-
12
- has_many :docs, ReviewsDoc
13
-
14
- end
15
- end
@@ -1,13 +0,0 @@
1
-
2
- module EchoNest
3
- class SimilarDoc
4
- include HappyMapper
5
-
6
- tag :artist
7
-
8
- #TODO: Add document elements
9
- element :name, String
10
- element :id, String
11
- element :rank, Integer
12
- end
13
- end
@@ -1,12 +0,0 @@
1
-
2
- module EchoNest
3
- class SimilarResult
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- has_one :artist, Artist
9
- has_one :results, SimilarResults
10
-
11
- end
12
- end
@@ -1,11 +0,0 @@
1
-
2
- module EchoNest
3
- class SimilarResults
4
- include HappyMapper
5
-
6
- tag :similar
7
-
8
- has_many :docs, SimilarDoc
9
-
10
- end
11
- end
@@ -1,11 +0,0 @@
1
-
2
- module EchoNest
3
- class UrlsResult
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- has_one :artist, Artist
9
-
10
- end
11
- end
@@ -1,14 +0,0 @@
1
-
2
- module EchoNest
3
- class VideoDoc
4
- include HappyMapper
5
-
6
- tag :doc
7
-
8
- #TODO: Add document elements
9
- element :site, String
10
- element :title, String
11
- element :url, String
12
- element :date_found, String
13
- end
14
- end
@@ -1,12 +0,0 @@
1
-
2
- module EchoNest
3
- class VideoResult
4
- include HappyMapper
5
-
6
- tag :response
7
-
8
- has_one :artist, Artist
9
- has_one :results, VideoResults
10
-
11
- end
12
- end
@@ -1,15 +0,0 @@
1
-
2
- module EchoNest
3
- class VideoResults
4
- include HappyMapper
5
-
6
- tag :results
7
-
8
- attribute :found, String
9
- attribute :shown, String
10
- attribute :start, String
11
-
12
- has_many :docs, VideoDoc
13
-
14
- end
15
- end
@@ -1,51 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe "ArtistSearch" do
4
-
5
- describe "#search" do
6
- before(:each) do
7
- @mock_request = mock "Request"
8
- @mock_request.stub!(:fetch)
9
- EchoNest::ApiRequest.stub!(:new).and_return(@mock_request)
10
- EchoNest::ArtistSearch.stub!(:parse)
11
- end
12
-
13
- it "should create a new ApiRequest with resource 'search_artists' and :query => query" do
14
- EchoNest::ApiRequest.should_receive(:new).with('search_artists', :query=> "QUERY").and_return(@mock_request)
15
- EchoNest::ArtistSearch.search("QUERY")
16
- end
17
-
18
- it "should call fetch on the api request" do
19
- @mock_request.should_receive(:fetch)
20
- EchoNest::ArtistSearch.search("QUERY")
21
- end
22
-
23
- it "should call parse on the results of fetch" do
24
- @mock_request.stub!(:fetch).and_return("RESULT")
25
- EchoNest::ArtistSearch.should_receive(:parse).with("RESULT").and_return("search_result")
26
- EchoNest::ArtistSearch.search("QUERY").should == "search_result"
27
- end
28
-
29
- end
30
-
31
- describe "#parse" do
32
-
33
- before(:each) do
34
- @xml = File.read(File.dirname(__FILE__) + "/../fixtures/search_artists/wavves.xml")
35
- end
36
-
37
- it "should parse xml" do
38
- EchoNest::ArtistSearch.parse(@xml)
39
- end
40
-
41
- it "should have list of artists" do
42
- search = EchoNest::ArtistSearch.parse(@xml)
43
- search.artists.should be_kind_of(Array)
44
- search.artists[0].should be_kind_of(EchoNest::Artist)
45
- search.artists[0].name.should == "Wavves"
46
- search.artists[0].id.should == "music://id.echonest.com/~/AR/ARVVZQP11E2835DBCB"
47
- end
48
-
49
- end
50
-
51
- end