clarify 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE +23 -0
- data/LICENSE.txt +24 -0
- data/README.md +66 -0
- data/Rakefile +10 -0
- data/clarify.gemspec +26 -0
- data/lib/clarify.rb +17 -0
- data/lib/clarify/bundle.rb +40 -0
- data/lib/clarify/configuration.rb +8 -0
- data/lib/clarify/metadata.rb +30 -0
- data/lib/clarify/request.rb +36 -0
- data/lib/clarify/search.rb +14 -0
- data/lib/clarify/track.rb +44 -0
- data/lib/clarify/version.rb +3 -0
- data/spec/lib/clarify/bundle_spec.rb +43 -0
- data/spec/lib/clarify/configuration_spec.rb +14 -0
- data/spec/lib/clarify/metadata_spec.rb +36 -0
- data/spec/lib/clarify/search_spec.rb +22 -0
- data/spec/lib/clarify/track_spec.rb +81 -0
- data/spec/spec_helper.rb +12 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDk0Y2E4NTgyNTA0NDIyMjY2ZTk4NjkzZjBlZjg1YTk5NWJmNjVlMg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjJiZGU2NWJhZjY4ODFjN2Y1ODI1MWJjNmU3M2E2ODI3YjIzMTE1OQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDVlMjNiOGU1ZDA0MDQ3Yzk3NDNmZWM0YjkwYTY4MzAwN2ExYjExMDhiYjRk
|
10
|
+
NmRiNDI5MzY1ZjRkNWQwOGE2OGUzNGZhMGI5YWM4NDIyNzRjODhiZmJiYWFk
|
11
|
+
MDkwYTM1N2IxYjFhYjQwYTE5NWU0NDg2N2VjOTkxNTQ0NTBjMGY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODBmNGVkZDVmYjJjNGM1MjI4NWRmMjlhZTg4NTgzZmI2ZDg5OTk1NTM1ZmMw
|
14
|
+
N2YwZGM3MGU5OTAzNzcxMDQ2ODJlMzk0M2QyZGNlMjIyOGZmZDExMDkwMmEz
|
15
|
+
N2ExNzEwZDFjM2FlMzRhMGJkZWJlZjMzMDUzMTlmMGUyYzhmNDk=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Clarify, Inc
|
4
|
+
|
5
|
+
Written by Nola Stowe @rubygeek
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
9
|
+
in the Software without restriction, including without limitation the rights
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
12
|
+
furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
15
|
+
copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2014 Clarify, Inc.
|
2
|
+
|
3
|
+
Written by Nola Stowe @rubygeek
|
4
|
+
|
5
|
+
MIT License
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
a copy of this software and associated documentation files (the
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# Clarify
|
2
|
+
|
3
|
+
A gem to communicate with the ClarifyAPI.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'clarify', require: 'clarify-ruby'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install clarify
|
18
|
+
|
19
|
+
add a configuration block to an initializer if you are using rails or in an include file:
|
20
|
+
|
21
|
+
```
|
22
|
+
Clarify.configure do |config|
|
23
|
+
config.api_key = 'CLARIFY_API_KEY'
|
24
|
+
# if key in ENV
|
25
|
+
# config.api_key = ENV['CLARIFY_API_KEY']
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
It doesn't have to be in ENV variable but that is an option.
|
30
|
+
|
31
|
+
**Remember never to check in your API key to a public repository!**
|
32
|
+
|
33
|
+
Your API key is found on your [application page](https://developer.clarify.io/apps).
|
34
|
+
|
35
|
+
If you wish to store your API key in your environment:
|
36
|
+
|
37
|
+
In bash:
|
38
|
+
|
39
|
+
export CLARIFY_API_KEY=atYIFLDSDFsdfssSsd+fsfsdfsd+p+PCwA
|
40
|
+
|
41
|
+
If you don't want to load it in your bash file, you can add it on the command line:
|
42
|
+
|
43
|
+
CLARIFY_API_KEY=atYIFLDSDFsdfssSsd+fsfsdfsd+p+PCwA rails s
|
44
|
+
|
45
|
+
Or on [Heroku](http://www.heroku)
|
46
|
+
|
47
|
+
heroku config:set CLARIFY_API_KEY=atYIFLDSDFsdfssSsd+fsfsdfsd+p+PCwA
|
48
|
+
|
49
|
+
[Read more on heroku environment variables](https://devcenter.heroku.com/articles/config-vars)
|
50
|
+
|
51
|
+
By default, it uses the newest version of the API. If you want to use a specific version use:
|
52
|
+
|
53
|
+
## Usage
|
54
|
+
|
55
|
+
Clarify::Bundle.new.find_all # uses default version
|
56
|
+
Clarify::Bundle.new(4).find_all # uses version 4
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
1. Fork it to your github user ie: ( `http://github.com/my-github-username/clarify-ruby/` )
|
61
|
+
2. Create your feature branch and rspec tests (`git checkout -b my-new-feature`)
|
62
|
+
3. Run the rspec tests with `rake spec`
|
63
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
6. Create new Pull Request
|
66
|
+
|
data/Rakefile
ADDED
data/clarify.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'clarify/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'clarify'
|
8
|
+
spec.version = Clarify::VERSION
|
9
|
+
spec.authors = ['rubygeek']
|
10
|
+
spec.email = ['nola@rubygeek.com']
|
11
|
+
spec.summary = 'Search audio and video in a few lines of code'
|
12
|
+
spec.description = 'Use the Clarify API to make your audio and video files searchable in just a few lines of code.'
|
13
|
+
spec.homepage = 'http://www.clarify.io'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'httparty', '~> 0.13', '>= 0.13.1'
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0', '>= 10.0.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
|
25
|
+
spec.add_development_dependency 'debugger', '~> 1.6', '>= 1.6.8'
|
26
|
+
end
|
data/lib/clarify.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "clarify/version"
|
2
|
+
require "clarify/configuration"
|
3
|
+
require "clarify/bundle"
|
4
|
+
require "clarify/request"
|
5
|
+
require "clarify/metadata"
|
6
|
+
require "clarify/track"
|
7
|
+
require "clarify/search"
|
8
|
+
|
9
|
+
module Clarify
|
10
|
+
class << self
|
11
|
+
attr_accessor :configuration
|
12
|
+
end
|
13
|
+
def self.configure
|
14
|
+
self.configuration ||= Configuration.new
|
15
|
+
yield(configuration)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative 'request'
|
2
|
+
|
3
|
+
module Clarify
|
4
|
+
class Bundle < Request
|
5
|
+
|
6
|
+
def initialize(version = 1)
|
7
|
+
super(version)
|
8
|
+
end
|
9
|
+
|
10
|
+
def create(query={})
|
11
|
+
response = self.class.post("/#{self.version}/bundles",
|
12
|
+
query: query,
|
13
|
+
headers: self.headers)
|
14
|
+
build_response(response)
|
15
|
+
end
|
16
|
+
|
17
|
+
def find(bundle_id, args={})
|
18
|
+
raise ArgumentError, "Missing bundle id" if bundle_id.nil?
|
19
|
+
response = self.class.get("/#{version}/bundles/#{bundle_id}", query: args, headers: headers)
|
20
|
+
build_response(response)
|
21
|
+
end
|
22
|
+
|
23
|
+
def find_all(args={})
|
24
|
+
response = self.class.get("/#{version}/bundles", headers: headers)
|
25
|
+
build_response(response)
|
26
|
+
end
|
27
|
+
|
28
|
+
def delete(bundle_id)
|
29
|
+
response = self.class.delete("/#{version}/bundles/#{bundle_id}", headers: headers)
|
30
|
+
build_response(response)
|
31
|
+
end
|
32
|
+
|
33
|
+
def update(bundle_id, query={})
|
34
|
+
response = self.class.put("/#{version}/bundles/#{bundle_id}",
|
35
|
+
body: query, headers: headers)
|
36
|
+
build_response(response)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'request'
|
2
|
+
|
3
|
+
module Clarify
|
4
|
+
class Metadata < Request
|
5
|
+
|
6
|
+
def initialize(version=1)
|
7
|
+
super(version)
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(bundle_id)
|
11
|
+
raise ArgumentError, "Missing bundle id" if bundle_id.nil?
|
12
|
+
response = self.class.get("/#{version}/bundles/#{bundle_id}/metadata", headers: headers)
|
13
|
+
build_response(response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete(bundle_id)
|
17
|
+
raise ArgumentError, "Missing bundle id" if bundle_id.nil?
|
18
|
+
response = self.class.delete("/#{version}/bundles/#{bundle_id}/metadata", headers: headers)
|
19
|
+
build_response(response)
|
20
|
+
end
|
21
|
+
|
22
|
+
def update(bundle_id, data="")
|
23
|
+
raise ArgumentError, "Missing bundle id" if bundle_id.nil?
|
24
|
+
response = self.class.put("/#{version}/bundles/#{bundle_id}/metadata",
|
25
|
+
body: {data: data} , headers: headers)
|
26
|
+
build_response(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Clarify
|
5
|
+
|
6
|
+
Response = Struct.new(:status, :data)
|
7
|
+
|
8
|
+
class Request
|
9
|
+
include HTTParty
|
10
|
+
base_uri "https://api.clarify.io/"
|
11
|
+
|
12
|
+
#uncomment below for httparty debugging
|
13
|
+
#debug_output
|
14
|
+
|
15
|
+
attr_accessor :version, :api_key
|
16
|
+
|
17
|
+
def initialize(version = 1)
|
18
|
+
@version = "v#{version}"
|
19
|
+
@api_key = Clarify.configuration.api_key #old ENV['CLARIFY_API_KEY']
|
20
|
+
end
|
21
|
+
|
22
|
+
def headers
|
23
|
+
{"Authorization" => "Bearer #{@api_key}"}
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_response(response)
|
27
|
+
if response.code != 204 #http code for no content
|
28
|
+
body = JSON.parse(response.parsed_response, symbolize_names: true)
|
29
|
+
else
|
30
|
+
body = ""
|
31
|
+
end
|
32
|
+
Response.new(response.code, body)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Clarify
|
2
|
+
class Search < Request
|
3
|
+
|
4
|
+
def initialize(version="1")
|
5
|
+
super(version)
|
6
|
+
end
|
7
|
+
|
8
|
+
def perform(query={})
|
9
|
+
response = self.class.get("/#{version}/search", query: query, headers: headers)
|
10
|
+
build_response(response)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative 'request'
|
2
|
+
|
3
|
+
module Clarify
|
4
|
+
class Track < Request
|
5
|
+
|
6
|
+
def initialize(version=1)
|
7
|
+
super(version)
|
8
|
+
end
|
9
|
+
|
10
|
+
def all(bundle_id)
|
11
|
+
raise ArgumentError, "Missing bundle id" if bundle_id.nil?
|
12
|
+
response = self.class.get("/#{version}/bundles/#{bundle_id}/tracks", headers: headers)
|
13
|
+
build_response(response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def add(bundle_id, media_url)
|
17
|
+
raise ArgumentError, "Missing bundle id" if bundle_id.nil?
|
18
|
+
raise ArgumentError, "Missing media_url" if media_url.nil?
|
19
|
+
response = self.class.post("/#{version}/bundles/#{bundle_id}/tracks", body: {media_url: media_url}, headers: headers)
|
20
|
+
build_response(response)
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete(bundle_id, track="")
|
24
|
+
raise ArgumentError, "Missing bundle id" if bundle_id.nil?
|
25
|
+
response = self.class.delete("/#{version}/bundles/#{bundle_id}/tracks", query: {track: track}, headers: headers)
|
26
|
+
build_response(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
def delete_by_id(bundle_id, track_id)
|
30
|
+
raise ArgumentError, "Missing bundle id" if bundle_id.nil?
|
31
|
+
raise ArgumentError, "Missing track id" if track_id.nil?
|
32
|
+
response = self.class.delete("/#{version}/bundles/#{bundle_id}/tracks/#{track_id}", headers: headers)
|
33
|
+
build_response(response)
|
34
|
+
end
|
35
|
+
|
36
|
+
def find(bundle_id, track_id)
|
37
|
+
raise ArgumentError, "Missing bundle id" if bundle_id.nil?
|
38
|
+
raise ArgumentError, "Missing track id" if track_id.nil?
|
39
|
+
response = self.class.get("/#{version}/bundles/#{bundle_id}/tracks/#{track_id}", headers: headers)
|
40
|
+
build_response(response)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Clarify
|
2
|
+
|
3
|
+
describe Bundle do
|
4
|
+
before do
|
5
|
+
@response = Bundle.new.create
|
6
|
+
@bundle_id = @response.data[:id]
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
Bundle.new.delete(@bundle_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should create a new bundle with all blank values" do
|
14
|
+
expect(@response.data).to include(:_class, :_links, :id)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should retrieve the bundle created" do
|
18
|
+
response = Bundle.new.find(@bundle_id)
|
19
|
+
expect(response.status).to eql 200
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should find all bundles" do
|
23
|
+
response = Bundle.new.find_all
|
24
|
+
expect(response.status).to eql 200
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should update a bundle" do
|
28
|
+
response = Bundle.new.update(@bundle_id, {name: "test"})
|
29
|
+
expect(response.status).to eql 202
|
30
|
+
expect(response.data.keys).to include(:_class, :_links, :id)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "deleting a bundle" do
|
35
|
+
it "should delete the bundle" do
|
36
|
+
response = Bundle.new.create
|
37
|
+
Bundle.new.delete(response.data[:id])
|
38
|
+
expect(Bundle.new.find(response.data[:id]).status).to be 404
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Clarify
|
2
|
+
describe Config do
|
3
|
+
before do
|
4
|
+
Clarify.configure do |config|
|
5
|
+
config.api_key = ENV['CLARIFY_API_KEY']
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should set the api_key in configuration" do
|
10
|
+
expect(Request.new.api_key).to eql(ENV['CLARIFY_API_KEY'])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Clarify
|
2
|
+
|
3
|
+
describe Metadata do
|
4
|
+
before do
|
5
|
+
bundle = Bundle.new.create
|
6
|
+
@bundle_id = bundle.data[:id]
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
Bundle.new.delete(@bundle_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should retrieve the metadata for bundle" do
|
14
|
+
metadata = Metadata.new.find(@bundle_id)
|
15
|
+
expect(metadata.status).to eql 200
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should update a bundle" do
|
19
|
+
metadata = Metadata.new.update(@bundle_id, '{"meta": 1}')
|
20
|
+
expect(metadata.status).to eql 202
|
21
|
+
expect(metadata.data.keys).to include(:_class, :_links)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should delete the metadata" do
|
25
|
+
Metadata.new.update(@bundle_id, '{"meta": 1}')
|
26
|
+
metadata_before = Metadata.new.find(@bundle_id)
|
27
|
+
expect(metadata_before.data[:data].keys).to include :meta
|
28
|
+
|
29
|
+
metadata_after = Metadata.new.delete(@bundle_id)
|
30
|
+
expect(metadata_after.status).to eq 204
|
31
|
+
expect(metadata_after.data).to be_empty
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Clarify
|
2
|
+
|
3
|
+
describe Search do
|
4
|
+
before do
|
5
|
+
@response = Bundle.new.create
|
6
|
+
@bundle_id = @response.data[:id]
|
7
|
+
@media_url = "http://media.clarify.io/audio/samples/harvard-sentences-1.wav"
|
8
|
+
@response = Track.new.add(@bundle_id, @media_url)
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
Bundle.new.delete(@bundle_id)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should search for a word in speech" do
|
16
|
+
response = Search.new.perform({query: "cat"})
|
17
|
+
expect(response.data[:item_results].first[:term_results].first[:matches].first[:hits].size).to eql 2
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Clarify
|
2
|
+
|
3
|
+
describe Track do
|
4
|
+
|
5
|
+
before do
|
6
|
+
bundle = Bundle.new.create
|
7
|
+
@bundle_id = bundle.data[:id]
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
Bundle.new.delete(@bundle_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
context "adding tracks and getting tracks for bundle" do
|
15
|
+
before do
|
16
|
+
@media_url = "http://media.clarify.io/audio/samples/harvard-sentences-1.wav"
|
17
|
+
@response = Track.new.add(@bundle_id, @media_url)
|
18
|
+
end
|
19
|
+
it "should be successful" do
|
20
|
+
expect(@response.status).to eql 201
|
21
|
+
expect(@response.data.keys).to include(:_class, :_links)
|
22
|
+
end
|
23
|
+
it "should list track in bundle" do
|
24
|
+
response = Track.new.all(@bundle_id)
|
25
|
+
expect(response.data[:tracks]).to be_an_instance_of(Array)
|
26
|
+
expect(response.data[:tracks][0][:media_url]).to eql @media_url
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "adding a track and deleting all tracks for bundle" do
|
31
|
+
before do
|
32
|
+
@media_url = "http://media.clarify.io/audio/samples/harvard-sentences-1.wav"
|
33
|
+
@add_response = Track.new.add(@bundle_id, @media_url)
|
34
|
+
@del_response = Track.new.delete(@bundle_id)
|
35
|
+
end
|
36
|
+
it "should be successful" do
|
37
|
+
expect(@del_response.status).to eql 204
|
38
|
+
end
|
39
|
+
it "should not be in bundle" do
|
40
|
+
response = Track.new.all(@bundle_id)
|
41
|
+
expect(response.data[:tracks]).to be_empty
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "adding a track and finding by track_id" do
|
46
|
+
before do
|
47
|
+
media_url = "http://media.clarify.io/audio/samples/harvard-sentences-1.wav"
|
48
|
+
Track.new.add(@bundle_id, media_url)
|
49
|
+
|
50
|
+
all_tracks = Track.new.all(@bundle_id)
|
51
|
+
|
52
|
+
@track_id = all_tracks.data[:tracks].first[:id]
|
53
|
+
@find_response = Track.new.find(@bundle_id, @track_id)
|
54
|
+
end
|
55
|
+
it "should be successful" do
|
56
|
+
expect(@find_response.status).to eql 200
|
57
|
+
end
|
58
|
+
it "should have some keys and duration value" do
|
59
|
+
expect(@find_response.data.keys).to include(:audio_channel,:audio_language, :duration)
|
60
|
+
expect(@find_response.data[:duration]).to eql 64.422875
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "adding a track and deleting by delete_by_id " do
|
65
|
+
before do
|
66
|
+
media_url = "http://media.clarify.io/audio/samples/harvard-sentences-1.wav"
|
67
|
+
Track.new.add(@bundle_id, media_url)
|
68
|
+
|
69
|
+
all_tracks = Track.new.all(@bundle_id)
|
70
|
+
|
71
|
+
@track_id = all_tracks.data[:tracks].first[:id]
|
72
|
+
@find_response = Track.new.delete_by_id(@bundle_id, @track_id)
|
73
|
+
end
|
74
|
+
it "should be successful" do
|
75
|
+
expect(@find_response.status).to eql 204
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: clarify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.9
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- rubygeek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.13.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.13'
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.13.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.5'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.5'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '10.0'
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 10.0.0
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '10.0'
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 10.0.0
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rspec
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '3.0'
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 3.0.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.0'
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 3.0.0
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: debugger
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.6'
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.6.8
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.6'
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 1.6.8
|
107
|
+
description: Use the Clarify API to make your audio and video files searchable in
|
108
|
+
just a few lines of code.
|
109
|
+
email:
|
110
|
+
- nola@rubygeek.com
|
111
|
+
executables: []
|
112
|
+
extensions: []
|
113
|
+
extra_rdoc_files: []
|
114
|
+
files:
|
115
|
+
- .gitignore
|
116
|
+
- .rspec
|
117
|
+
- Gemfile
|
118
|
+
- LICENSE
|
119
|
+
- LICENSE.txt
|
120
|
+
- README.md
|
121
|
+
- Rakefile
|
122
|
+
- clarify.gemspec
|
123
|
+
- lib/clarify.rb
|
124
|
+
- lib/clarify/bundle.rb
|
125
|
+
- lib/clarify/configuration.rb
|
126
|
+
- lib/clarify/metadata.rb
|
127
|
+
- lib/clarify/request.rb
|
128
|
+
- lib/clarify/search.rb
|
129
|
+
- lib/clarify/track.rb
|
130
|
+
- lib/clarify/version.rb
|
131
|
+
- spec/lib/clarify/bundle_spec.rb
|
132
|
+
- spec/lib/clarify/configuration_spec.rb
|
133
|
+
- spec/lib/clarify/metadata_spec.rb
|
134
|
+
- spec/lib/clarify/search_spec.rb
|
135
|
+
- spec/lib/clarify/track_spec.rb
|
136
|
+
- spec/spec_helper.rb
|
137
|
+
homepage: http://www.clarify.io
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.4.1
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Search audio and video in a few lines of code
|
161
|
+
test_files:
|
162
|
+
- spec/lib/clarify/bundle_spec.rb
|
163
|
+
- spec/lib/clarify/configuration_spec.rb
|
164
|
+
- spec/lib/clarify/metadata_spec.rb
|
165
|
+
- spec/lib/clarify/search_spec.rb
|
166
|
+
- spec/lib/clarify/track_spec.rb
|
167
|
+
- spec/spec_helper.rb
|