bassnode-ruby-echonest 0.1.2

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/spec/song_spec.rb ADDED
@@ -0,0 +1,91 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'spec_helper'
4
+ require "echonest"
5
+
6
+ include SpecHelper
7
+
8
+ describe Echonest::ApiMethods::Song do
9
+ before do
10
+ @api = Echonest::Api.new('8TPE3VC60ODJTNTFE')
11
+ @song = Echonest::ApiMethods::Song.new(@api)
12
+ end
13
+
14
+ def self.describe_bundle_for_song(method, options=nil)
15
+ describe "#{method}" do
16
+ it "should request to song/#{method} with id" do
17
+ @api.should_receive(:request).with(
18
+ "song/#{method}",
19
+ :get,
20
+ :id => 'abcd').and_return{ Echonest::Response.new('{"hello":"world"}') }
21
+
22
+ @song.send(method, :id => 'abcd')
23
+ end
24
+
25
+ it "should request to song/#{method} with option" do
26
+ options.each do |opt|
27
+ @api.should_receive(:request).with(
28
+ "song/#{method}",
29
+ :get,
30
+ opt.merge(:id => 'abcd')).and_return{ Echonest::Response.new('{"hello":"world"}') }
31
+
32
+ @song.send(method, opt.merge(:id => 'abcd'))
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ def self.describe_bundle_for_option(method, options=nil)
39
+ describe "#{method}" do
40
+ it "should request to song/#{method}" do
41
+ @api.should_receive(:request).with(
42
+ "song/#{method}",
43
+ :get,
44
+ {}).and_return{ Echonest::Response.new('{"hello":"world"}') }
45
+
46
+ @song.send(method)
47
+ end
48
+
49
+ it "should request to song/#{method} with option" do
50
+ options.each do |opt|
51
+ @api.should_receive(:request).with(
52
+ "song/#{method}",
53
+ :get,
54
+ opt).and_return{ Echonest::Response.new('{"hello":"world"}') }
55
+
56
+ @song.send(method, opt)
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ describe_bundle_for_option('search', [
63
+ {:format => 'json'},
64
+ {:format => 'json', :title => 'foo'},
65
+ {:format => 'json', :title => 'foo', :sort => 'tempo-asc'},
66
+ {:format => 'json', :results => 100, :bucket => 'audio_summary'},
67
+ {:format => 'json', :results => 100, :bucket => %w[audio_summary tracks song_hotttnesss]}
68
+ ])
69
+
70
+ describe_bundle_for_song('profile', [
71
+ {:format => 'json'},
72
+ {:format => 'json', :bucket => 'audio_summary'},
73
+ {:format => 'json', :bucket => 'audio_summary', :limit => 'true'},
74
+ {:format => 'json', :bucket => %w[audio_summary tracks song_hotttnesss]}
75
+ ])
76
+
77
+ # describe_bundle_for_option('identify', [
78
+ # {:code => '1234'},
79
+ # {:code => '1234', :genre => 'pop'},
80
+ # {:code => '1234', :genre => 'pop', :bucket => 'audio_summary'},
81
+ # {:code => '1234', :genre => 'pop', :bucket => %w[audio_summary tracks song_hotttnesss]}
82
+ # ])
83
+
84
+ describe "identify" do
85
+ it "should request to song/identify with option" do
86
+ @api.should_receive(:request).with("song/identify", :post, {}, nil).and_return{ Echonest::Response.new('{"hello":"world"}') }
87
+ @song.identify({})
88
+ end
89
+
90
+ end
91
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ -c
2
+ -fs
@@ -0,0 +1,11 @@
1
+ $:.unshift File.dirname(__FILE__) + '/../lib/'
2
+
3
+ require 'echonest'
4
+
5
+ module SpecHelper
6
+ def fixture(filename)
7
+ File.dirname(__FILE__) + '/fixtures/' + filename
8
+ end
9
+ end
10
+
11
+
@@ -0,0 +1,105 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'spec_helper'
4
+ require "echonest"
5
+
6
+ include SpecHelper
7
+
8
+ describe Echonest::ApiMethods::Track do
9
+ before do
10
+ @api = Echonest::Api.new('8TPE3VC60ODJTNTFE')
11
+ @track = Echonest::ApiMethods::Track.new(@api)
12
+ end
13
+
14
+ describe '#profile' do
15
+ it 'should request to track/profile with id' do
16
+ @api.should_receive(:request).with(
17
+ 'track/profile',
18
+ :get ,
19
+ :id => 'TRXXHTJ1294CD8F3B3', :bucket => 'audio_summary')
20
+
21
+ @track.profile(:id => 'TRXXHTJ1294CD8F3B3')
22
+ end
23
+
24
+ it 'should request to track/profile with md5' do
25
+ @api.should_receive(:request).with(
26
+ 'track/profile',
27
+ :get ,
28
+ :md5 => '0cf9c7faab913c62451940e6a4eb8a09', :bucket => 'audio_summary')
29
+
30
+ @track.profile(:md5 => '0cf9c7faab913c62451940e6a4eb8a09')
31
+ end
32
+ end
33
+
34
+ describe '#analyze' do
35
+ it 'should request to track/profile with id' do
36
+ @api.should_receive(:request).with(
37
+ 'track/analyze',
38
+ :post ,
39
+ :id => 'TRXXHTJ1294CD8F3B3', :bucket => 'audio_summary')
40
+
41
+ @track.analyze(:id => 'TRXXHTJ1294CD8F3B3')
42
+ end
43
+
44
+ it 'should request to track/profile with md5' do
45
+ @api.should_receive(:request).with(
46
+ 'track/analyze',
47
+ :post,
48
+ :md5 => '0cf9c7faab913c62451940e6a4eb8a09', :bucket => 'audio_summary')
49
+
50
+ @track.analyze(:md5 => '0cf9c7faab913c62451940e6a4eb8a09')
51
+ end
52
+ end
53
+
54
+ describe '#upload' do
55
+ it 'should upload by url' do
56
+ @api.should_receive(:request).with(
57
+ 'track/upload',
58
+ :post ,
59
+ :url => 'http://example.com/foo.mp3', :bucket => 'audio_summary')
60
+
61
+ @track.upload(:url => 'http://example.com/foo.mp3')
62
+ end
63
+
64
+ it 'should upload by local filename' do
65
+ filename = fixture('sample.mp3')
66
+
67
+ @api.should_receive(:request).with(
68
+ 'track/upload',
69
+ :post,
70
+ { :bucket => 'audio_summary', :filetype => 'mp3' },
71
+ instance_of(File))
72
+
73
+ @track.upload(:filename => filename)
74
+ end
75
+ end
76
+
77
+ describe '#analysis_url' do
78
+ it 'should return analysis url' do
79
+ @track.should_receive(:profile).
80
+ with(:md5 => 'c2ee3cfddf1eb8631a928a4f662b587c').
81
+ once.
82
+ and_return(Echonest::Response.new(open(fixture('profile_unknown.json')).read))
83
+ @track.should_receive(:upload).
84
+ with(:filename => fixture('sample.mp3')).
85
+ and_return(Echonest::Response.new(open(fixture('profile.json')).read))
86
+ @track.should_receive(:profile).
87
+ with(:md5 => 'c2ee3cfddf1eb8631a928a4f662b587c').
88
+ once.
89
+ and_return(Echonest::Response.new(open(fixture('profile.json')).read))
90
+
91
+ @track.analysis_url(fixture('sample.mp3')).
92
+ should eql('https://echonest-analysis.s3.amazonaws.com:443/TR/TRXXHTJ1294CD8F3B3/3/full.json?Signature=GQMyRUdcO5MUPSHZej72oQHOg3g%3D&Expires=1278605254&AWSAccessKeyId=AKIAJTEJGOTDLQY2E77A')
93
+ end
94
+ end
95
+
96
+ describe '#analysis' do
97
+ it 'should return analysis' do
98
+ analysis_url = 'https://echonest-analysis.s3.amazonaws.com:443/TR/TRXXHTJ1294CD8F3B3/3/full.json?Signature=GQMyRUdcO5MUPSHZej72oQHOg3g%3D&Expires=1278605254&AWSAccessKeyId=AKIAJTEJGOTDLQY2E77A'
99
+ @track.should_receive(:analysis_url).with(fixture('sample.mp3')).and_return(analysis_url)
100
+ Echonest::Analysis.should_receive(:new_from_url).with(analysis_url)
101
+
102
+ @track.analysis(fixture('sample.mp3'))
103
+ end
104
+ end
105
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bassnode-ruby-echonest
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 2
10
+ version: 0.1.2
11
+ platform: ruby
12
+ authors:
13
+ - youpy
14
+ - bassnode
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-04-24 00:00:00 -07:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: libxml-ruby
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: httpclient
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: hashie
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :runtime
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: rspec
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ type: :development
77
+ version_requirements: *id004
78
+ description: An Ruby interface for Echo Nest Developer API
79
+ email: youpy@buycheapviagraonlinenow.com
80
+ executables: []
81
+
82
+ extensions: []
83
+
84
+ extra_rdoc_files:
85
+ - README.rdoc
86
+ - ChangeLog
87
+ files:
88
+ - .gitignore
89
+ - ChangeLog
90
+ - README.rdoc
91
+ - Rakefile
92
+ - bassnode-ruby-echonest.gemspec
93
+ - lib/echonest.rb
94
+ - lib/echonest/analysis.rb
95
+ - lib/echonest/api.rb
96
+ - lib/echonest/element/bar.rb
97
+ - lib/echonest/element/beat.rb
98
+ - lib/echonest/element/loudness.rb
99
+ - lib/echonest/element/section.rb
100
+ - lib/echonest/element/segment.rb
101
+ - lib/echonest/element/tatum.rb
102
+ - lib/echonest/response.rb
103
+ - lib/echonest/traditional_api_methods.rb
104
+ - lib/echonest/version.rb
105
+ - spec/analysis_spec.rb
106
+ - spec/api_spec.rb
107
+ - spec/apimethods_base_spec.rb
108
+ - spec/artist_spec.rb
109
+ - spec/echonest_spec.rb
110
+ - spec/fixtures/analysis.json
111
+ - spec/fixtures/profile.json
112
+ - spec/fixtures/profile_failure.json
113
+ - spec/fixtures/profile_unknown.json
114
+ - spec/fixtures/sample.mp3
115
+ - spec/playlist_spec.rb
116
+ - spec/response_spec.rb
117
+ - spec/song_spec.rb
118
+ - spec/spec.opts
119
+ - spec/spec_helper.rb
120
+ - spec/track_spec.rb
121
+ has_rdoc: true
122
+ homepage: http://github.com/bassnode/ruby-echonest
123
+ licenses: []
124
+
125
+ post_install_message:
126
+ rdoc_options:
127
+ - --title
128
+ - ruby-echonest documentation
129
+ - --charset
130
+ - utf-8
131
+ - --opname
132
+ - index.html
133
+ - --line-numbers
134
+ - --main
135
+ - README.rdoc
136
+ - --inline-source
137
+ - --exclude
138
+ - ^(examples|extras)/
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 3
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ hash: 3
156
+ segments:
157
+ - 0
158
+ version: "0"
159
+ requirements: []
160
+
161
+ rubyforge_project: bassnode-ruby-echonest
162
+ rubygems_version: 1.3.7
163
+ signing_key:
164
+ specification_version: 3
165
+ summary: An Ruby interface for Echo Nest Developer API
166
+ test_files: []
167
+