echowrap 0.0.1

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 (159) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +16 -0
  3. data/Gemfile +13 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +111 -0
  6. data/Rakefile +1 -0
  7. data/echowrap.gemspec +24 -0
  8. data/lib/echowrap/analysis.rb +39 -0
  9. data/lib/echowrap/api/artist.rb +387 -0
  10. data/lib/echowrap/api/oauth.rb +25 -0
  11. data/lib/echowrap/api/playlist.rb +248 -0
  12. data/lib/echowrap/api/sandbox.rb +45 -0
  13. data/lib/echowrap/api/song.rb +111 -0
  14. data/lib/echowrap/api/taste_profile.rb +296 -0
  15. data/lib/echowrap/api/track.rb +64 -0
  16. data/lib/echowrap/api/utils.rb +57 -0
  17. data/lib/echowrap/artist.rb +73 -0
  18. data/lib/echowrap/asset.rb +12 -0
  19. data/lib/echowrap/audio_summary.rb +15 -0
  20. data/lib/echowrap/base.rb +88 -0
  21. data/lib/echowrap/biography.rb +13 -0
  22. data/lib/echowrap/blog.rb +8 -0
  23. data/lib/echowrap/call_list.rb +8 -0
  24. data/lib/echowrap/category_map.rb +8 -0
  25. data/lib/echowrap/client.rb +80 -0
  26. data/lib/echowrap/configurable.rb +84 -0
  27. data/lib/echowrap/default.rb +88 -0
  28. data/lib/echowrap/doc_counts.rb +8 -0
  29. data/lib/echowrap/echonest_id.rb +8 -0
  30. data/lib/echowrap/error/bad_gateway.rb +11 -0
  31. data/lib/echowrap/error/bad_request.rb +10 -0
  32. data/lib/echowrap/error/client_error.rb +35 -0
  33. data/lib/echowrap/error/configuration_error.rb +8 -0
  34. data/lib/echowrap/error/forbidden.rb +10 -0
  35. data/lib/echowrap/error/gateway_timeout.rb +11 -0
  36. data/lib/echowrap/error/internal_server_error.rb +11 -0
  37. data/lib/echowrap/error/not_acceptable.rb +10 -0
  38. data/lib/echowrap/error/not_found.rb +10 -0
  39. data/lib/echowrap/error/server_error.rb +28 -0
  40. data/lib/echowrap/error/service_unavailable.rb +11 -0
  41. data/lib/echowrap/error/too_many_requests.rb +12 -0
  42. data/lib/echowrap/error/unauthorized.rb +10 -0
  43. data/lib/echowrap/error/unprocessable_entity.rb +10 -0
  44. data/lib/echowrap/error.rb +32 -0
  45. data/lib/echowrap/familiarity.rb +8 -0
  46. data/lib/echowrap/feed.rb +14 -0
  47. data/lib/echowrap/foreign_id.rb +10 -0
  48. data/lib/echowrap/genre.rb +8 -0
  49. data/lib/echowrap/hotttnesss.rb +8 -0
  50. data/lib/echowrap/image.rb +15 -0
  51. data/lib/echowrap/item.rb +95 -0
  52. data/lib/echowrap/item_request.rb +8 -0
  53. data/lib/echowrap/keyvalues.rb +8 -0
  54. data/lib/echowrap/license.rb +10 -0
  55. data/lib/echowrap/location.rb +8 -0
  56. data/lib/echowrap/meta.rb +9 -0
  57. data/lib/echowrap/news_article.rb +8 -0
  58. data/lib/echowrap/options.rb +10 -0
  59. data/lib/echowrap/playlist.rb +47 -0
  60. data/lib/echowrap/prediction.rb +7 -0
  61. data/lib/echowrap/rate_limit.rb +47 -0
  62. data/lib/echowrap/reference.rb +8 -0
  63. data/lib/echowrap/request/multipart_with_file.rb +36 -0
  64. data/lib/echowrap/response/parse_json.rb +25 -0
  65. data/lib/echowrap/response/raise_error.rb +31 -0
  66. data/lib/echowrap/review.rb +8 -0
  67. data/lib/echowrap/rule.rb +8 -0
  68. data/lib/echowrap/sandbox.rb +11 -0
  69. data/lib/echowrap/seeds.rb +9 -0
  70. data/lib/echowrap/sequenced_data/bar.rb +4 -0
  71. data/lib/echowrap/sequenced_data/beat.rb +4 -0
  72. data/lib/echowrap/sequenced_data/section.rb +6 -0
  73. data/lib/echowrap/sequenced_data/segment.rb +4 -0
  74. data/lib/echowrap/sequenced_data/tatum.rb +4 -0
  75. data/lib/echowrap/sequenced_data.rb +12 -0
  76. data/lib/echowrap/song.rb +24 -0
  77. data/lib/echowrap/status.rb +12 -0
  78. data/lib/echowrap/taste_profile.rb +28 -0
  79. data/lib/echowrap/term.rb +8 -0
  80. data/lib/echowrap/track.rb +21 -0
  81. data/lib/echowrap/update_info.rb +8 -0
  82. data/lib/echowrap/urls.rb +9 -0
  83. data/lib/echowrap/version.rb +18 -0
  84. data/lib/echowrap/video.rb +7 -0
  85. data/lib/echowrap/years_active.rb +8 -0
  86. data/lib/echowrap.rb +78 -0
  87. data/spec/echonest/api/artist_spec.rb +901 -0
  88. data/spec/echonest/api/oauth_spec.rb +29 -0
  89. data/spec/echonest/api/playlist_spec.rb +274 -0
  90. data/spec/echonest/api/sandbox_spec.rb +67 -0
  91. data/spec/echonest/api/song_spec.rb +326 -0
  92. data/spec/echonest/api/taste_profile_spec.rb +403 -0
  93. data/spec/echonest/api/track_spec.rb +167 -0
  94. data/spec/echonest/base_spec.rb +119 -0
  95. data/spec/echonest/client_spec.rb +174 -0
  96. data/spec/echonest/error_spec.rb +20 -0
  97. data/spec/echonest/rate_limit_spec.rb +76 -0
  98. data/spec/echonest_spec.rb +65 -0
  99. data/spec/fixtures/artist/biographies.json +1 -0
  100. data/spec/fixtures/artist/blogs.json +1 -0
  101. data/spec/fixtures/artist/extract.json +1 -0
  102. data/spec/fixtures/artist/familiarity.json +1 -0
  103. data/spec/fixtures/artist/hotttnesss.json +1 -0
  104. data/spec/fixtures/artist/images.json +1 -0
  105. data/spec/fixtures/artist/list_genres.json +1 -0
  106. data/spec/fixtures/artist/list_terms.json +1 -0
  107. data/spec/fixtures/artist/news.json +1 -0
  108. data/spec/fixtures/artist/profile.json +1 -0
  109. data/spec/fixtures/artist/reviews.json +1 -0
  110. data/spec/fixtures/artist/search.json +1 -0
  111. data/spec/fixtures/artist/similar.json +1 -0
  112. data/spec/fixtures/artist/songs.json +1 -0
  113. data/spec/fixtures/artist/suggest.json +1 -0
  114. data/spec/fixtures/artist/terms.json +1 -0
  115. data/spec/fixtures/artist/top_hottt.json +1 -0
  116. data/spec/fixtures/artist/top_terms.json +1 -0
  117. data/spec/fixtures/artist/twitter.json +1 -0
  118. data/spec/fixtures/artist/urls.json +1 -0
  119. data/spec/fixtures/artist/video.json +1 -0
  120. data/spec/fixtures/billie_jean_fingerprint.txt +1 -0
  121. data/spec/fixtures/billie_jean_query.json +16 -0
  122. data/spec/fixtures/oauth/timestamp.json +1 -0
  123. data/spec/fixtures/playlist/basic.json +1 -0
  124. data/spec/fixtures/playlist/dynamic/create.json +1 -0
  125. data/spec/fixtures/playlist/dynamic/delete.json +1 -0
  126. data/spec/fixtures/playlist/dynamic/feedback.json +1 -0
  127. data/spec/fixtures/playlist/dynamic/info.json +1 -0
  128. data/spec/fixtures/playlist/dynamic/next.json +1 -0
  129. data/spec/fixtures/playlist/dynamic/restart.json +1 -0
  130. data/spec/fixtures/playlist/dynamic/steer.json +1 -0
  131. data/spec/fixtures/playlist/static.json +1 -0
  132. data/spec/fixtures/sandbox/access.json +19 -0
  133. data/spec/fixtures/sandbox/list.json +1 -0
  134. data/spec/fixtures/song/identify.json +19 -0
  135. data/spec/fixtures/song/profile.json +1 -0
  136. data/spec/fixtures/song/search.json +1 -0
  137. data/spec/fixtures/taste_profile/ban.json +9 -0
  138. data/spec/fixtures/taste_profile/create.json +1 -0
  139. data/spec/fixtures/taste_profile/delete.json +11 -0
  140. data/spec/fixtures/taste_profile/favorite.json +9 -0
  141. data/spec/fixtures/taste_profile/feed.json +1 -0
  142. data/spec/fixtures/taste_profile/keyvalues.json +4 -0
  143. data/spec/fixtures/taste_profile/list.json +1 -0
  144. data/spec/fixtures/taste_profile/play.json +9 -0
  145. data/spec/fixtures/taste_profile/predict.json +1 -0
  146. data/spec/fixtures/taste_profile/profile.json +1 -0
  147. data/spec/fixtures/taste_profile/rate.json +9 -0
  148. data/spec/fixtures/taste_profile/read.json +1 -0
  149. data/spec/fixtures/taste_profile/similar.json +14 -0
  150. data/spec/fixtures/taste_profile/skip.json +9 -0
  151. data/spec/fixtures/taste_profile/status.json +2 -0
  152. data/spec/fixtures/taste_profile/update.json +10 -0
  153. data/spec/fixtures/taste_profile/update_request_data.json +4 -0
  154. data/spec/fixtures/technolol-music.mp3 +0 -0
  155. data/spec/fixtures/track/analysis.json +3 -0
  156. data/spec/fixtures/track/profile.json +35 -0
  157. data/spec/fixtures/track/upload.json +21 -0
  158. data/spec/helper.rb +50 -0
  159. metadata +323 -0
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *~
19
+ .rvmrc
20
+ .ruby-version
21
+ log/*
22
+ .DS_Store
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ bundler_args: --without development
2
+ language: ruby
3
+ rvm:
4
+ - jruby-19mode
5
+ - rbx-18mode
6
+ - rbx-19mode
7
+ - 1.9.2
8
+ - 1.9.3
9
+ - 2.0.0
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: jruby-18mode
13
+ - rvm: rbx-18mode
14
+ - rvm: rbx-19mode
15
+ - rvm: 1.8.7
16
+ script: bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+
5
+ group :test do
6
+ gem 'coveralls', :require => false
7
+ gem 'rspec'
8
+ gem 'webmock'
9
+ gem 'timecop'
10
+ end
11
+
12
+ # Specify your gem's dependencies in echonest.gemspec
13
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tim Case
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # The Echowrap Ruby Gem
2
+ [![Echonest](http://echonest.com/static/img/logos/250x200_dk.gif)](http://developer.echonest.com/index.html)
3
+
4
+ A Ruby interface to the Echonest API. The Echonest API is based on their
5
+ automatically derived-database of about 30 million songs which
6
+ is aggregated using web crawling, data mining, and digital signal
7
+ processing techniques. The API includes support for music
8
+ recommendation, artist recommendation, playlist generation, acoustic
9
+ analysis, music identification, and data feeds. Details about the API
10
+ can be found at http://developer.echonest.com/
11
+
12
+ * This wrapper supports 100% of the [Echonest API Version 4](http://developer.echonest.com/docs/v4)
13
+ * Data returned from API calls are mapped into Ruby objects
14
+ * Various http clients are supported via [Faraday](https://github.com/lostisland/faraday)
15
+ * Uses Unix philosophy of "do one thing and do it well"
16
+
17
+ [![Dependency Status](https://gemnasium.com/timcase/echonest.png)](https://gemnasium.com/timcase/echonest)
18
+ [![Build
19
+ Status](https://travis-ci.org/timcase/echowrap.png)](https://travis-ci.org/timcase/echowrap)
20
+ [![Code Climate](https://codeclimate.com/github/timcase/echonest.png)](https://codeclimate.com/github/timcase/echonest)
21
+ [![Coverage Status](https://coveralls.io/repos/timcase/echonest/badge.png?branch=master)](https://coveralls.io/r/timcase/echonest?branch=master)
22
+
23
+ ## Supported Rubies
24
+ This library is [tested against](https://travis-ci.org/timcase/echonest) the following Ruby implentations
25
+ * Ruby 1.9.2
26
+ * Ruby 1.9.3
27
+ * Ruby 2.0
28
+ * JRuby 1.9 mode
29
+
30
+ ## Gem Dependencies
31
+ Installing this gem also installs the following gems:
32
+
33
+ * [faraday](https://github.com/lostisland/faraday) HTTP client lib that provides a common interface over many adapters (such as Net::HTTP) and embraces the concept of Rack middleware when processing the request/response cycle.
34
+ * [multi_json](https://github.com/intridea/multi_json) A common interface to multiple JSON libraries, including Oj, Yajl, the JSON gem (with C-extensions), the pure-Ruby JSON gem, NSJSONSerialization, gson.rb, JrJackson, and OkJson.
35
+ * [simple_oauth](https://github.com/laserlemon/simple_oauth) Builds and verifies OAuth headers
36
+
37
+ ## Installation
38
+
39
+ Add this line to your application's Gemfile:
40
+ ```ruby
41
+ gem 'echowrap'
42
+ ```
43
+ And then execute:
44
+ ```shell
45
+ $ bundle install
46
+ ```
47
+ Or install it yourself as:
48
+ ```shell
49
+ $ gem install echowrap
50
+ ```
51
+ ## Quick Start Guide
52
+
53
+ First, [get an api key from Echonest][register].
54
+
55
+ Then copy and paste in your API keys:
56
+
57
+ ```ruby
58
+ Echowrap.configure do |config|
59
+ config.api_key = 'YOUR_API_KEY'
60
+ config.consumer_key = 'YOUR_CONSUMER_KEY'
61
+ config.shared_secret = 'YOUR_SHARED_SECRET'
62
+ end
63
+ ```
64
+ You are ready to use Echowrap:
65
+
66
+ ```ruby
67
+ Echowrap.song_search(artist: 'Daft Punk')
68
+ ```
69
+
70
+ [register]: http://developer.echonest.com/account/register
71
+
72
+ ## Usage
73
+ See [Usage page](https://github.com/timcase/echonest/wiki) for a complete listing of the api methods
74
+
75
+ ## Tests
76
+ An Rspec test suite is available to ensure API functionality:
77
+
78
+ 1. $ git clone git://github.com/timcase/echowrap.git
79
+ 2. $ bundle install (installs rspec and other supporting gems, see
80
+ [GEMFILE](https://github.com/timcase/echonest/blob/master/Gemfile)
81
+ for complete listing)
82
+ 3. $ rspec
83
+
84
+ ## More Information
85
+ More information can be found on the [project website on
86
+ GitHub](https://github.com/timcase/echowrap). There is extensive usage
87
+ documentation available [on the
88
+ wiki](https://github.com/timcase/echowrap/wiki).
89
+
90
+ ## API Documentation
91
+
92
+ ## License
93
+ Echowrap is released under the [MIT
94
+ License](https://github.com/timcase/echowrap/blob/master/LICENSE.txt).
95
+
96
+ ## Support
97
+ Bug reports and feature requests should be filed on the [github issue
98
+ tracking page](https://github.com/timcase/echowrap/issues).
99
+
100
+ ## Contributing
101
+
102
+ 1. Fork it
103
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
104
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
105
+ 4. Push to the branch (`git push origin my-new-feature`)
106
+ 5. Create new Pull Request
107
+
108
+ ##Acknowledgement
109
+ Much of the heavy lifting was done by studying the [Twitter gem](https://github.com/sferik/twitter).
110
+ ##Contributors
111
+ [Tim Case](timcase.me)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/echowrap.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'echowrap/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "echowrap"
8
+ gem.version = Echowrap::Version
9
+ gem.authors = ["Tim Case"]
10
+ gem.email = ["tim@2drops.net"]
11
+ gem.description = %q{A Ruby interface to the Echonest API, details can be found at http://echowrap.com.}
12
+ gem.summary = %q{A Ruby interface to the Echonest API.}
13
+ gem.homepage = "https://github.com/timcase/echowrap"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'faraday', '~> 0.9.0.rc5'
21
+ gem.add_dependency 'multi_json', '~> 1.7.7'
22
+ gem.add_dependency 'simple_oauth', '~> 0.2'
23
+
24
+ end
@@ -0,0 +1,39 @@
1
+ require 'echowrap/base'
2
+
3
+ module Echowrap
4
+ class Analysis < Echowrap::Base
5
+
6
+ def bars
7
+ @bars ||= map_collection(Echowrap::Bar, :bars)
8
+ end
9
+
10
+ def beats
11
+ @beats ||= map_collection(Echowrap::Beat, :beats)
12
+ end
13
+
14
+ def id
15
+ @attrs[:meta][:timestamp]
16
+ end
17
+
18
+ def meta
19
+ @meta ||= Echowrap::Meta.new(@attrs[:meta])
20
+ end
21
+
22
+ def sections
23
+ @sections ||= map_collection(Echowrap::Section, :sections)
24
+ end
25
+
26
+ def segments
27
+ @segments ||= map_collection(Echowrap::Segment, :segments)
28
+ end
29
+
30
+ def tatums
31
+ @tatums ||= map_collection(Echowrap::Tatum, :tatums)
32
+ end
33
+
34
+ def track
35
+ @track ||= Echowrap::Track.new(@attrs[:track])
36
+ end
37
+
38
+ end
39
+ end