ruby-echonest 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ pkg
2
+ coverage
3
+ *.gem
4
+ /example*
5
+ *~
6
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,13 +1,3 @@
1
1
  source :rubygems
2
2
 
3
- gem 'rake', '0.9.2.2'
4
- gem 'httpclient'
5
- gem 'hashie'
6
- gem 'libxml-ruby'
7
- gem 'jeweler'
8
-
9
- group :development do
10
- gem 'rspec', '>= 2.0.0'
11
- gem 'rdoc'
12
- end
13
-
3
+ gemspec
data/Rakefile CHANGED
@@ -1,31 +1,10 @@
1
- require 'bundler'
2
- Bundler.require
3
-
4
- $LOAD_PATH.unshift "lib"
5
- require 'echonest'
6
-
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "ruby-echonest"
9
- gem.version = Echonest::VERSION
10
- gem.summary = "An Ruby interface for Echo Nest Developer API"
11
- gem.description = "An Ruby interface for Echo Nest Developer API"
12
- gem.email = "youpy@buycheapviagraonlinenow.com"
13
- gem.homepage = "http://github.com/youpy/ruby-echonest"
14
- gem.authors = ["youpy"]
15
- end
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
16
3
 
4
+ require 'rspec/core'
17
5
  require 'rspec/core/rake_task'
18
-
19
- RSpec::Core::RakeTask.new(:core) do |spec|
20
- spec.pattern = 'spec/**/*_spec.rb'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
21
8
  end
22
9
 
23
- task :default => :core
24
-
25
- require 'rdoc/task'
26
- Rake::RDocTask.new do |rdoc|
27
- rdoc.rdoc_dir = 'rdoc'
28
- rdoc.title = "echonest %s" % Echonest::VERSION
29
- rdoc.rdoc_files.include('README*')
30
- rdoc.rdoc_files.include('lib/**/*.rb')
31
- end
10
+ task :default => :spec
data/lib/echonest/api.rb CHANGED
@@ -13,6 +13,7 @@ module Echonest
13
13
  include TraditionalApiMethods
14
14
 
15
15
  class Error < StandardError; end
16
+ class UnsupportedFiletypeError < StandardError; end
16
17
 
17
18
  attr_reader :user_agent
18
19
 
@@ -106,7 +107,7 @@ module Echonest
106
107
 
107
108
  if options.has_key?(:filename)
108
109
  filename = options.delete(:filename)
109
- filetype = filename.to_s.match(/\.(mp3|au|ogg)$/)[1]
110
+ filetype = parse_filetype(filename)
110
111
 
111
112
  open(filename) do |f|
112
113
  @api.request('track/upload',
@@ -164,6 +165,20 @@ module Echonest
164
165
  sleep 5
165
166
  end
166
167
  end
168
+
169
+ private
170
+
171
+ def parse_filetype(filename)
172
+ filetype = filename.to_s.match(/\.(wav|mp3|au|ogg|m4a|mp4|aif|aiff)$/)
173
+
174
+ if !filetype
175
+ raise Api::UnsupportedFiletypeError
176
+ elsif ['aif', 'aiff'].include? filetype[1]
177
+ 'wav'
178
+ else
179
+ filetype[1]
180
+ end
181
+ end
167
182
  end
168
183
  end
169
184
  end
@@ -1,3 +1,3 @@
1
1
  module Echonest
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -1,39 +1,25 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/echonest/version', __FILE__)
2
3
 
3
- Gem::Specification.new do |s|
4
- s.name = %q{ruby-echonest}
5
- s.version = "0.1.0"
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["youpy"]
6
+ gem.email = ["youpy@buycheapviagraonlinenow.com"]
7
+ gem.description = %q{An Ruby interface for Echo Nest Developer API}
8
+ gem.summary = %q{An Ruby interface for Echo Nest Developer API}
9
+ gem.homepage = "http://github.com/youpy/ruby-echonest"
6
10
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["youpy"]
9
- s.date = %q{2010-08-24}
10
- s.description = %q{An Ruby interface for Echo Nest Developer API}
11
- s.email = %q{youpy@buycheapviagraonlinenow.com}
12
- s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
13
- s.files = ["README.rdoc", "ChangeLog", "Rakefile", "spec/analysis_spec.rb", "spec/api_spec.rb", "spec/echonest_spec.rb", "spec/fixtures", "spec/fixtures/analysis.json", "spec/fixtures/profile.json", "spec/fixtures/profile_failure.json", "spec/fixtures/profile_unknown.json", "spec/fixtures/sample.mp3", "spec/response_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/track_spec.rb", "lib/echonest", "lib/echonest/analysis.rb", "lib/echonest/api.rb", "lib/echonest/element", "lib/echonest/element/bar.rb", "lib/echonest/element/beat.rb", "lib/echonest/element/loudness.rb", "lib/echonest/element/section.rb", "lib/echonest/element/segment.rb", "lib/echonest/element/tatum.rb", "lib/echonest/response.rb", "lib/echonest/traditional_api_methods.rb", "lib/echonest/version.rb", "lib/echonest.rb"]
14
- s.homepage = %q{http://github.com/youpy/ruby-echonest}
15
- s.rdoc_options = ["--title", "ruby-echonest documentation", "--charset", "utf-8", "--opname", "index.html", "--line-numbers", "--main", "README.rdoc", "--inline-source", "--exclude", "^(examples|extras)/"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = %q{ruby-echonest}
18
- s.rubygems_version = %q{1.3.6}
19
- s.summary = %q{An Ruby interface for Echo Nest Developer API}
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "ruby-echonest"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Echonest::VERSION
20
17
 
21
- if s.respond_to? :specification_version then
22
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
- s.specification_version = 3
18
+ gem.add_dependency('httpclient')
19
+ gem.add_dependency('hashie')
20
+ gem.add_dependency('libxml-ruby')
24
21
 
25
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<libxml-ruby>, [">= 0"])
27
- s.add_runtime_dependency(%q<httpclient>, [">= 0"])
28
- s.add_runtime_dependency(%q<hashie>, [">= 0"])
29
- else
30
- s.add_dependency(%q<libxml-ruby>, [">= 0"])
31
- s.add_dependency(%q<httpclient>, [">= 0"])
32
- s.add_dependency(%q<hashie>, [">= 0"])
33
- end
34
- else
35
- s.add_dependency(%q<libxml-ruby>, [">= 0"])
36
- s.add_dependency(%q<httpclient>, [">= 0"])
37
- s.add_dependency(%q<hashie>, [">= 0"])
38
- end
22
+ gem.add_development_dependency('rspec', ['~> 2.8.0'])
23
+ gem.add_development_dependency('rake')
24
+ gem.add_development_dependency('ruby-echonest')
39
25
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/spec/track_spec.rb CHANGED
@@ -69,16 +69,43 @@ describe Echonest::ApiMethods::Track do
69
69
  @track.upload(:url => 'http://example.com/foo.mp3')
70
70
  end
71
71
 
72
- it 'should upload by local filename' do
73
- filename = fixture('sample.mp3')
72
+ %w{ wav mp3 au ogg m4a mp4 }.each do |filetype|
73
+ it "should upload '#{filetype}' by local filename" do
74
+ filename = fixture("sample.#{filetype}")
75
+
76
+ @api.should_receive(:request).with(
77
+ 'track/upload',
78
+ :post,
79
+ { :bucket => 'audio_summary', :filetype => filetype },
80
+ instance_of(File))
81
+
82
+ @track.upload(:filename => filename)
83
+ end
84
+ end
74
85
 
75
- @api.should_receive(:request).with(
76
- 'track/upload',
77
- :post,
78
- { :bucket => 'audio_summary', :filetype => 'mp3' },
79
- instance_of(File))
86
+ %w{ aif aiff }.each do |filetype|
87
+ it "should upload '#{filetype}' as filetype wav" do
88
+ # we are tricking the echonest api here
89
+ # they do aiff, but only if we pretend it's wav
90
+
91
+ filename = fixture("sample.#{filetype}")
92
+
93
+ @api.should_receive(:request).with(
94
+ 'track/upload',
95
+ :post,
96
+ { :bucket => 'audio_summary', :filetype => 'wav' },
97
+ instance_of(File))
98
+
99
+ @track.upload(:filename => filename)
100
+ end
101
+ end
102
+
103
+ it "should throw exception if unsupported FileType" do
104
+ filename = fixture("profile.json")
80
105
 
81
- @track.upload(:filename => filename)
106
+ expect do
107
+ @track.upload(:filename => filename)
108
+ end.to raise_error(Echonest::Api::UnsupportedFiletypeError)
82
109
  end
83
110
  end
84
111
 
metadata CHANGED
@@ -1,125 +1,123 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-echonest
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 0
9
- version: 0.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - youpy
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-01-09 00:00:00 +09:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- type: :runtime
23
- name: rake
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
25
- requirements:
26
- - - "="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 9
31
- - 2
32
- - 2
33
- version: 0.9.2.2
34
- requirement: *id001
35
- - !ruby/object:Gem::Dependency
36
- prerelease: false
37
- type: :runtime
12
+ date: 2012-12-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
38
15
  name: httpclient
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- segments:
44
- - 0
45
- version: "0"
46
- requirement: *id002
47
- - !ruby/object:Gem::Dependency
48
- prerelease: false
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
49
22
  type: :runtime
50
- name: hashie
51
- version_requirements: &id003 !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- version: "0"
58
- requirement: *id003
59
- - !ruby/object:Gem::Dependency
60
23
  prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: hashie
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
61
38
  type: :runtime
62
- name: libxml-ruby
63
- version_requirements: &id004 !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
- version: "0"
70
- requirement: *id004
71
- - !ruby/object:Gem::Dependency
72
39
  prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: libxml-ruby
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
73
54
  type: :runtime
74
- name: jeweler
75
- version_requirements: &id005 !ruby/object:Gem::Requirement
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- segments:
80
- - 0
81
- version: "0"
82
- requirement: *id005
83
- - !ruby/object:Gem::Dependency
84
55
  prerelease: false
85
- type: :development
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
86
63
  name: rspec
87
- version_requirements: &id006 !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- segments:
92
- - 2
93
- - 0
94
- - 0
95
- version: 2.0.0
96
- requirement: *id006
97
- - !ruby/object:Gem::Dependency
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.8.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.8.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
98
87
  prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: ruby-echonest
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
99
102
  type: :development
100
- name: rdoc
101
- version_requirements: &id007 !ruby/object:Gem::Requirement
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- segments:
106
- - 0
107
- version: "0"
108
- requirement: *id007
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
109
110
  description: An Ruby interface for Echo Nest Developer API
110
- email: youpy@buycheapviagraonlinenow.com
111
+ email:
112
+ - youpy@buycheapviagraonlinenow.com
111
113
  executables: []
112
-
113
114
  extensions: []
114
-
115
- extra_rdoc_files:
116
- - ChangeLog
117
- - README.rdoc
118
- files:
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
119
118
  - .rspec
120
119
  - ChangeLog
121
120
  - Gemfile
122
- - Gemfile.lock
123
121
  - README.rdoc
124
122
  - Rakefile
125
123
  - lib/echonest.rb
@@ -142,39 +140,63 @@ files:
142
140
  - spec/fixtures/profile.json
143
141
  - spec/fixtures/profile_failure.json
144
142
  - spec/fixtures/profile_unknown.json
143
+ - spec/fixtures/sample.aif
144
+ - spec/fixtures/sample.aiff
145
+ - spec/fixtures/sample.au
146
+ - spec/fixtures/sample.m4a
145
147
  - spec/fixtures/sample.mp3
148
+ - spec/fixtures/sample.mp4
149
+ - spec/fixtures/sample.ogg
150
+ - spec/fixtures/sample.wav
146
151
  - spec/response_spec.rb
147
152
  - spec/spec_helper.rb
148
153
  - spec/track_spec.rb
149
- has_rdoc: true
150
154
  homepage: http://github.com/youpy/ruby-echonest
151
155
  licenses: []
152
-
153
156
  post_install_message:
154
157
  rdoc_options: []
155
-
156
- require_paths:
158
+ require_paths:
157
159
  - lib
158
- required_ruby_version: !ruby/object:Gem::Requirement
159
- requirements:
160
- - - ">="
161
- - !ruby/object:Gem::Version
162
- segments:
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ segments:
163
167
  - 0
164
- version: "0"
165
- required_rubygems_version: !ruby/object:Gem::Requirement
166
- requirements:
167
- - - ">="
168
- - !ruby/object:Gem::Version
169
- segments:
168
+ hash: 1320993124817053134
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ none: false
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ segments:
170
176
  - 0
171
- version: "0"
177
+ hash: 1320993124817053134
172
178
  requirements: []
173
-
174
179
  rubyforge_project:
175
- rubygems_version: 1.3.6
180
+ rubygems_version: 1.8.24
176
181
  signing_key:
177
182
  specification_version: 3
178
183
  summary: An Ruby interface for Echo Nest Developer API
179
- test_files: []
180
-
184
+ test_files:
185
+ - spec/analysis_spec.rb
186
+ - spec/api_spec.rb
187
+ - spec/echonest_spec.rb
188
+ - spec/fixtures/analysis.json
189
+ - spec/fixtures/profile.json
190
+ - spec/fixtures/profile_failure.json
191
+ - spec/fixtures/profile_unknown.json
192
+ - spec/fixtures/sample.aif
193
+ - spec/fixtures/sample.aiff
194
+ - spec/fixtures/sample.au
195
+ - spec/fixtures/sample.m4a
196
+ - spec/fixtures/sample.mp3
197
+ - spec/fixtures/sample.mp4
198
+ - spec/fixtures/sample.ogg
199
+ - spec/fixtures/sample.wav
200
+ - spec/response_spec.rb
201
+ - spec/spec_helper.rb
202
+ - spec/track_spec.rb
data/Gemfile.lock DELETED
@@ -1,36 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- diff-lcs (1.1.3)
5
- git (1.2.5)
6
- hashie (1.2.0)
7
- httpclient (2.2.1)
8
- jeweler (1.6.4)
9
- bundler (~> 1.0)
10
- git (>= 1.2.5)
11
- rake
12
- json (1.6.3)
13
- libxml-ruby (2.2.2)
14
- rake (0.9.2.2)
15
- rdoc (3.11)
16
- json (~> 1.4)
17
- rspec (2.7.0)
18
- rspec-core (~> 2.7.0)
19
- rspec-expectations (~> 2.7.0)
20
- rspec-mocks (~> 2.7.0)
21
- rspec-core (2.7.1)
22
- rspec-expectations (2.7.0)
23
- diff-lcs (~> 1.1.2)
24
- rspec-mocks (2.7.0)
25
-
26
- PLATFORMS
27
- ruby
28
-
29
- DEPENDENCIES
30
- hashie
31
- httpclient
32
- jeweler
33
- libxml-ruby
34
- rake (= 0.9.2.2)
35
- rdoc
36
- rspec (>= 2.0.0)