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.
- data/VERSION.yml +1 -1
- data/examples/artist_audio.rb +33 -0
- data/lib/echonest.rb +39 -29
- data/lib/echonest/artist.rb +57 -53
- data/lib/echonest/paged_result.rb +33 -0
- data/lib/echonest/xml/artist_doc.rb +23 -0
- data/lib/echonest/xml/artist_search_results.rb +14 -0
- data/lib/echonest/xml/audio_doc.rb +20 -0
- data/lib/echonest/xml/audio_result.rb +13 -0
- data/lib/echonest/xml/audio_results.rb +16 -0
- data/lib/echonest/xml/blogs_doc.rb +15 -0
- data/lib/echonest/xml/blogs_result.rb +14 -0
- data/lib/echonest/xml/blogs_results.rb +18 -0
- data/lib/echonest/xml/familiarity_result.rb +12 -0
- data/lib/echonest/xml/hotttnesss_result.rb +12 -0
- data/lib/echonest/xml/news_doc.rb +15 -0
- data/lib/echonest/xml/news_result.rb +14 -0
- data/lib/echonest/xml/news_results.rb +16 -0
- data/lib/echonest/xml/profile_result.rb +12 -0
- data/lib/echonest/xml/reviews_doc.rb +16 -0
- data/lib/echonest/xml/reviews_result.rb +15 -0
- data/lib/echonest/xml/reviews_results.rb +17 -0
- data/lib/echonest/xml/similar_doc.rb +15 -0
- data/lib/echonest/xml/similar_result.rb +14 -0
- data/lib/echonest/xml/similar_results.rb +16 -0
- data/lib/echonest/xml/urls_result.rb +14 -0
- data/lib/echonest/xml/video_doc.rb +16 -0
- data/lib/echonest/xml/video_result.rb +14 -0
- data/lib/echonest/xml/video_results.rb +17 -0
- data/spec/echonest/paged_result_spec.rb +66 -0
- data/spec/echonest/xml/artist_search_results_spec.rb +25 -0
- data/spec/echonest/{audio_result_spec.rb → xml/audio_result_spec.rb} +9 -9
- data/spec/echonest/{blog_result_spec.rb → xml/blogs_result_spec.rb} +10 -10
- data/spec/echonest/{familiarity_result_spec.rb → xml/familiarity_result_spec.rb} +7 -7
- data/spec/echonest/{hotttness_result_spec.rb → xml/hotttness_result_spec.rb} +7 -7
- data/spec/echonest/{news_result_spec.rb → xml/news_result_spec.rb} +9 -9
- data/spec/echonest/{profile_result_spec.rb → xml/profile_result_spec.rb} +5 -5
- data/spec/echonest/xml/refactor.rb +12 -0
- data/spec/echonest/{reviews_result_spec.rb → xml/reviews_result_spec.rb} +9 -9
- data/spec/echonest/{similar_result_spec.rb → xml/similar_result_spec.rb} +7 -7
- data/spec/echonest/{urls_result_spec.rb → xml/urls_result_spec.rb} +6 -6
- data/spec/echonest/{video_result_spec.rb → xml/video_result_spec.rb} +9 -9
- data/spec/spec_helper.rb +2 -0
- metadata +57 -48
- data/lib/echonest/artist_search.rb +0 -18
- data/lib/echonest/audio_doc.rb +0 -18
- data/lib/echonest/audio_result.rb +0 -12
- data/lib/echonest/audio_results.rb +0 -15
- data/lib/echonest/blog_doc.rb +0 -13
- data/lib/echonest/blog_result.rb +0 -12
- data/lib/echonest/blog_results.rb +0 -15
- data/lib/echonest/familiarity_result.rb +0 -11
- data/lib/echonest/hotttnesss_result.rb +0 -11
- data/lib/echonest/news_doc.rb +0 -13
- data/lib/echonest/news_result.rb +0 -12
- data/lib/echonest/news_results.rb +0 -15
- data/lib/echonest/profile_result.rb +0 -11
- data/lib/echonest/reviews_doc.rb +0 -15
- data/lib/echonest/reviews_result.rb +0 -12
- data/lib/echonest/reviews_results.rb +0 -15
- data/lib/echonest/similar_doc.rb +0 -13
- data/lib/echonest/similar_result.rb +0 -12
- data/lib/echonest/similar_results.rb +0 -11
- data/lib/echonest/urls_result.rb +0 -11
- data/lib/echonest/video_doc.rb +0 -14
- data/lib/echonest/video_result.rb +0 -12
- data/lib/echonest/video_results.rb +0 -15
- data/spec/echonest/search_spec.rb +0 -51
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper.rb"
|
2
|
+
|
3
|
+
include EchoNest
|
4
|
+
|
5
|
+
describe "PagedResult" do
|
6
|
+
before :each do
|
7
|
+
@docs = mock("docs", :length => 2)
|
8
|
+
@results = mock("results", :docs => @docs)
|
9
|
+
@block_body = mock("block body")
|
10
|
+
@block = Proc.new { |*args| @block_body.called(*args) }
|
11
|
+
@page = PagedResult.new @results, &@block
|
12
|
+
|
13
|
+
@docs2 = mock("docs2", :length => 2)
|
14
|
+
@page2 = mock("page2", :docs => @docs2)
|
15
|
+
@block_body.stub!(:called).and_return(@page2)
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "each" do
|
20
|
+
it "should iterate over items in results" do
|
21
|
+
@docs.should_receive(:each)
|
22
|
+
@page.each
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "[]" do
|
27
|
+
it "should return the nth doc" do
|
28
|
+
@docs.should_receive('[]').twice().with(1).and_return(:doc)
|
29
|
+
@page[1].should == :doc
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should get the next page if index is out of range" do
|
33
|
+
@docs.should_receive('[]').at_least(1).and_return(nil)
|
34
|
+
@page.should_receive(:next_page)
|
35
|
+
@page[2]
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "next_page" do
|
41
|
+
|
42
|
+
before(:each) do
|
43
|
+
@merged_docs = mock("Merged Docs", :length => 4)
|
44
|
+
@docs.stub!('+').and_return(@merged_docs)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should fetch the next page" do
|
48
|
+
@block_body.should_receive(:called).with(2, 15).and_return(@page2)
|
49
|
+
@page.next_page
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should update the delegate" do
|
53
|
+
@docs.should_receive('+').with(@docs2).and_return(@merged_docs)
|
54
|
+
@page.next_page
|
55
|
+
@page.length.should == 4
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "length" do
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe "ArtistSearchResuls" do
|
4
|
+
|
5
|
+
describe "#parse" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@xml = File.read(File.dirname(__FILE__) + "/../../fixtures/search_artists/wavves.xml")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should parse xml" do
|
12
|
+
ArtistSearchResults.parse(@xml)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have list of artists" do
|
16
|
+
search = ArtistSearchResults.parse(@xml)
|
17
|
+
search.artists.should be_kind_of(Array)
|
18
|
+
search.artists[0].should be_kind_of(ArtistDoc)
|
19
|
+
search.artists[0].name.should == "Wavves"
|
20
|
+
search.artists[0].id.should == "music://id.echonest.com/~/AR/ARVVZQP11E2835DBCB"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
3
|
describe "Audio" do
|
4
4
|
|
5
5
|
describe "#parse" do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
@xml = File.read(File.dirname(__FILE__) + "
|
8
|
+
@xml = File.read(File.dirname(__FILE__) + "/../../fixtures/audio/wavves.xml")
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should parse xml" do
|
12
|
-
|
12
|
+
AudioResult.parse(@xml)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should have artist" do
|
16
|
-
audio =
|
17
|
-
audio.artist.should be_kind_of(
|
16
|
+
audio = AudioResult.parse(@xml)
|
17
|
+
audio.artist.should be_kind_of(ArtistDoc)
|
18
18
|
audio.artist.name.should == "Wavves"
|
19
19
|
audio.artist.id.should == "music://id.echonest.com/~/AR/ARVVZQP11E2835DBCB"
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should have results" do
|
23
|
-
audio =
|
24
|
-
audio.results.should be_kind_of(
|
23
|
+
audio = AudioResult.parse(@xml)
|
24
|
+
audio.results.should be_kind_of(AudioResults)
|
25
25
|
audio.results.found.should == "51"
|
26
26
|
audio.results.shown.should == "15"
|
27
27
|
audio.results.start.should == "0"
|
@@ -31,9 +31,9 @@ describe "Audio" do
|
|
31
31
|
|
32
32
|
describe "result" do
|
33
33
|
it "should be an AudioDoc" do
|
34
|
-
audio =
|
34
|
+
audio = AudioResult.parse(@xml)
|
35
35
|
doc = audio.results.docs[0]
|
36
|
-
doc.should be_kind_of(
|
36
|
+
doc.should be_kind_of(AudioDoc)
|
37
37
|
doc.artist_id.should == "music://id.echonest.com/~/AR/ARVVZQP11E2835DBCB"
|
38
38
|
doc.artist.should == "Wavves"
|
39
39
|
doc.release.should == "03/21/09 Austin TX"
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "BlogsResult" do
|
4
4
|
|
5
5
|
describe "#parse" do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
@xml = File.read(File.dirname(__FILE__) + "
|
8
|
+
@xml = File.read(File.dirname(__FILE__) + "/../../fixtures/blog/radiohead.xml")
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should parse xml" do
|
12
|
-
|
12
|
+
BlogsResult.parse(@xml)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should have artist" do
|
16
|
-
blog =
|
17
|
-
blog.artist.should be_kind_of(
|
16
|
+
blog = BlogsResult.parse(@xml)
|
17
|
+
blog.artist.should be_kind_of(ArtistDoc)
|
18
18
|
blog.artist.name.should == "Radiohead"
|
19
19
|
blog.artist.id.should == "music://id.echonest.com/~/AR/ARH6W4X1187B99274F"
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should have results" do
|
23
|
-
blog =
|
24
|
-
blog.results.should be_kind_of(
|
23
|
+
blog = BlogsResult.parse(@xml)
|
24
|
+
blog.results.should be_kind_of(BlogsResults)
|
25
25
|
#TODO: Fill in these values as found in fixture
|
26
26
|
blog.results.found.should == "131"
|
27
27
|
blog.results.shown.should == "2"
|
@@ -32,9 +32,9 @@ describe "BlogResult" do
|
|
32
32
|
|
33
33
|
describe "result" do
|
34
34
|
it "should be an BlogDoc" do
|
35
|
-
blog =
|
35
|
+
blog = BlogsResult.parse(@xml)
|
36
36
|
doc = blog.results.docs[0]
|
37
|
-
doc.should be_kind_of(
|
37
|
+
doc.should be_kind_of(BlogsDoc)
|
38
38
|
#TODO: Create tests based on attributes in resource
|
39
39
|
doc.name.should == "Radiohead live at Santa Barbara 28.8.08 « Misspeak Music"
|
40
40
|
doc.url.should == "http://misspeakmusic.wordpress.com/2008/09/01/radiohead-live-at-santa-barbara-28808/"
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require File.dirname(__FILE__) + '
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
3
|
describe "FamiliarityResult" do
|
4
4
|
|
5
5
|
describe "#parse" do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
@xml = File.read(File.dirname(__FILE__) + "
|
8
|
+
@xml = File.read(File.dirname(__FILE__) + "/../../fixtures/familiarity/radiohead.xml")
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should parse xml" do
|
12
|
-
|
12
|
+
FamiliarityResult.parse(@xml)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should have artist" do
|
16
|
-
familiarity =
|
17
|
-
familiarity.artist.should be_kind_of(
|
16
|
+
familiarity = FamiliarityResult.parse(@xml)
|
17
|
+
familiarity.artist.should be_kind_of(ArtistDoc)
|
18
18
|
familiarity.artist.name.should == "Radiohead"
|
19
19
|
familiarity.artist.id.should == "music://id.echonest.com/~/AR/ARH6W4X1187B99274F"
|
20
20
|
end
|
21
21
|
|
22
22
|
it " artist should have familiarity" do
|
23
|
-
familiarity =
|
24
|
-
familiarity.artist.should be_kind_of(
|
23
|
+
familiarity = FamiliarityResult.parse(@xml)
|
24
|
+
familiarity.artist.should be_kind_of(ArtistDoc)
|
25
25
|
familiarity.artist.familiarity.should_not be_nil
|
26
26
|
familiarity.artist.familiarity.should == 0.96974159665
|
27
27
|
end
|