clarify 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MzBkMDZjYzI0OTBlMmQxYmI2NzRiY2E0NTNmNjVmNmFmMDc1MWI0YQ==
5
- data.tar.gz: !binary |-
6
- NGI4MWVhMGQ4NmE2OGNmYmZhNGVjNjJmYzI4NTIzMWMxYjM0OTk5NA==
2
+ SHA1:
3
+ metadata.gz: 18179d891742e09939fedb3b2073db80bf3e87f9
4
+ data.tar.gz: 70e075ae0bd8788d63663dd4f4fc3697f57cdd7c
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YjA3N2ZiZjc2ZGE0NDMxNTY0ZjJlZDFiMjU2NzJlNmU4ZmI4NDllMWE2ZjFm
10
- Yjk0NGE2MzY3NmY4OGMyOTc4MWE1NWEwNTZiNTk3NWE0NjNlOGQwNzc0Mjlj
11
- NzA0MDUxODBkNzJmMWY4MWIzMTMwZDRhNTJmMTM0N2M2Yzg4ZmY=
12
- data.tar.gz: !binary |-
13
- NWFmNDI2MmI5MjQwNzY0ZTY0NzA2YTYwMmFhODllZTI1MjIwNzRiN2IwMDc4
14
- M2M3MDM4NDQxMTQ1YTg1MWNkNmNlMGU0MDU0YWU5M2NhMmM4NGJhN2QzMzI1
15
- ZWZlZjU4MDI1OGQyZjAxMDVjNGFhNmEzNmRmYmRkMTZlMGUwN2Q=
6
+ metadata.gz: 0489cdd40b5e83b8f46f5fa6a0ccecd3581ec13fbc3e1be6022d76041fcb68fcdcd101f5185627f9f411e5239aaa163d021532f9b8a303c45856fb829a6138cf
7
+ data.tar.gz: 40a9112bf243b525e4c80f01b8a3371ca9c086077c2ec68c38597cdb11c02594d63ed960c91794b6809178a0591c0bdfe8d8314995487482f3232af22cdd38e2
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .idea/*
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
+ [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Clarify/clarify-ruby/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Clarify/clarify-ruby/?branch=master) [![Code Climate](https://codeclimate.com/github/Clarify/clarify-ruby/badges/gpa.svg)](https://codeclimate.com/github/Clarify/clarify-ruby)
2
+
1
3
  # Clarify
2
4
 
3
5
  A gem to communicate with the ClarifyAPI.
4
6
 
5
- ## Installation
7
+ ### Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
8
10
 
@@ -19,6 +21,8 @@ Or install it yourself as:
19
21
  add a configuration block to an initializer if you are using rails or in an include file:
20
22
 
21
23
  ```
24
+ require 'clarify'
25
+
22
26
  Clarify.configure do |config|
23
27
  config.api_key = 'CLARIFY_API_KEY'
24
28
  # if key in ENV
@@ -31,7 +35,7 @@ It doesn't have to be in ENV variable but that is an option.
31
35
 
32
36
  **Remember never to check in your API key to a public repository!**
33
37
 
34
- Your API key is found on your [application page](https://developer.clarify.io/apps).
38
+ Your API key is found on your [application page](https://developer.clarify.io/apps/list/).
35
39
 
36
40
  If you wish to store your API key in your environment:
37
41
 
@@ -49,11 +53,34 @@ Or on [Heroku](http://www.heroku)
49
53
 
50
54
  [Read more on heroku environment variables](https://devcenter.heroku.com/articles/config-vars)
51
55
 
52
- By default, it uses the newest version of the API. If you want to use a specific version use:
56
+ By default, it uses the newest version of the API.
53
57
 
54
58
  ## Usage
55
59
 
56
- Clarify::Bundle.new.find_all
60
+ To begin using this library, initialize the Clarify object with your API key:
61
+
62
+ ```ruby
63
+ require 'clarify'
64
+ @client = Clarify::Bundle.new
65
+ ```
66
+
67
+ Then add an audio or video file to your search index:
68
+
69
+ ```ruby
70
+ bundle = @client.create(:name => "Harvard Sentences",
71
+ :media_url => "http://media.clarify.io/audio/samples/harvard-sentences-1.wav")
72
+ bundle.data[:id]
73
+ ```
74
+
75
+ Within minutes your file will be added to your index and available via a simple search:
76
+
77
+ ```ruby
78
+ @client = Clarify::Search.new
79
+ results = @client.perform(:query => "dorothy").data
80
+ bundles = results[:_links][:items]
81
+ ```
82
+
83
+ See more examples for listing, getting, and deleting bundles etc. in the /examples folder.
57
84
 
58
85
  ## Contributing
59
86
 
@@ -0,0 +1,14 @@
1
+ require 'clarify'
2
+
3
+ # This assumes that you set up your key in the environment using: export CLARIFY_API_KEY=abcde12345
4
+ Clarify.configure do |config|
5
+ # config.api_key = 'CLARIFY_API_KEY'
6
+ # if key in ENV
7
+ config.api_key = ENV['CLARIFY_API_KEY']
8
+ end
9
+
10
+ client = Clarify::Bundle.new
11
+
12
+ bundle = client.create(:name => "Dorothy and the Wizard of Oz",
13
+ :media_url => "http://media.clarify.io/audio/books/dorothyandthewizardinoz_01_baum_64kb.mp3")
14
+ puts bundle.data[:id]
@@ -0,0 +1,12 @@
1
+
2
+ require 'clarify'
3
+
4
+ # This assumes that you set up your key in the environment using: export CLARIFY_API_KEY=abcde12345
5
+ Clarify.configure do |config|
6
+ # config.api_key = 'CLARIFY_API_KEY'
7
+ # if key in ENV
8
+ config.api_key = ENV['CLARIFY_API_KEY']
9
+ end
10
+
11
+ client = Clarify::Bundle.new
12
+ client.delete("abc123")
@@ -0,0 +1,14 @@
1
+
2
+ require 'clarify'
3
+
4
+ # This assumes that you set up your key in the environment using: export CLARIFY_API_KEY=abcde12345
5
+ Clarify.configure do |config|
6
+ # config.api_key = 'CLARIFY_API_KEY'
7
+ # if key in ENV
8
+ config.api_key = ENV['CLARIFY_API_KEY']
9
+ end
10
+
11
+ client = Clarify::Bundle.new
12
+
13
+ bundles = client.find_all.data[:_links][:items]
14
+ bundles.each { |bundle| puts bundle[:href] }
@@ -0,0 +1,26 @@
1
+
2
+ require 'clarify'
3
+
4
+ # This assumes that you set up your key in the environment using: export CLARIFY_API_KEY=abcde12345
5
+ Clarify.configure do |config|
6
+ # config.api_key = 'CLARIFY_API_KEY'
7
+ # if key in ENV
8
+ config.api_key = ENV['CLARIFY_API_KEY']
9
+ end
10
+
11
+ client = Clarify::Search.new
12
+ results = client.perform(:query => "dorothy").data
13
+ bundles = results[:_links][:items]
14
+
15
+ _bundle = Clarify::Bundle.new
16
+
17
+ bundles.each do |bundle|
18
+ _id = bundle[:href][12..44]
19
+ test = _bundle.find(_id)
20
+ puts test.data[:name]
21
+ i = bundles.find_index(bundle)
22
+ matches = results[:item_results][i][:term_results][0][:matches][0][:hits]
23
+ matches.each do |match|
24
+ puts match[:start].to_s + " -- " + match[:end].to_s
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+
2
+ require 'clarify'
3
+
4
+ # This assumes that you set up your key in the environment using: export CLARIFY_API_KEY=abcde12345
5
+ Clarify.configure do |config|
6
+ # config.api_key = 'CLARIFY_API_KEY'
7
+ # if key in ENV
8
+ config.api_key = ENV['CLARIFY_API_KEY']
9
+ end
10
+
11
+ client = Clarify::Bundle.new
12
+
13
+ bundle = client.create(:name => "Harvard Sentences",
14
+ :media_url => "http://media.clarify.io/audio/samples/harvard-sentences-1.wav")
15
+ print bundle.data[:id]
@@ -3,31 +3,35 @@ require_relative 'request'
3
3
  module Clarify
4
4
  class Bundle < Request
5
5
 
6
+ def bundle_url
7
+ "/v#{version}/bundles"
8
+ end
9
+
6
10
  def create(query={})
7
- response = self.class.post("/#{version_name}/bundles",
8
- query: query,
11
+ response = self.class.post("#{bundle_url}",
12
+ body: query,
9
13
  headers: self.headers)
10
14
  build_response(response)
11
15
  end
12
16
 
13
17
  def find(bundle_id, args={})
14
18
  raise ArgumentError, "Missing bundle id" if bundle_id.nil?
15
- response = self.class.get("/#{version_name}/bundles/#{bundle_id}", query: args, headers: headers)
19
+ response = self.class.get("#{bundle_url}/#{bundle_id}", query: args, headers: headers)
16
20
  build_response(response)
17
21
  end
18
22
 
19
23
  def find_all(args={})
20
- response = self.class.get("/#{version_name}/bundles", headers: headers)
24
+ response = self.class.get("#{bundle_url}", headers: headers)
21
25
  build_response(response)
22
26
  end
23
27
 
24
28
  def delete(bundle_id)
25
- response = self.class.delete("/#{version_name}/bundles/#{bundle_id}", headers: headers)
29
+ response = self.class.delete("#{bundle_url}/#{bundle_id}", headers: headers)
26
30
  build_response(response)
27
31
  end
28
32
 
29
33
  def update(bundle_id, query={})
30
- response = self.class.put("/#{version_name}/bundles/#{bundle_id}",
34
+ response = self.class.put("#{bundle_url}/#{bundle_id}",
31
35
  body: query, headers: headers)
32
36
  build_response(response)
33
37
  end
@@ -8,14 +8,14 @@ module Clarify
8
8
  class Request
9
9
  include HTTParty
10
10
  base_uri "https://api.clarify.io/"
11
+ version = 1
11
12
 
12
13
  #uncomment below for httparty debugging
13
14
  #debug_output
14
15
 
15
- attr_accessor :version_name, :api_key
16
+ attr_accessor :version, :api_key
16
17
 
17
18
  def initialize
18
- @version_name = Clarify.configuration.version_name
19
19
  @api_key = Clarify.configuration.api_key
20
20
  end
21
21
 
@@ -1,3 +1,3 @@
1
1
  module Clarify
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clarify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubygeek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-30 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -17,7 +17,7 @@ dependencies:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.13'
20
- - - ! '>='
20
+ - - '>='
21
21
  - !ruby/object:Gem::Version
22
22
  version: 0.13.1
23
23
  type: :runtime
@@ -27,7 +27,7 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0.13'
30
- - - ! '>='
30
+ - - '>='
31
31
  - !ruby/object:Gem::Version
32
32
  version: 0.13.1
33
33
  - !ruby/object:Gem::Dependency
@@ -51,7 +51,7 @@ dependencies:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
53
  version: '10.0'
54
- - - ! '>='
54
+ - - '>='
55
55
  - !ruby/object:Gem::Version
56
56
  version: 10.0.0
57
57
  type: :development
@@ -61,7 +61,7 @@ dependencies:
61
61
  - - ~>
62
62
  - !ruby/object:Gem::Version
63
63
  version: '10.0'
64
- - - ! '>='
64
+ - - '>='
65
65
  - !ruby/object:Gem::Version
66
66
  version: 10.0.0
67
67
  - !ruby/object:Gem::Dependency
@@ -71,7 +71,7 @@ dependencies:
71
71
  - - ~>
72
72
  - !ruby/object:Gem::Version
73
73
  version: '3.0'
74
- - - ! '>='
74
+ - - '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: 3.0.0
77
77
  type: :development
@@ -81,7 +81,7 @@ dependencies:
81
81
  - - ~>
82
82
  - !ruby/object:Gem::Version
83
83
  version: '3.0'
84
- - - ! '>='
84
+ - - '>='
85
85
  - !ruby/object:Gem::Version
86
86
  version: 3.0.0
87
87
  - !ruby/object:Gem::Dependency
@@ -91,7 +91,7 @@ dependencies:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
93
  version: '1.6'
94
- - - ! '>='
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.6.8
97
97
  type: :development
@@ -101,7 +101,7 @@ dependencies:
101
101
  - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.6'
104
- - - ! '>='
104
+ - - '>='
105
105
  - !ruby/object:Gem::Version
106
106
  version: 1.6.8
107
107
  description: Use the Clarify API to make your audio and video files searchable in
@@ -120,6 +120,11 @@ files:
120
120
  - README.md
121
121
  - Rakefile
122
122
  - clarify.gemspec
123
+ - examples/create.rb
124
+ - examples/delete.rb
125
+ - examples/list.rb
126
+ - examples/search.rb
127
+ - examples/test.rb
123
128
  - lib/clarify.rb
124
129
  - lib/clarify/bundle.rb
125
130
  - lib/clarify/configuration.rb
@@ -144,17 +149,17 @@ require_paths:
144
149
  - lib
145
150
  required_ruby_version: !ruby/object:Gem::Requirement
146
151
  requirements:
147
- - - ! '>='
152
+ - - '>='
148
153
  - !ruby/object:Gem::Version
149
154
  version: '0'
150
155
  required_rubygems_version: !ruby/object:Gem::Requirement
151
156
  requirements:
152
- - - ! '>='
157
+ - - '>='
153
158
  - !ruby/object:Gem::Version
154
159
  version: '0'
155
160
  requirements: []
156
161
  rubyforge_project:
157
- rubygems_version: 2.4.1
162
+ rubygems_version: 2.4.4
158
163
  signing_key:
159
164
  specification_version: 4
160
165
  summary: Search audio and video in a few lines of code