gingerhendrix-echonest 0.1.1 → 0.2.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 +2 -2
- data/generators/echonest_acceptance_test/USAGE +5 -0
- data/generators/echonest_acceptance_test/echonest_acceptance_test_generator.rb +50 -0
- data/generators/echonest_acceptance_test/templates/feature.erb +8 -0
- data/generators/echonest_model/USAGE +5 -0
- data/generators/echonest_model/echonest_model_generator.rb +52 -0
- data/generators/echonest_model/templates/doc.rb.erb +12 -0
- data/generators/echonest_model/templates/result.rb.erb +12 -0
- data/generators/echonest_model/templates/results.rb.erb +15 -0
- data/generators/echonest_resource/USAGE +5 -0
- data/generators/echonest_resource/echonest_resource_generator.rb +50 -0
- data/generators/echonest_unit_test/USAGE +5 -0
- data/generators/echonest_unit_test/echonest_unit_test_generator.rb +50 -0
- data/generators/echonest_unit_test/templates/unit_test.rb.erb +44 -0
- data/lib/echonest/api_request.rb +1 -1
- data/lib/echonest/artist.rb +52 -1
- data/lib/echonest/{audio.rb → audio_result.rb} +1 -1
- data/lib/echonest/blog_doc.rb +13 -0
- data/lib/echonest/blog_result.rb +12 -0
- data/lib/echonest/blog_results.rb +15 -0
- data/lib/echonest/familiarity_result.rb +11 -0
- data/lib/echonest/hotttnesss_result.rb +11 -0
- data/lib/echonest/news_doc.rb +13 -0
- data/lib/echonest/news_result.rb +12 -0
- data/lib/echonest/news_results.rb +15 -0
- data/lib/echonest/profile_result.rb +11 -0
- data/lib/echonest/reviews_doc.rb +15 -0
- data/lib/echonest/reviews_result.rb +12 -0
- data/lib/echonest/reviews_results.rb +15 -0
- data/lib/echonest/similar_doc.rb +13 -0
- data/lib/echonest/similar_result.rb +12 -0
- data/lib/echonest/similar_results.rb +11 -0
- data/lib/echonest/urls_result.rb +11 -0
- data/lib/echonest/video_doc.rb +14 -0
- data/lib/echonest/video_result.rb +12 -0
- data/lib/echonest/video_results.rb +15 -0
- data/lib/echonest.rb +25 -1
- data/spec/echonest/api_request_spec.rb +7 -0
- data/spec/echonest/{audio_spec.rb → audio_result_spec.rb} +4 -4
- data/spec/echonest/blog_result_spec.rb +48 -0
- data/spec/echonest/familiarity_result_spec.rb +33 -0
- data/spec/echonest/hotttness_result_spec.rb +31 -0
- data/spec/echonest/news_result_spec.rb +49 -0
- data/spec/echonest/profile_result_spec.rb +26 -0
- data/spec/echonest/reviews_result_spec.rb +49 -0
- data/spec/echonest/similar_result_spec.rb +35 -0
- data/spec/echonest/urls_result_spec.rb +38 -0
- data/spec/echonest/video_result_spec.rb +48 -0
- data/spec/fixtures/blog/radiohead.xml +32 -0
- data/spec/fixtures/familiarity/radiohead.xml +17 -0
- data/spec/fixtures/hotttnesss/radiohead.xml +17 -0
- data/spec/fixtures/news/radiohead.xml +32 -0
- data/spec/fixtures/profile/radiohead.xml +16 -0
- data/spec/fixtures/reviews/radiohead.xml +40 -0
- data/spec/fixtures/similar/radiohead.xml +31 -0
- data/spec/fixtures/urls/radiohead.xml +21 -0
- data/spec/fixtures/video/radiohead.xml +32 -0
- data/test/test_echonest_acceptance_test_generator.rb +52 -0
- data/test/test_echonest_model_generator.rb +47 -0
- data/test/test_echonest_resource_generator.rb +45 -0
- data/test/test_echonest_unit_test_generator.rb +35 -0
- data/test/test_generator_helper.rb +29 -0
- metadata +76 -7
data/VERSION.yml
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
class EchonestAcceptanceTestGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
default_options :author => nil
|
4
|
+
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
8
|
+
super
|
9
|
+
usage if args.empty?
|
10
|
+
@name = args.shift
|
11
|
+
extract_options
|
12
|
+
end
|
13
|
+
|
14
|
+
def manifest
|
15
|
+
record do |m|
|
16
|
+
# Ensure appropriate folder(s) exists
|
17
|
+
m.directory 'features'
|
18
|
+
|
19
|
+
# Create stubs
|
20
|
+
m.template "feature.erb", "features/artist_#{@name}.feature"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
def banner
|
26
|
+
<<-EOS
|
27
|
+
Creates a ...
|
28
|
+
|
29
|
+
USAGE: #{$0} #{spec.name} name
|
30
|
+
EOS
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_options!(opts)
|
34
|
+
# opts.separator ''
|
35
|
+
# opts.separator 'Options:'
|
36
|
+
# For each option below, place the default
|
37
|
+
# at the top of the file next to "default_options"
|
38
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
39
|
+
# "Some comment about this option",
|
40
|
+
# "Default: none") { |o| options[:author] = o }
|
41
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
42
|
+
end
|
43
|
+
|
44
|
+
def extract_options
|
45
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
46
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
47
|
+
# raw instance variable value.
|
48
|
+
# @author = options[:author]
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Feature: Artist <%= name %>
|
2
|
+
In order to find <%= name %> about an an artist
|
3
|
+
A user should be able to retrieve <%= name %> for an artist
|
4
|
+
|
5
|
+
Scenario: Artist <%= name %>
|
6
|
+
When I retrieve the <%= name %> for "music://id.echonest.com/~/AR/ARVVZQP11E2835DBCB"
|
7
|
+
Then I should get some <%= name %> results
|
8
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class EchonestModelGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
default_options :author => nil
|
4
|
+
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
8
|
+
super
|
9
|
+
usage if args.empty?
|
10
|
+
@name = args.shift
|
11
|
+
extract_options
|
12
|
+
end
|
13
|
+
|
14
|
+
def manifest
|
15
|
+
record do |m|
|
16
|
+
# Ensure appropriate folder(s) exists
|
17
|
+
m.directory 'lib/echonest'
|
18
|
+
|
19
|
+
m.template "result.rb.erb", "lib/echonest/#{name}_result.rb"
|
20
|
+
m.template "results.rb.erb", "lib/echonest/#{name}_results.rb"
|
21
|
+
m.template "doc.rb.erb", "lib/echonest/#{name}_doc.rb"
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
def banner
|
28
|
+
<<-EOS
|
29
|
+
Creates a ...
|
30
|
+
|
31
|
+
USAGE: #{$0} #{spec.name} name
|
32
|
+
EOS
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_options!(opts)
|
36
|
+
# opts.separator ''
|
37
|
+
# opts.separator 'Options:'
|
38
|
+
# For each option below, place the default
|
39
|
+
# at the top of the file next to "default_options"
|
40
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
41
|
+
# "Some comment about this option",
|
42
|
+
# "Default: none") { |o| options[:author] = o }
|
43
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
44
|
+
end
|
45
|
+
|
46
|
+
def extract_options
|
47
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
48
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
49
|
+
# raw instance variable value.
|
50
|
+
# @author = options[:author]
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class EchonestResourceGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
default_options :author => nil
|
4
|
+
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
8
|
+
super
|
9
|
+
usage if args.empty?
|
10
|
+
@name = args.shift
|
11
|
+
extract_options
|
12
|
+
end
|
13
|
+
|
14
|
+
def manifest
|
15
|
+
record do |m|
|
16
|
+
# Ensure appropriate folder(s) exists
|
17
|
+
m.dependency "echonest_acceptance_test", [name]
|
18
|
+
m.dependency "echonest_unit_test", [name]
|
19
|
+
m.dependency "echonest_model", [name]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
def banner
|
25
|
+
<<-EOS
|
26
|
+
Creates a ...
|
27
|
+
|
28
|
+
USAGE: #{$0} #{spec.name} name
|
29
|
+
EOS
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_options!(opts)
|
33
|
+
# opts.separator ''
|
34
|
+
# opts.separator 'Options:'
|
35
|
+
# For each option below, place the default
|
36
|
+
# at the top of the file next to "default_options"
|
37
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
38
|
+
# "Some comment about this option",
|
39
|
+
# "Default: none") { |o| options[:author] = o }
|
40
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
41
|
+
end
|
42
|
+
|
43
|
+
def extract_options
|
44
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
45
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
46
|
+
# raw instance variable value.
|
47
|
+
# @author = options[:author]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class EchonestUnitTestGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
default_options :author => nil
|
4
|
+
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
8
|
+
super
|
9
|
+
usage if args.empty?
|
10
|
+
@name = args.shift
|
11
|
+
extract_options
|
12
|
+
end
|
13
|
+
|
14
|
+
def manifest
|
15
|
+
record do |m|
|
16
|
+
# Ensure appropriate folder(s) exists
|
17
|
+
m.directory 'spec/echonest'
|
18
|
+
|
19
|
+
# Create stubs
|
20
|
+
m.template "unit_test.rb.erb", "spec/echonest/#{name}_result_spec.rb"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
def banner
|
26
|
+
<<-EOS
|
27
|
+
Creates a ...
|
28
|
+
|
29
|
+
USAGE: #{$0} #{spec.name} name
|
30
|
+
EOS
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_options!(opts)
|
34
|
+
# opts.separator ''
|
35
|
+
# opts.separator 'Options:'
|
36
|
+
# For each option below, place the default
|
37
|
+
# at the top of the file next to "default_options"
|
38
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
39
|
+
# "Some comment about this option",
|
40
|
+
# "Default: none") { |o| options[:author] = o }
|
41
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
42
|
+
end
|
43
|
+
|
44
|
+
def extract_options
|
45
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
46
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
47
|
+
# raw instance variable value.
|
48
|
+
# @author = options[:author]
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "<%=name.capitalize%>Result" do
|
4
|
+
|
5
|
+
describe "#parse" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@xml = File.read(File.dirname(__FILE__) + "/../fixtures/<%=name%>/radiohead.xml")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should parse xml" do
|
12
|
+
EchoNest::<%=name.capitalize%>Result.parse(@xml)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have artist" do
|
16
|
+
<%=name%> = EchoNest::<%=name.capitalize%>Result.parse(@xml)
|
17
|
+
<%=name%>.artist.should be_kind_of(EchoNest::Artist)
|
18
|
+
<%=name%>.artist.name.should == "Radiohead"
|
19
|
+
<%=name%>.artist.id.should == "music://id.echonest.com/~/AR/ARH6W4X1187B99274F"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have results" do
|
23
|
+
<%=name%> = EchoNest::<%=name.capitalize%>Result.parse(@xml)
|
24
|
+
<%=name%>.results.should be_kind_of(EchoNest::<%=name.capitalize%>Results)
|
25
|
+
#TODO: Fill in these values as found in fixture
|
26
|
+
<%=name%>.results.found.should == "51"
|
27
|
+
<%=name%>.results.shown.should == "15"
|
28
|
+
<%=name%>.results.start.should == "0"
|
29
|
+
<%=name%>.results.docs.should be_kind_of(Array)
|
30
|
+
<%=name%>.results.docs.length.should == 15
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "result" do
|
34
|
+
it "should be an <%=name.capitalize%>Doc" do
|
35
|
+
<%=name%> = EchoNest::<%=name.capitalize%>Result.parse(@xml)
|
36
|
+
doc = <%=name%>.results.docs[0]
|
37
|
+
doc.should be_kind_of(EchoNest::<%=name.capitalize%>Doc)
|
38
|
+
#TODO: Create tests based on attributes in resource
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
data/lib/echonest/api_request.rb
CHANGED
data/lib/echonest/artist.rb
CHANGED
@@ -9,11 +9,62 @@ module EchoNest
|
|
9
9
|
|
10
10
|
element :name, String
|
11
11
|
element :id, String
|
12
|
+
element :familiarity, Float
|
13
|
+
element :hotttnesss, Float
|
14
|
+
element :foreign_id, String
|
12
15
|
|
16
|
+
element :mb_url, String
|
17
|
+
element :official_url, String
|
18
|
+
element :myspace_url, String
|
19
|
+
element :wikipedia_url, String
|
20
|
+
element :amazon_url, String
|
21
|
+
element :itunes_url, String
|
22
|
+
|
23
|
+
|
13
24
|
def get_audio
|
14
25
|
request = ApiRequest.new("get_audio", {:id => id})
|
15
|
-
|
26
|
+
AudioResult.parse request.fetch
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_blogs
|
30
|
+
request = ApiRequest.new("get_audio", {:id => id})
|
31
|
+
BlogResult.parse request.fetch
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_familiarity
|
35
|
+
request = ApiRequest.new("get_familiarity", {:id => id})
|
36
|
+
FamiliarityResult.parse request.fetch
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_hotttnesss
|
40
|
+
request = ApiRequest.new("get_hotttnesss", {:id => id})
|
41
|
+
HotttnesssResult.parse request.fetch
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_news
|
45
|
+
request = ApiRequest.new("get_news", {:id => id})
|
46
|
+
NewsResult.parse request.fetch
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_profile
|
50
|
+
request = ApiRequest.new("get_profile", {:id => id})
|
51
|
+
ProfileResult.parse request.fetch
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_similar
|
55
|
+
request = ApiRequest.new("get_similar", {:id => id})
|
56
|
+
SimilarResult.parse request.fetch
|
16
57
|
end
|
17
58
|
|
59
|
+
def get_urls
|
60
|
+
request = ApiRequest.new("get_urls", {:id => id})
|
61
|
+
UrlsResult.parse request.fetch
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_video
|
65
|
+
request = ApiRequest.new("get_video", {:id => id})
|
66
|
+
VideoResult.parse request.fetch
|
67
|
+
end
|
68
|
+
|
18
69
|
end
|
19
70
|
end
|
@@ -0,0 +1,15 @@
|
|
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
|