clarify 1.1.1 → 2.0.0.alpha.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -16
- data/.rspec +2 -0
- data/.simplecov +3 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +4 -0
- data/Dockerfile +11 -0
- data/Gemfile +2 -2
- data/LICENSE +1 -1
- data/README.md +202 -47
- data/Rakefile +62 -4
- data/clarify.gemspec +10 -7
- data/cucumber.yml +1 -0
- data/features/create-bundles.feature +10 -0
- data/features/delete-bundle.feature +7 -0
- data/features/identity-steps.feature +6 -0
- data/features/list-bundles.feature +13 -0
- data/features/search-bundles.feature +10 -0
- data/features/step_definitions/curied_url_steps.rb +6 -0
- data/features/step_definitions/error_steps.rb +4 -0
- data/features/step_definitions/http_verification_step.rb +4 -0
- data/features/step_definitions/identity_steps.rb +12 -0
- data/features/step_definitions/list_steps.rb +76 -0
- data/features/support/env.rb +36 -0
- data/features/support/lib/curies.rb +19 -0
- data/features/support/lib/customer.rb +41 -0
- data/features/support/lib/exceptions.rb +27 -0
- data/features/support/lib/names.rb +16 -0
- data/lib/clarify.rb +16 -14
- data/lib/clarify/bundle_repository.rb +26 -0
- data/lib/clarify/client.rb +51 -0
- data/lib/clarify/collection_iterator.rb +27 -0
- data/lib/clarify/configuration.rb +29 -7
- data/lib/clarify/errors.rb +22 -0
- data/lib/clarify/response.rb +29 -0
- data/lib/clarify/response_factory.rb +34 -0
- data/lib/clarify/responses/bundle.rb +11 -0
- data/lib/clarify/responses/collection.rb +31 -0
- data/lib/clarify/responses/no_body.rb +13 -0
- data/lib/clarify/responses/search_collection.rb +18 -0
- data/lib/clarify/responses/tracks.rb +15 -0
- data/lib/clarify/rest_client.rb +129 -0
- data/lib/clarify/version.rb +3 -1
- data/spec/clarify/bundle_repository_spec.rb +37 -0
- data/spec/clarify/client_spec.rb +93 -0
- data/spec/clarify/collection_iterator_spec.rb +86 -0
- data/spec/clarify/configuration_spec.rb +77 -0
- data/spec/clarify/errors_spec.rb +15 -0
- data/spec/clarify/response_factory_spec.rb +51 -0
- data/spec/clarify/response_spec.rb +69 -0
- data/spec/clarify/responses/bundle_spec.rb +8 -0
- data/spec/clarify/responses/collection_spec.rb +58 -0
- data/spec/clarify/responses/search_collection_spec.rb +40 -0
- data/spec/clarify/responses/tracks_spec.rb +18 -0
- data/spec/clarify/rest_client_spec.rb +222 -0
- data/spec/spec_helper.rb +4 -9
- data/src_readme/README_no_output.md +186 -0
- data/src_readme/examples/bundle_create.rb +11 -0
- data/src_readme/examples/bundle_fetch.rb +9 -0
- data/src_readme/examples/bundles_list_fetch.rb +11 -0
- data/src_readme/examples/bundles_paged_over.rb +8 -0
- data/src_readme/examples/bundles_search.rb +20 -0
- data/src_readme/examples/list_bundles.rb +6 -0
- data/src_readme/examples/searches_paged_over.rb +10 -0
- data/src_readme/examples/setup.rb +5 -0
- data/src_readme/make.rb +56 -0
- data/src_readme/readme.md.erb +55 -0
- metadata +127 -62
- data/LICENSE.txt +0 -24
- data/examples/create.rb +0 -14
- data/examples/delete.rb +0 -12
- data/examples/list.rb +0 -14
- data/examples/search.rb +0 -26
- data/examples/test.rb +0 -15
- data/lib/clarify/bundle.rb +0 -40
- data/lib/clarify/metadata.rb +0 -26
- data/lib/clarify/request.rb +0 -37
- data/lib/clarify/search.rb +0 -10
- data/lib/clarify/track.rb +0 -40
- data/spec/lib/clarify/bundle_spec.rb +0 -43
- data/spec/lib/clarify/configuration_spec.rb +0 -19
- data/spec/lib/clarify/metadata_spec.rb +0 -36
- data/spec/lib/clarify/search_spec.rb +0 -22
- data/spec/lib/clarify/track_spec.rb +0 -81
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27ee463c9c617e7b5fe25e15bcab7a015b2a773d
|
4
|
+
data.tar.gz: aa70eb477ccd681645764b8c60140acbb389cb2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfa320f5bf403e49fca2ff15569f4dfdbe8968cafc9e82c13c440b26bce52d9e9501037b4914ad97521e7bae6359d2298f6aa9ce8e1cc5b73383f0ee334ba770
|
7
|
+
data.tar.gz: 9bf3beeef829c852382395da189228cf0844320373d3992a2308fe8ac80ffb809b37508d035a7f56fdbf482d5dac2c7dfaa5df929cb543e8b21b2e80f3b08403
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.simplecov
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Dockerfile
ADDED
data/Gemfile
CHANGED
data/LICENSE
CHANGED
@@ -2,7 +2,7 @@ The MIT License (MIT)
|
|
2
2
|
|
3
3
|
Copyright (c) 2014 Clarify, Inc
|
4
4
|
|
5
|
-
Written by
|
5
|
+
Written by Clarify Inc. support@clarify.io
|
6
6
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,93 +1,248 @@
|
|
1
|
-
[](https://scrutinizer-ci.com/g/Clarify/clarify-ruby/?branch=master) [](https://codeclimate.com/github/Clarify/clarify-ruby)
|
2
1
|
|
3
|
-
|
2
|
+
[![Build Status][travis-image]][travis-url] [![Code Climate][cc-image]][cc-url]
|
4
3
|
|
5
|
-
|
4
|
+
# How To
|
6
5
|
|
7
|
-
|
6
|
+
You can get started in minutes using our Quickstarts:
|
8
7
|
|
9
|
-
|
8
|
+
[http://clarify.io/docs/quickstarts/](http://clarify.io/docs/quickstarts/)
|
10
9
|
|
11
|
-
|
10
|
+
## Basic Setup and Examples
|
12
11
|
|
13
|
-
|
12
|
+
Require the library and initialize the Client, which takes care of
|
13
|
+
configuration and http client setup.
|
14
14
|
|
15
|
-
|
15
|
+
```ruby
|
16
|
+
# setup.rb
|
17
|
+
require 'clarify'
|
18
|
+
require 'pp'
|
19
|
+
|
20
|
+
clarify = Clarify::Client.new(api_key: 'docs-api-key')
|
21
|
+
pp clarify
|
22
|
+
```
|
23
|
+
|
24
|
+
### Search for bundles
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
# bundles_search.rb
|
28
|
+
require 'clarify'
|
29
|
+
|
30
|
+
clarify = Clarify::Client.new(api_key: 'docs-api-key')
|
16
31
|
|
17
|
-
|
32
|
+
results = clarify.bundles.search('plane')
|
18
33
|
|
19
|
-
|
34
|
+
results.each do |bundle_results, bundle_url|
|
35
|
+
# Fetch the bundle:
|
36
|
+
bundle = clarify.get(bundle_url)
|
20
37
|
|
21
|
-
|
38
|
+
puts "#{bundle.name} - #{bundle_url}"
|
39
|
+
bundle_results['term_results'].each do |term_result|
|
40
|
+
term_result['matches'].each do |match|
|
41
|
+
type = match['type']
|
42
|
+
match['hits'].each do |hit|
|
43
|
+
puts "\tmatched #{type} content at #{hit['start']} to #{hit['end']}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
```
|
22
49
|
|
50
|
+
Example output of bundles_search.rb:
|
51
|
+
```
|
52
|
+
The Future of Women in Flying - /v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd
|
53
|
+
matched audio content at 68.92 to 69.31
|
54
|
+
First American in Earth Orbit - /v1/bundles/72aaa17a9da745c9be41ab64b60319cb
|
55
|
+
matched audio content at 99.25 to 99.43
|
23
56
|
```
|
57
|
+
|
58
|
+
### Get a list of bundles
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
# list_bundles.rb
|
24
62
|
require 'clarify'
|
63
|
+
clarify = Clarify::Client.new(api_key: 'docs-api-key')
|
25
64
|
|
26
|
-
|
27
|
-
|
28
|
-
# if key in ENV
|
29
|
-
# config.api_key = ENV['CLARIFY_API_KEY']
|
30
|
-
config.version = 1 #default is latest api version
|
65
|
+
clarify.bundles.fetch.each do |bundle_url|
|
66
|
+
puts " - #{bundle_url}"
|
31
67
|
end
|
32
68
|
```
|
33
69
|
|
34
|
-
|
70
|
+
Example output of list_bundles.rb:
|
71
|
+
```
|
72
|
+
- /v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd
|
73
|
+
- /v1/bundles/2a112c5b3e944802b932b0ddbf068c37
|
74
|
+
- /v1/bundles/ca4fbc504c6940cd96f270a0ca903917
|
75
|
+
- /v1/bundles/378efa8d163240478ae7d460c20fdb41
|
76
|
+
- /v1/bundles/4577432c51ab4fcdbed34be16ba363a2
|
77
|
+
- /v1/bundles/72aaa17a9da745c9be41ab64b60319cb
|
78
|
+
- /v1/bundles/2a0a63d07c6b46f99638edb961bc08f6
|
79
|
+
- /v1/bundles/45a8a6849e1948cea8bbb8dcb3440b68
|
80
|
+
```
|
35
81
|
|
36
|
-
|
82
|
+
### Fetch a particular bundle
|
37
83
|
|
38
|
-
|
84
|
+
```ruby
|
85
|
+
# bundle_fetch.rb
|
86
|
+
require 'clarify'
|
87
|
+
require 'pp'
|
39
88
|
|
40
|
-
|
89
|
+
clarify = Clarify::Client.new(api_key: 'docs-api-key')
|
41
90
|
|
42
|
-
|
91
|
+
bundle_url = '/v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd'
|
92
|
+
bundle = clarify.get(bundle_url)
|
93
|
+
puts "Bundle Name: #{bundle.name}"
|
94
|
+
pp bundle
|
95
|
+
```
|
43
96
|
|
44
|
-
|
97
|
+
Example output of bundle_fetch.rb:
|
98
|
+
```
|
99
|
+
Bundle Name: The Future of Women in Flying
|
100
|
+
#<Clarify::Responses::Bundle:0x007fc9c3171918
|
101
|
+
@body=
|
102
|
+
{"id"=>"3fbca3fe3678495fb08fe939dbe4f1cd",
|
103
|
+
"version"=>1,
|
104
|
+
"type"=>"audio",
|
105
|
+
"name"=>"The Future of Women in Flying",
|
106
|
+
"created"=>"2014-04-08T18:37:35.420Z",
|
107
|
+
"updated"=>"2014-04-08T18:37:35.420Z",
|
108
|
+
"_class"=>"Bundle",
|
109
|
+
"_links"=>
|
110
|
+
{"self"=>{"href"=>"/v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd"},
|
111
|
+
"curies"=>
|
112
|
+
[{"href"=>"/docs/rels/{rel}", "name"=>"clarify", "templated"=>true}],
|
113
|
+
"clarify:metadata"=>
|
114
|
+
{"href"=>"/v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd/metadata"},
|
115
|
+
"clarify:tracks"=>
|
116
|
+
{"href"=>"/v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd/tracks"}}},
|
117
|
+
@response=#<Net::HTTPOK 200 OK readbody=true>>
|
118
|
+
```
|
45
119
|
|
46
|
-
|
120
|
+
### Get a list of bundles and their names
|
47
121
|
|
48
|
-
|
122
|
+
```ruby
|
123
|
+
# bundles_list_fetch.rb
|
124
|
+
require 'clarify'
|
125
|
+
require 'pp'
|
49
126
|
|
50
|
-
|
127
|
+
clarify = Clarify::Client.new(api_key: 'docs-api-key')
|
51
128
|
|
52
|
-
|
129
|
+
bundles = clarify.bundles.fetch
|
53
130
|
|
54
|
-
|
131
|
+
bundles.each do |url|
|
132
|
+
bundle = clarify.get(url)
|
133
|
+
puts " - Bundle Name: #{bundle.name}"
|
134
|
+
end
|
135
|
+
```
|
55
136
|
|
56
|
-
|
137
|
+
Example output of bundles_list_fetch.rb:
|
138
|
+
```
|
139
|
+
- Bundle Name: The Future of Women in Flying
|
140
|
+
- Bundle Name: Election Eve Campaign Speech
|
141
|
+
- Bundle Name: Address to the Women of America
|
142
|
+
- Bundle Name: Address to Congress - Baseball
|
143
|
+
- Bundle Name: On Black Power
|
144
|
+
- Bundle Name: First American in Earth Orbit
|
145
|
+
- Bundle Name: On Releasing the Watergate Tapes
|
146
|
+
- Bundle Name: Resignation Address
|
147
|
+
```
|
57
148
|
|
58
|
-
|
149
|
+
### Create a bundle
|
59
150
|
|
60
|
-
|
151
|
+
Here you will need your own API key. Creating the bundle will return a 204,
|
152
|
+
which means it has been Created, but is not done processing.
|
61
153
|
|
62
154
|
```ruby
|
155
|
+
# bundle_create.rb
|
63
156
|
require 'clarify'
|
64
|
-
|
157
|
+
require 'pp'
|
158
|
+
|
159
|
+
clarify = Clarify::Client.new(api_key: ENV['CLARIFY_API_KEY'])
|
160
|
+
|
161
|
+
created_bundle = clarify.bundles.create!(
|
162
|
+
name: 'Harvard Sentences #1',
|
163
|
+
media_url: 'http://media.clarify.io/audio/samples/harvard-sentences-1.wav'
|
164
|
+
)
|
165
|
+
|
166
|
+
pp created_bundle
|
167
|
+
```
|
168
|
+
|
169
|
+
Example output of bundle_create.rb:
|
170
|
+
```
|
171
|
+
#<Clarify::Response:0x007ffb5428fc38
|
172
|
+
@body=
|
173
|
+
{"id"=>"415bd191442846a6839c88ae3956eb64",
|
174
|
+
"_class"=>"Ref",
|
175
|
+
"_links"=>
|
176
|
+
{"self"=>{"href"=>"/v1/bundles/415bd191442846a6839c88ae3956eb64"},
|
177
|
+
"curies"=>
|
178
|
+
[{"href"=>"/docs/rels/{rel}", "name"=>"clarify", "templated"=>true}],
|
179
|
+
"clarify:metadata"=>
|
180
|
+
{"href"=>"/v1/bundles/415bd191442846a6839c88ae3956eb64/metadata"},
|
181
|
+
"clarify:tracks"=>
|
182
|
+
{"href"=>"/v1/bundles/415bd191442846a6839c88ae3956eb64/tracks"}}},
|
183
|
+
@response=#<Net::HTTPCreated 201 Created readbody=true>>
|
65
184
|
```
|
66
185
|
|
67
|
-
|
186
|
+
## More Advanced Usage
|
187
|
+
#
|
188
|
+
### Get all of your searches over many pages
|
68
189
|
|
69
190
|
```ruby
|
70
|
-
|
71
|
-
|
72
|
-
|
191
|
+
# searches_paged_over.rb
|
192
|
+
require 'clarify'
|
193
|
+
require 'pp'
|
194
|
+
|
195
|
+
clarify = Clarify::Client.new(api_key: 'docs-api-key')
|
196
|
+
|
197
|
+
first_page = clarify.bundles.search('flight')
|
198
|
+
clarify.pager(first_page).each do |result, bundle_url|
|
199
|
+
puts " - #{clarify.get(bundle_url).name}"
|
200
|
+
pp result
|
201
|
+
end
|
202
|
+
```
|
203
|
+
|
204
|
+
Example output of searches_paged_over.rb:
|
205
|
+
```
|
206
|
+
- First American in Earth Orbit
|
207
|
+
{"score"=>1,
|
208
|
+
"term_results"=>
|
209
|
+
[{"score"=>0.379,
|
210
|
+
"matches"=>
|
211
|
+
[{"type"=>"audio",
|
212
|
+
"track"=>0,
|
213
|
+
"hits"=>
|
214
|
+
[{"start"=>67.41, "end"=>67.55}, {"start"=>92.76, "end"=>92.94}]}]}]}
|
73
215
|
```
|
74
216
|
|
75
|
-
|
217
|
+
### Get all of your bundles over many pages
|
76
218
|
|
77
219
|
```ruby
|
78
|
-
|
79
|
-
|
80
|
-
|
220
|
+
# bundles_paged_over.rb
|
221
|
+
require 'clarify'
|
222
|
+
|
223
|
+
clarify = Clarify::Client.new(api_key: 'docs-api-key')
|
224
|
+
|
225
|
+
first_page = clarify.bundles.fetch
|
226
|
+
clarify.pager(first_page).each do |bundle_url|
|
227
|
+
puts " - #{clarify.get(bundle_url).name}"
|
228
|
+
end
|
81
229
|
```
|
82
230
|
|
83
|
-
|
231
|
+
Example output of bundles_paged_over.rb:
|
232
|
+
```
|
233
|
+
- The Future of Women in Flying
|
234
|
+
- Election Eve Campaign Speech
|
235
|
+
- Address to the Women of America
|
236
|
+
- Address to Congress - Baseball
|
237
|
+
- On Black Power
|
238
|
+
- First American in Earth Orbit
|
239
|
+
- On Releasing the Watergate Tapes
|
240
|
+
- Resignation Address
|
241
|
+
```
|
84
242
|
|
85
|
-
## Contributing
|
86
243
|
|
87
|
-
|
88
|
-
|
89
|
-
3. Run the rspec tests with `rake spec`
|
90
|
-
4. Commit your changes (`git commit -am 'Add some feature'`)
|
91
|
-
5. Push to the branch (`git push origin my-new-feature`)
|
92
|
-
6. Create new Pull Request
|
244
|
+
[travis-image]: https://travis-ci.org/Clarify/clarify-ruby.svg
|
245
|
+
[travis-url]: https://travis-ci.org/Clarify/clarify-ruby
|
93
246
|
|
247
|
+
[cc-image]: https://codeclimate.com/github/Clarify/clarify-ruby/badges/gpa.svg
|
248
|
+
[cc-url]: https://codeclimate.com/github/Clarify/clarify-ruby
|
data/Rakefile
CHANGED
@@ -1,10 +1,68 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
require 'rake/clean'
|
2
6
|
|
3
|
-
|
7
|
+
CLEAN.include(FileList['coverage'])
|
8
|
+
|
9
|
+
task default: [:test]
|
10
|
+
task test: [:clean, :rubocop, :spec, :clean, :features, :docs]
|
11
|
+
task docs: [:examples, :build_docs, :no_doc_change]
|
4
12
|
|
5
13
|
RSpec::Core::RakeTask.new(:spec) do |s|
|
6
14
|
s.pattern = 'spec/**/*.rb'
|
7
15
|
end
|
8
16
|
|
9
|
-
|
10
|
-
task
|
17
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
18
|
+
task.patterns = ['**/*.rb']
|
19
|
+
task.fail_on_error = true
|
20
|
+
end
|
21
|
+
|
22
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
23
|
+
t.cucumber_opts = "features --format pretty"
|
24
|
+
end
|
25
|
+
|
26
|
+
task :build_docs do
|
27
|
+
pid = fork do
|
28
|
+
exec('ruby', 'src_readme/make.rb')
|
29
|
+
end
|
30
|
+
|
31
|
+
Process.wait(pid)
|
32
|
+
|
33
|
+
if $?.exitstatus > 0
|
34
|
+
puts "Readme build failed!"
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
task :no_doc_change do
|
40
|
+
pid = fork do
|
41
|
+
exec('git', 'diff', '--exit-code', 'src_readme/README_no_output.md')
|
42
|
+
end
|
43
|
+
|
44
|
+
Process.wait(pid)
|
45
|
+
|
46
|
+
if $?.exitstatus > 0
|
47
|
+
puts "Readme build changed the README.md! Must rebuild and commit."
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
task :examples do
|
53
|
+
FileList['src_readme/examples/*.rb'].each do |file|
|
54
|
+
puts "Testing example: #{file}"
|
55
|
+
|
56
|
+
pid = fork do
|
57
|
+
exec('ruby', file)
|
58
|
+
end
|
59
|
+
Process.wait(pid)
|
60
|
+
|
61
|
+
if $?.exitstatus > 0
|
62
|
+
puts "Example #{file} failed!"
|
63
|
+
exit 1
|
64
|
+
end
|
65
|
+
|
66
|
+
puts ""
|
67
|
+
end
|
68
|
+
end
|