freesound_ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +50 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +61 -0
- data/LICENSE.txt +22 -0
- data/README.md +78 -0
- data/Rakefile +6 -0
- data/freesound_ruby.gemspec +29 -0
- data/lib/freesound.rb +14 -0
- data/lib/freesound/client.rb +41 -0
- data/lib/freesound/collections.rb +26 -0
- data/lib/freesound/resources.rb +94 -0
- data/lib/freesound/version.rb +3 -0
- data/spec/helper.rb +2 -0
- data/spec/integration/find_pack_spec.rb +28 -0
- data/spec/integration/find_sound_spec.rb +34 -0
- data/spec/integration/find_user_spec.rb +29 -0
- data/spec/integration/helper.rb +14 -0
- data/spec/integration/pack_resources_spec.rb +18 -0
- data/spec/integration/search_sound_spec.rb +12 -0
- data/spec/integration/user_resources_spec.rb +25 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c7c330090c9136df4e109206164576ffd359f6cc
|
4
|
+
data.tar.gz: 937d092aa4adf2e3c0f7acbba0fad50bc835c4b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a11224e534629891ab316b28a1e51f731fb9d3a1475fbb2645d264bd226b7f2b0d33bcd0fcc9e9681408a537aba96ca1101a414c352d28df2fd67dee0130ea97
|
7
|
+
data.tar.gz: 695e4678310c54541367837d5050a858c1ad51af4580469ca09380eb6b79a9f1fd59298875fbc812fb898439a49d35940ab876b83d78f42353d56b49e23f5711
|
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
|
4
|
+
# rdoc generated
|
5
|
+
rdoc
|
6
|
+
|
7
|
+
# yard generated
|
8
|
+
doc
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# bundler
|
12
|
+
.bundle
|
13
|
+
|
14
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
15
|
+
#
|
16
|
+
# * Create a file at ~/.gitignore
|
17
|
+
# * Include files you want ignored
|
18
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
19
|
+
#
|
20
|
+
# After doing this, these files will be ignored in all your git projects,
|
21
|
+
# saving you from having to 'pollute' every project you touch with them
|
22
|
+
#
|
23
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
24
|
+
#
|
25
|
+
# For MacOS:
|
26
|
+
#
|
27
|
+
#.DS_Store
|
28
|
+
|
29
|
+
# For TextMate
|
30
|
+
#*.tmproj
|
31
|
+
#tmtags
|
32
|
+
|
33
|
+
# For emacs:
|
34
|
+
#*~
|
35
|
+
#\#*
|
36
|
+
#.\#*
|
37
|
+
|
38
|
+
# For vim:
|
39
|
+
*.swp
|
40
|
+
|
41
|
+
# For redcar:
|
42
|
+
#.redcar
|
43
|
+
|
44
|
+
# For rubinius:
|
45
|
+
#*.rbc
|
46
|
+
|
47
|
+
*.gem
|
48
|
+
|
49
|
+
# VCR Cassettes
|
50
|
+
spec/fixtures/vcr_cassettes
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
freesound_ruby (0.1.0)
|
5
|
+
activeresource (~> 4.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (4.0.2)
|
11
|
+
activesupport (= 4.0.2)
|
12
|
+
builder (~> 3.1.0)
|
13
|
+
activeresource (4.0.0)
|
14
|
+
activemodel (~> 4.0)
|
15
|
+
activesupport (~> 4.0)
|
16
|
+
rails-observers (~> 0.1.1)
|
17
|
+
activesupport (4.0.2)
|
18
|
+
i18n (~> 0.6, >= 0.6.4)
|
19
|
+
minitest (~> 4.2)
|
20
|
+
multi_json (~> 1.3)
|
21
|
+
thread_safe (~> 0.1)
|
22
|
+
tzinfo (~> 0.3.37)
|
23
|
+
addressable (2.3.5)
|
24
|
+
atomic (1.1.14)
|
25
|
+
builder (3.1.4)
|
26
|
+
crack (0.4.1)
|
27
|
+
safe_yaml (~> 0.9.0)
|
28
|
+
diff-lcs (1.2.5)
|
29
|
+
i18n (0.6.9)
|
30
|
+
minitest (4.7.5)
|
31
|
+
multi_json (1.8.2)
|
32
|
+
rails-observers (0.1.2)
|
33
|
+
activemodel (~> 4.0)
|
34
|
+
rake (10.1.0)
|
35
|
+
rspec (2.14.1)
|
36
|
+
rspec-core (~> 2.14.0)
|
37
|
+
rspec-expectations (~> 2.14.0)
|
38
|
+
rspec-mocks (~> 2.14.0)
|
39
|
+
rspec-core (2.14.7)
|
40
|
+
rspec-expectations (2.14.4)
|
41
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
42
|
+
rspec-mocks (2.14.4)
|
43
|
+
safe_yaml (0.9.7)
|
44
|
+
thread_safe (0.1.3)
|
45
|
+
atomic
|
46
|
+
tzinfo (0.3.38)
|
47
|
+
vcr (2.8.0)
|
48
|
+
webmock (1.8.11)
|
49
|
+
addressable (>= 2.2.7)
|
50
|
+
crack (>= 0.1.7)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
bundler
|
57
|
+
freesound_ruby!
|
58
|
+
rake
|
59
|
+
rspec
|
60
|
+
vcr (~> 2.8.0)
|
61
|
+
webmock (~> 1.8.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Alex Genco
|
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,78 @@
|
|
1
|
+
# Freesound Ruby
|
2
|
+
|
3
|
+
Consume the [Freesound.org](http://www.freesound.org) API with Ruby.
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/alexgenco/freesound_ruby.png)](https://travis-ci.org/alexgenco/freesound_ruby)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/alexgenco/freesound_ruby.png)](https://codeclimate.com/github/alexgenco/freesound_ruby)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'freesound_ruby'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install freesound_ruby
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
You will need an [API key](http://www.freesound.org/api/apply) to use the Freesound gem:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require 'freesound'
|
28
|
+
Freesound.api_key = "your_api_key"
|
29
|
+
```
|
30
|
+
|
31
|
+
And a client object:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
client = Freesound::Client.new
|
35
|
+
```
|
36
|
+
|
37
|
+
Freesound exposes three resources:
|
38
|
+
[sounds](http://www.freesound.org/docs/api/resources.html#sound-resource),
|
39
|
+
[users](http://www.freesound.org/docs/api/resources.html#users), and
|
40
|
+
[packs](http://www.freesound.org/docs/api/resources.html#packs).
|
41
|
+
You can request them directly from the client:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
sound = client.sound(17185)
|
45
|
+
user = client.user("alexgenco")
|
46
|
+
pack = client.pack(5107)
|
47
|
+
```
|
48
|
+
|
49
|
+
Resources will respond to any attributes returned by the API:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
sound.bitrate # => 1411
|
53
|
+
user.username # => "alexgenco"
|
54
|
+
pack.name # => "Iceland"
|
55
|
+
```
|
56
|
+
|
57
|
+
You can also search for sounds:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
client.search("kick") # => (many sounds)
|
61
|
+
```
|
62
|
+
|
63
|
+
The Freesound API also supports pagination and robust search filters, but this
|
64
|
+
library doesn't support them quite yet.
|
65
|
+
|
66
|
+
More features to come!
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
1. Fork it
|
71
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
72
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
73
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
74
|
+
5. Create new Pull Request
|
75
|
+
|
76
|
+
You will need a Freesound.org API key to run the integration tests.
|
77
|
+
Get one [here](http://www.freesound.org/api/apply) and assign it to the
|
78
|
+
FREESOUND_KEY environment variable.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'freesound/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "freesound_ruby"
|
8
|
+
spec.version = Freesound::VERSION
|
9
|
+
spec.authors = ["Alex Genco"]
|
10
|
+
spec.email = ["alexgenco@gmail.com"]
|
11
|
+
spec.summary = "A Ruby library for consuming the Freesound.org API"
|
12
|
+
spec.homepage = "https://github.com/alexgenco/freesound_ruby"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.required_ruby_version = '>= 1.9.3'
|
21
|
+
|
22
|
+
spec.add_dependency "activeresource", "~> 4.0.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "webmock", "~> 1.8.0"
|
28
|
+
spec.add_development_dependency "vcr", "~> 2.8.0"
|
29
|
+
end
|
data/lib/freesound.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "freesound/version"
|
2
|
+
require "freesound/client"
|
3
|
+
require "freesound/collections"
|
4
|
+
require "freesound/resources"
|
5
|
+
|
6
|
+
module Freesound
|
7
|
+
class << self
|
8
|
+
attr_writer :api_key
|
9
|
+
|
10
|
+
def api_key
|
11
|
+
@api_key || raise("Freesound requires an api_key")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "freesound/resources"
|
2
|
+
|
3
|
+
module Freesound
|
4
|
+
class ResourceNotFound < RuntimeError; end
|
5
|
+
|
6
|
+
class Client
|
7
|
+
def sound(id)
|
8
|
+
begin
|
9
|
+
Resources::Sound.find(id, params: query_params)
|
10
|
+
rescue ActiveResource::BadRequest
|
11
|
+
raise ResourceNotFound, "Sound with id #{id} not found"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def user(username)
|
16
|
+
begin
|
17
|
+
Resources::User.find(username, params: query_params)
|
18
|
+
rescue ActiveResource::BadRequest
|
19
|
+
raise ResourceNotFound, "User with username '#{username}' not found"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def pack(id)
|
24
|
+
begin
|
25
|
+
Resources::Pack.find(id, params: query_params)
|
26
|
+
rescue ActiveResource::BadRequest
|
27
|
+
raise ResourceNotFound, "Pack with id #{id} not found"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def search(query)
|
32
|
+
Resources::Sound.get(:search, query_params(q: query))
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def query_params(additional={})
|
38
|
+
{api_key: Freesound.api_key}.merge(additional)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "active_resource"
|
2
|
+
|
3
|
+
module Freesound
|
4
|
+
module Collections
|
5
|
+
# Collections are required to tell ActiveResource how to parse JSON
|
6
|
+
# responses that wrap a collection of resources.
|
7
|
+
#
|
8
|
+
# The #__collection_key method determines the JSON key containing the
|
9
|
+
# resource data.
|
10
|
+
#
|
11
|
+
class Base < ActiveResource::Collection
|
12
|
+
def initialize(parsed={})
|
13
|
+
@elements = parsed.fetch(__collection_key)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def __collection_key
|
19
|
+
self.class.name.demodulize.underscore
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Sounds < Base; end
|
24
|
+
class Packs < Base; end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require "active_resource"
|
2
|
+
require "uri"
|
3
|
+
|
4
|
+
require "freesound/collections"
|
5
|
+
|
6
|
+
module Freesound
|
7
|
+
module Resources
|
8
|
+
class Base < ActiveResource::Base
|
9
|
+
self.site = "http://www.freesound.org/api"
|
10
|
+
self.include_format_in_path = false
|
11
|
+
|
12
|
+
class << self
|
13
|
+
# The Freesound API requires URLs to have a trailing slash before their
|
14
|
+
# query parameters, otherwise the request will result in a redirect.
|
15
|
+
#
|
16
|
+
# These are hacks to construct the URLs correctly because ActiveResource
|
17
|
+
# does not append a trailing slash.
|
18
|
+
#
|
19
|
+
def element_path(id, *args)
|
20
|
+
super("#{id}/", *args)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(path, *args)
|
24
|
+
super("#{path}/", *args)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Macro for establishing relationships.
|
28
|
+
#
|
29
|
+
# Resources return has_many relationships as a URL, rather than a
|
30
|
+
# collection of objects. For example user JSON would look like:
|
31
|
+
#
|
32
|
+
# {
|
33
|
+
# username: "alexgenco",
|
34
|
+
# sounds: "http://www.freesound.org/api/people/alexgenco/sounds/"
|
35
|
+
# }
|
36
|
+
#
|
37
|
+
# This macro generates methods to access these child resources by
|
38
|
+
# following the URL and instantiating the appropriate resource.
|
39
|
+
#
|
40
|
+
# To setup a User that has many sounds:
|
41
|
+
#
|
42
|
+
# class User
|
43
|
+
# references :sounds
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
def references(collection_name)
|
47
|
+
resource_class = collection_name.to_s.singularize.camelize
|
48
|
+
|
49
|
+
class_eval(<<-RUBY, __FILE__, __LINE__)
|
50
|
+
def #{collection_name}(refresh=false)
|
51
|
+
@#{collection_name} = nil if refresh
|
52
|
+
|
53
|
+
@#{collection_name} ||= begin
|
54
|
+
path = URI.parse(super).path
|
55
|
+
#{resource_class}.find(:all, from: path, params: query_params)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
RUBY
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def query_params(additional={})
|
65
|
+
{api_key: Freesound.api_key}.merge(additional)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class User < Base
|
70
|
+
self.collection_name = "people"
|
71
|
+
|
72
|
+
references :sounds
|
73
|
+
references :packs
|
74
|
+
|
75
|
+
# User resources are identified by their username, for example:
|
76
|
+
#
|
77
|
+
# /api/people/alexgenco
|
78
|
+
#
|
79
|
+
def id
|
80
|
+
username
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class Sound < Base
|
85
|
+
self.collection_parser = "Freesound::Collections::Sounds"
|
86
|
+
end
|
87
|
+
|
88
|
+
class Pack < Base
|
89
|
+
self.collection_parser = "Freesound::Collections::Packs"
|
90
|
+
|
91
|
+
references :sounds
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "integration/helper"
|
2
|
+
|
3
|
+
describe "finding a pack" do
|
4
|
+
let(:client) { Freesound::Client.new }
|
5
|
+
|
6
|
+
context "that exists" do
|
7
|
+
let(:pack) do
|
8
|
+
VCR.use_cassette(:pack_5107) do
|
9
|
+
client.pack(5107)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns an object with pack attributes" do
|
14
|
+
expect(pack.ref).to match(/packs/)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "that doesn't exist" do
|
19
|
+
it "raises an exception" do
|
20
|
+
expect {
|
21
|
+
VCR.use_cassette(:pack_unknown) do
|
22
|
+
client.pack(123456789)
|
23
|
+
end
|
24
|
+
}.to raise_error(Freesound::ResourceNotFound,
|
25
|
+
/pack with id 123456789/i)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "integration/helper"
|
2
|
+
|
3
|
+
describe "finding a sound" do
|
4
|
+
let(:client) { Freesound::Client.new }
|
5
|
+
|
6
|
+
context "that exists" do
|
7
|
+
let(:sound) do
|
8
|
+
VCR.use_cassette(:sound_18763) do
|
9
|
+
client.sound(18763)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns an object with sound attributes" do
|
14
|
+
expect(sound.id).to be(18763)
|
15
|
+
expect(sound.ref).to match(/\/sounds\/18763/)
|
16
|
+
expect(sound.tags).to respond_to(:to_ary)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "belongs to a user" do
|
20
|
+
expect(sound.user.username).to be_present
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "that doesn't exist" do
|
25
|
+
it "raises an exception" do
|
26
|
+
expect {
|
27
|
+
VCR.use_cassette(:sound_unknown) do
|
28
|
+
client.sound(123456789)
|
29
|
+
end
|
30
|
+
}.to raise_error(Freesound::ResourceNotFound,
|
31
|
+
/sound with id 123456789/i)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "integration/helper"
|
2
|
+
|
3
|
+
describe "finding a user" do
|
4
|
+
let(:client) { Freesound::Client.new }
|
5
|
+
|
6
|
+
context "that exists" do
|
7
|
+
let(:user) do
|
8
|
+
VCR.use_cassette(:user_alexgenco) do
|
9
|
+
client.user("AlexGenco")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns an object with user attributes" do
|
14
|
+
expect(user.username).to eq("alexgenco")
|
15
|
+
expect(user.ref).to match(/\/people\/alexgenco/)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "that doesn't exist" do
|
20
|
+
it "raises an exception" do
|
21
|
+
expect {
|
22
|
+
VCR.use_cassette(:user_unknown) do
|
23
|
+
client.user("LOLWHOAMI__123")
|
24
|
+
end
|
25
|
+
}.to raise_error(Freesound::ResourceNotFound,
|
26
|
+
/user with username 'LOLWHOAMI__123'/i)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "helper"
|
2
|
+
require "freesound"
|
3
|
+
require "vcr"
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.before { Freesound.api_key = ENV.fetch("FREESOUND_KEY") }
|
7
|
+
end
|
8
|
+
|
9
|
+
VCR.configure do |config|
|
10
|
+
config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
|
11
|
+
config.hook_into :webmock
|
12
|
+
|
13
|
+
config.filter_sensitive_data("<FREESOUND_KEY>") { ENV.fetch("FREESOUND_KEY") }
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "integration/helper"
|
2
|
+
|
3
|
+
describe "a pack with resources" do
|
4
|
+
let(:client) { Freesound::Client.new }
|
5
|
+
|
6
|
+
let(:pack) do
|
7
|
+
VCR.use_cassette(:pack_5107) do
|
8
|
+
client.pack(5107)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has many sounds" do
|
13
|
+
VCR.use_cassette(:pack_5107_sounds) do
|
14
|
+
expect(pack.sounds).to respond_to(:to_ary)
|
15
|
+
expect(pack.sounds.first).to respond_to(:duration)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "integration/helper"
|
2
|
+
|
3
|
+
describe "searching for a sound" do
|
4
|
+
let(:client) { Freesound::Client.new }
|
5
|
+
|
6
|
+
it "returns a list of sounds that match the query" do
|
7
|
+
sounds = VCR.use_cassette(:search_csharp) do
|
8
|
+
client.search("csharp")
|
9
|
+
end
|
10
|
+
expect(sounds.size).to be > 0
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "integration/helper"
|
2
|
+
|
3
|
+
describe "a user with resources" do
|
4
|
+
let(:client) { Freesound::Client.new }
|
5
|
+
|
6
|
+
let(:user) do
|
7
|
+
VCR.use_cassette(:user_jovica) do
|
8
|
+
client.user("Jovica")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has many sounds" do
|
13
|
+
VCR.use_cassette(:jovica_sounds) do
|
14
|
+
expect(user.sounds).to respond_to(:to_ary)
|
15
|
+
expect(user.sounds.first).to respond_to(:duration)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has many packs" do
|
20
|
+
VCR.use_cassette(:jovica_packs) do
|
21
|
+
expect(user.packs).to respond_to(:to_ary)
|
22
|
+
expect(user.packs.first.ref).to match(/packs/)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: freesound_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Genco
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activeresource
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.8.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.8.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.8.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.8.0
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- alexgenco@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .document
|
105
|
+
- .gitignore
|
106
|
+
- .travis.yml
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- freesound_ruby.gemspec
|
113
|
+
- lib/freesound.rb
|
114
|
+
- lib/freesound/client.rb
|
115
|
+
- lib/freesound/collections.rb
|
116
|
+
- lib/freesound/resources.rb
|
117
|
+
- lib/freesound/version.rb
|
118
|
+
- spec/helper.rb
|
119
|
+
- spec/integration/find_pack_spec.rb
|
120
|
+
- spec/integration/find_sound_spec.rb
|
121
|
+
- spec/integration/find_user_spec.rb
|
122
|
+
- spec/integration/helper.rb
|
123
|
+
- spec/integration/pack_resources_spec.rb
|
124
|
+
- spec/integration/search_sound_spec.rb
|
125
|
+
- spec/integration/user_resources_spec.rb
|
126
|
+
homepage: https://github.com/alexgenco/freesound_ruby
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata: {}
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.9.3
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.0.3
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: A Ruby library for consuming the Freesound.org API
|
150
|
+
test_files:
|
151
|
+
- spec/helper.rb
|
152
|
+
- spec/integration/find_pack_spec.rb
|
153
|
+
- spec/integration/find_sound_spec.rb
|
154
|
+
- spec/integration/find_user_spec.rb
|
155
|
+
- spec/integration/helper.rb
|
156
|
+
- spec/integration/pack_resources_spec.rb
|
157
|
+
- spec/integration/search_sound_spec.rb
|
158
|
+
- spec/integration/user_resources_spec.rb
|