clarify 2.0.0 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9dd13f6f24ee7c62e04f6f7a4a3c48f71692482
4
- data.tar.gz: d9f41aed7e8805c0bd67599d699e51bcf79fee19
3
+ metadata.gz: c66097ba2e37737f19845cf320ce3490e0c2d996
4
+ data.tar.gz: 22ad56e43e04b86ca099d17cbbe772af8ea941c6
5
5
  SHA512:
6
- metadata.gz: 9a21bb48f8005e50ca0b872ce6ed6da1860b4a83ce4607ee10120ee2e8cc93a6b245b10fead575aa906fad2a01c7fe78117bb1d8205322f7092e2beb49c9d9d7
7
- data.tar.gz: ac8c17bef44562c8561ecf2ba035e29dfaa5abdd3c5ccbc5742ddb71dced7f124b5450e466f640ab531ea1648765d2d6b5c99e4547d9b71fc90656cb5a6c6821
6
+ metadata.gz: bae0b919bc4ca1a0e37b58c9d5228e3acdb4ca3dbeb828d7290ffe70bbb3a6d597b66080bcf91e4a7d1be867c03b4ef62b58e8c623d5140f7e99ac1cfa92ea89
7
+ data.tar.gz: 29213c93cb0e203d53b2237b658d8390db5f36102b17859ea7254fd023b068c236ea93b38e1cee2ac99c9f8ed9c54c77c3c104f718e8ad424b988a60e67cb7a0
@@ -1,3 +1,4 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
4
  - 2.2.1
@@ -1,3 +1,8 @@
1
+ # v2.1.0
2
+
3
+ - Added support for Insights: SpokenKeywordsInsight,
4
+ SpokenWordsInsight.
5
+
1
6
  # v2.0.0
2
7
 
3
8
  Release
data/Dockerfile CHANGED
@@ -1,11 +1,9 @@
1
1
  FROM ruby:latest
2
2
 
3
- RUN mkdir -p /data/lib/clarify/
3
+ RUN mkdir -p /data
4
4
  WORKDIR /data
5
- ADD Gemfile clarify.gemspec /data/
6
- ADD lib/clarify/version.rb /data/lib/clarify/version.rb
5
+ ADD . /data/
7
6
  RUN bundle install
8
7
 
9
- ADD features /data/features
10
8
 
11
9
  ENTRYPOINT [ "rake" ]
data/README.md CHANGED
@@ -49,10 +49,12 @@ end
49
49
 
50
50
  Example output of bundles_search.rb:
51
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
52
+ Obama-2004-DNC-Keynote - /v1/bundles/51ee9932989c47d3adf734c4e467c83f
53
+ matched audio content at 951.62 to 951.82
54
+ How-Schools-Kill-Creativity - /v1/bundles/6864abafeee8458bb9902628ee270cae
55
+ matched audio content at 485.92 to 486.11
56
+ The-Surprising-Science-of-Happiness - /v1/bundles/d6dcddf1066b4dd4bed78334e553e233
57
+ matched audio content at 80.94 to 81.57
56
58
  ```
57
59
 
58
60
  ### Get a list of bundles
@@ -69,14 +71,16 @@ end
69
71
 
70
72
  Example output of list_bundles.rb:
71
73
  ```
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
74
+ - /v1/bundles/d6dcddf1066b4dd4bed78334e553e233
75
+ - /v1/bundles/f87a4e7928a84cf192091a337dbbdd80
76
+ - /v1/bundles/cbc77abbc54e4cc686d65156fe1d29a3
77
+ - /v1/bundles/6864abafeee8458bb9902628ee270cae
78
+ - /v1/bundles/75afdd5a5af74a559b8381c22ead1047
79
+ - /v1/bundles/ae5fbaa351e44897a211c0c9f097ffba
80
+ - /v1/bundles/0e81c313755248e3860c6f569498eb84
81
+ - /v1/bundles/f145f401d14442c1838d04764c5a5bf1
82
+ - /v1/bundles/41266fd35e6f4cf78c6040dd24b9c34d
83
+ - /v1/bundles/68bca9f916e846c79ccd2b8079afc2f4
80
84
  ```
81
85
 
82
86
  ### Fetch a particular bundle
@@ -88,7 +92,7 @@ require 'pp'
88
92
 
89
93
  clarify = Clarify::Client.new(api_key: 'docs-api-key')
90
94
 
91
- bundle_url = '/v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd'
95
+ bundle_url = '/v1/bundles/d6dcddf1066b4dd4bed78334e553e233'
92
96
  bundle = clarify.get(bundle_url)
93
97
  puts "Bundle Name: #{bundle.name}"
94
98
  pp bundle
@@ -96,27 +100,156 @@ pp bundle
96
100
 
97
101
  Example output of bundle_fetch.rb:
98
102
  ```
99
- Bundle Name: The Future of Women in Flying
100
- #<Clarify::Responses::Bundle:0x007fc9c3171918
103
+ Bundle Name: The-Surprising-Science-of-Happiness
104
+ #<Clarify::Responses::Bundle:0x007f65808368b8
101
105
  @body=
102
- {"id"=>"3fbca3fe3678495fb08fe939dbe4f1cd",
106
+ {"id"=>"d6dcddf1066b4dd4bed78334e553e233",
103
107
  "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
+ "name"=>"The-Surprising-Science-of-Happiness",
109
+ "created"=>"2015-04-21T18:13:47.377Z",
110
+ "updated"=>"2015-04-21T18:13:47.377Z",
108
111
  "_class"=>"Bundle",
109
112
  "_links"=>
110
- {"self"=>{"href"=>"/v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd"},
113
+ {"self"=>{"href"=>"/v1/bundles/d6dcddf1066b4dd4bed78334e553e233"},
111
114
  "curies"=>
112
115
  [{"href"=>"/docs/rels/{rel}", "name"=>"clarify", "templated"=>true}],
113
116
  "clarify:metadata"=>
114
- {"href"=>"/v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd/metadata"},
117
+ {"href"=>"/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/metadata"},
115
118
  "clarify:tracks"=>
116
- {"href"=>"/v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd/tracks"}}},
119
+ {"href"=>"/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/tracks"},
120
+ "clarify:insights"=>
121
+ {"href"=>"/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights"}}},
117
122
  @response=#<Net::HTTPOK 200 OK readbody=true>>
118
123
  ```
119
124
 
125
+ ### Fetch a particular bundle's insight list
126
+
127
+ ```ruby
128
+ # bundle_insight_list.rb
129
+ require 'clarify'
130
+ require 'pp'
131
+
132
+ clarify = Clarify::Client.new(api_key: 'docs-api-key')
133
+
134
+ bundle_url = '/v1/bundles/d6dcddf1066b4dd4bed78334e553e233'
135
+ bundle = clarify.get(bundle_url)
136
+
137
+ bundle_insights_url = bundle.relation('clarify:insights')
138
+
139
+ puts "Insights for Bundle Name: #{bundle.name} (#{bundle_insights_url})"
140
+ insights = clarify.get(bundle_insights_url)
141
+ pp insights
142
+ puts '-----------'
143
+ insights.each do |insight, insight_url|
144
+ puts "Insight #{insight} (#{insight_url})"
145
+ insight = clarify.get(insight_url)
146
+ pp insight
147
+ puts ''
148
+ puts ''
149
+ puts ''
150
+ end
151
+ ```
152
+
153
+ Example output of bundle_insight_list.rb:
154
+ ```
155
+ Insights for Bundle Name: The-Surprising-Science-of-Happiness (/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights)
156
+ #<Clarify::Responses::Insights:0x007f710e256760
157
+ @body=
158
+ {"bundle_id"=>"d6dcddf1066b4dd4bed78334e553e233",
159
+ "created"=>"2015-04-21T18:13:47.388Z",
160
+ "updated"=>"2015-05-16T20:39:27.740Z",
161
+ "_class"=>"Insights",
162
+ "_links"=>
163
+ {"self"=>{"href"=>"/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights"},
164
+ "parent"=>{"href"=>"/v1/bundles/d6dcddf1066b4dd4bed78334e553e233"},
165
+ "insight:spoken_words"=>
166
+ {"href"=>
167
+ "/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights/c1ea412ef6aa434dbe05df12f97b9f89"},
168
+ "insight:spoken_keywords"=>
169
+ {"href"=>
170
+ "/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights/b83668e8089148b7a5c96b1b045637ec"},
171
+ "curies"=>
172
+ [{"href"=>"/docs/insights/{rel}",
173
+ "name"=>"insight",
174
+ "templated"=>true}]}},
175
+ @response=#<Net::HTTPOK 200 OK readbody=true>>
176
+ -----------
177
+ Insight insight:spoken_words (/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights/c1ea412ef6aa434dbe05df12f97b9f89)
178
+ #<Clarify::Responses::SpokenWordsInsight:0x007f710e226b78
179
+ @body=
180
+ {"id"=>"c1ea412ef6aa434dbe05df12f97b9f89",
181
+ "bundle_id"=>"d6dcddf1066b4dd4bed78334e553e233",
182
+ "name"=>"spoken_words",
183
+ "status"=>"ready",
184
+ "created"=>"2015-04-21T18:13:50.087Z",
185
+ "updated"=>"2015-04-21T18:13:50.090Z",
186
+ "track_data"=>
187
+ [{"spoken_duration"=>1189.48,
188
+ "word_count"=>3709,
189
+ "spoken_duration_percent"=>0.93}],
190
+ "_class"=>"SpokenWordsInsight",
191
+ "_links"=>
192
+ {"self"=>
193
+ {"href"=>
194
+ "/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights/c1ea412ef6aa434dbe05df12f97b9f89"},
195
+ "curies"=>
196
+ [{"href"=>"/docs/rels/{rel}", "name"=>"clarify", "templated"=>true}],
197
+ "parent"=>
198
+ {"href"=>"/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights"},
199
+ "clarify:bundle"=>
200
+ {"href"=>"/v1/bundles/d6dcddf1066b4dd4bed78334e553e233"}}},
201
+ @response=#<Net::HTTPOK 200 OK readbody=true>>
202
+
203
+
204
+
205
+ Insight insight:spoken_keywords (/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights/b83668e8089148b7a5c96b1b045637ec)
206
+ #<Clarify::Responses::SpokenKeywordsInsight:0x007f710e197ea0
207
+ @body=
208
+ {"id"=>"b83668e8089148b7a5c96b1b045637ec",
209
+ "bundle_id"=>"d6dcddf1066b4dd4bed78334e553e233",
210
+ "name"=>"spoken_keywords",
211
+ "status"=>"ready",
212
+ "created"=>"2015-05-16T20:39:27.739Z",
213
+ "updated"=>"2015-05-16T20:39:27.741Z",
214
+ "track_data"=>
215
+ [{"keywords"=>
216
+ [{"term"=>"one", "count"=>43, "weight"=>1},
217
+ {"term"=>"happiness", "count"=>27, "weight"=>0.628},
218
+ {"term"=>"like", "count"=>23, "weight"=>0.535},
219
+ {"term"=>"can", "count"=>20, "weight"=>0.465},
220
+ {"term"=>"know", "count"=>18, "weight"=>0.419},
221
+ {"term"=>"people", "count"=>17, "weight"=>0.395},
222
+ {"term"=>"really", "count"=>16, "weight"=>0.372},
223
+ {"term"=>"right", "count"=>15, "weight"=>0.349},
224
+ {"term"=>"2", "count"=>14, "weight"=>0.326},
225
+ {"term"=>"make", "count"=>13, "weight"=>0.302},
226
+ {"term"=>"change", "count"=>13, "weight"=>0.302},
227
+ {"term"=>"us", "count"=>12, "weight"=>0.279},
228
+ {"term"=>"say", "count"=>11, "weight"=>0.256},
229
+ {"term"=>"just", "count"=>11, "weight"=>0.256},
230
+ {"term"=>"better", "count"=>10, "weight"=>0.233},
231
+ {"term"=>"much", "count"=>10, "weight"=>0.233},
232
+ {"term"=>"now", "count"=>10, "weight"=>0.233},
233
+ {"term"=>"course", "count"=>10, "weight"=>0.233},
234
+ {"term"=>"3", "count"=>10, "weight"=>0.233},
235
+ {"term"=>"get", "count"=>9, "weight"=>0.209}]}],
236
+ "_class"=>"SpokenKeywordsInsight",
237
+ "_links"=>
238
+ {"self"=>
239
+ {"href"=>
240
+ "/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights/b83668e8089148b7a5c96b1b045637ec"},
241
+ "curies"=>
242
+ [{"href"=>"/docs/rels/{rel}", "name"=>"clarify", "templated"=>true}],
243
+ "parent"=>
244
+ {"href"=>"/v1/bundles/d6dcddf1066b4dd4bed78334e553e233/insights"},
245
+ "clarify:bundle"=>
246
+ {"href"=>"/v1/bundles/d6dcddf1066b4dd4bed78334e553e233"}}},
247
+ @response=#<Net::HTTPOK 200 OK readbody=true>>
248
+
249
+
250
+
251
+ ```
252
+
120
253
  ### Get a list of bundles and their names
121
254
 
122
255
  ```ruby
@@ -136,14 +269,16 @@ end
136
269
 
137
270
  Example output of bundles_list_fetch.rb:
138
271
  ```
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
272
+ - Bundle Name: The-Surprising-Science-of-Happiness
273
+ - Bundle Name: GWB-2004-Victory-Speech
274
+ - Bundle Name: harvard-sentences-2
275
+ - Bundle Name: How-Schools-Kill-Creativity
276
+ - Bundle Name: MLK-I-Have-a-Dream
277
+ - Bundle Name: dorothyandthewizardinoz_01
278
+ - Bundle Name: How-Great-Leaders-Inspire-Action
279
+ - Bundle Name: The-Happy-Secret-to-Better-Work
280
+ - Bundle Name: FDR-Statue-of-Liberty
281
+ - Bundle Name: Reagan-Challenger-Disaster
147
282
  ```
148
283
 
149
284
  ### Get a list of tracks and the URL of their original media
@@ -165,14 +300,16 @@ end
165
300
 
166
301
  Example output of bundles_show_tracks.rb:
167
302
  ```
168
- - http://archive.org/download/Greatest_Speeches_of_the_20th_Century/TheFutureofWomeninFlying_64kb.mp3
169
- - http://ia700200.us.archive.org/18/items/Greatest_Speeches_of_the_20th_Century/ElectionEveCampaignSpeech_64kb.mp3
170
- - http://ia600200.us.archive.org/18/items/Greatest_Speeches_of_the_20th_Century/AddresstotheWomenofAmerica_64kb.mp3
171
- - http://ia700200.us.archive.org/18/items/Greatest_Speeches_of_the_20th_Century/AddresstoCongress-1958_64kb.mp3
172
- - http://ia700200.us.archive.org/18/items/Greatest_Speeches_of_the_20th_Century/OnBlackPower_64kb.mp3
173
- - http://ia600200.us.archive.org/18/items/Greatest_Speeches_of_the_20th_Century/TheFirstAmericaninEarthOrbit_64kb.mp3
174
- - http://ia700200.us.archive.org/18/items/Greatest_Speeches_of_the_20th_Century/OnReleasingtheWatergateTapes_64kb.mp3
175
- - http://ia600200.us.archive.org/18/items/Greatest_Speeches_of_the_20th_Century/ResignationAddress-1974_64kb.mp3
303
+ - http://media.clarify.io/video/presentations/DanGilbert-TED2004-The-Surprising-Science-of-Happiness.mp4
304
+ - http://media.clarify.io/audio/speeches/GWB-2004-Victory-Speech.mp3
305
+ - http://media.clarify.io/audio/samples/harvard-sentences-2.wav
306
+ - http://media.clarify.io/video/presentations/SirKenRobinson-TED2006-How-Schools-Kill-Creativity.mp4
307
+ - http://media.clarify.io/audio/speeches/MLK-I-Have-a-Dream.mp3
308
+ - http://media.clarify.io/audio/books/dorothyandthewizardinoz_01_baum_64kb.mp3
309
+ - http://media.clarify.io/video/presentations/SimonSinek-TEDxPugetSound-How-Great-Leaders-Inspire-Action.mp4
310
+ - http://media.clarify.io/video/presentations/ShawnAchor-TEDxBloomington-The-Happy-Secret-to-Better-Work.mp4
311
+ - http://media.clarify.io/audio/speeches/FDR-Statue-of-Liberty.mp3
312
+ - http://media.clarify.io/audio/speeches/Reagan-Challenger-Disaster.mp3
176
313
  ```
177
314
 
178
315
  ### Create a bundle
@@ -197,18 +334,20 @@ pp created_bundle
197
334
 
198
335
  Example output of bundle_create.rb:
199
336
  ```
200
- #<Clarify::Response:0x007ffb5428fc38
337
+ #<Clarify::Response:0x007fd0740a7278
201
338
  @body=
202
- {"id"=>"415bd191442846a6839c88ae3956eb64",
339
+ {"id"=>"1bf2f176592144398d799bfa2298f629",
203
340
  "_class"=>"Ref",
204
341
  "_links"=>
205
- {"self"=>{"href"=>"/v1/bundles/415bd191442846a6839c88ae3956eb64"},
342
+ {"self"=>{"href"=>"/v1/bundles/1bf2f176592144398d799bfa2298f629"},
206
343
  "curies"=>
207
344
  [{"href"=>"/docs/rels/{rel}", "name"=>"clarify", "templated"=>true}],
208
345
  "clarify:metadata"=>
209
- {"href"=>"/v1/bundles/415bd191442846a6839c88ae3956eb64/metadata"},
346
+ {"href"=>"/v1/bundles/1bf2f176592144398d799bfa2298f629/metadata"},
210
347
  "clarify:tracks"=>
211
- {"href"=>"/v1/bundles/415bd191442846a6839c88ae3956eb64/tracks"}}},
348
+ {"href"=>"/v1/bundles/1bf2f176592144398d799bfa2298f629/tracks"},
349
+ "clarify:insights"=>
350
+ {"href"=>"/v1/bundles/1bf2f176592144398d799bfa2298f629/insights"}}},
212
351
  @response=#<Net::HTTPCreated 201 Created readbody=true>>
213
352
  ```
214
353
 
@@ -232,15 +371,60 @@ end
232
371
 
233
372
  Example output of searches_paged_over.rb:
234
373
  ```
235
- - First American in Earth Orbit
374
+ - Reagan-Challenger-Disaster
236
375
  {"score"=>1,
237
376
  "term_results"=>
238
- [{"score"=>0.379,
377
+ [{"score"=>0.34,
239
378
  "matches"=>
240
379
  [{"type"=>"audio",
241
380
  "track"=>0,
242
381
  "hits"=>
243
- [{"start"=>67.41, "end"=>67.55}, {"start"=>92.76, "end"=>92.94}]}]}]}
382
+ [{"start"=>34.29, "end"=>34.71}, {"start"=>172.59, "end"=>173.2}]}]}]}
383
+ - How-Great-Leaders-Inspire-Action
384
+ {"score"=>0.632,
385
+ "term_results"=>
386
+ [{"score"=>0.286,
387
+ "matches"=>
388
+ [{"type"=>"audio",
389
+ "track"=>0,
390
+ "hits"=>
391
+ [{"start"=>64.53, "end"=>65},
392
+ {"start"=>72.9, "end"=>73.12},
393
+ {"start"=>502.59, "end"=>502.81},
394
+ {"start"=>625.4, "end"=>625.65},
395
+ {"start"=>637.97, "end"=>638.25}]}]}]}
396
+ - FDR-Statue-of-Liberty
397
+ {"score"=>0.566,
398
+ "term_results"=>
399
+ [{"score"=>0.155,
400
+ "matches"=>
401
+ [{"type"=>"audio",
402
+ "track"=>0,
403
+ "hits"=>[{"start"=>48.47, "end"=>48.73}]}]}]}
404
+ - The-Happy-Secret-to-Better-Work
405
+ {"score"=>0.354,
406
+ "term_results"=>
407
+ [{"score"=>0.097,
408
+ "matches"=>
409
+ [{"type"=>"audio",
410
+ "track"=>0,
411
+ "hits"=>[{"start"=>652.78, "end"=>653.05}]}]}]}
412
+ - The-Surprising-Science-of-Happiness
413
+ {"score"=>0.283,
414
+ "term_results"=>
415
+ [{"score"=>0.078,
416
+ "matches"=>
417
+ [{"type"=>"audio",
418
+ "track"=>0,
419
+ "hits"=>[{"start"=>78.05, "end"=>78.39}]}]}]}
420
+ - On-the-Edge-of-Hypermedia
421
+ {"score"=>0.212,
422
+ "term_results"=>
423
+ [{"score"=>0.058,
424
+ "matches"=>
425
+ [{"type"=>"audio",
426
+ "track"=>0,
427
+ "hits"=>[{"start"=>2083.62, "end"=>2084.12}]}]}]}
244
428
  ```
245
429
 
246
430
  ### Get all of your bundles over many pages
@@ -259,14 +443,23 @@ end
259
443
 
260
444
  Example output of bundles_paged_over.rb:
261
445
  ```
262
- - The Future of Women in Flying
263
- - Election Eve Campaign Speech
264
- - Address to the Women of America
265
- - Address to Congress - Baseball
266
- - On Black Power
267
- - First American in Earth Orbit
268
- - On Releasing the Watergate Tapes
269
- - Resignation Address
446
+ - The-Surprising-Science-of-Happiness
447
+ - GWB-2004-Victory-Speech
448
+ - harvard-sentences-2
449
+ - How-Schools-Kill-Creativity
450
+ - MLK-I-Have-a-Dream
451
+ - dorothyandthewizardinoz_01
452
+ - How-Great-Leaders-Inspire-Action
453
+ - The-Happy-Secret-to-Better-Work
454
+ - FDR-Statue-of-Liberty
455
+ - Reagan-Challenger-Disaster
456
+ - Obama-2008-DNC-Speech
457
+ - GWB-2000-Victory-Speech
458
+ - Obama-2004-DNC-Keynote
459
+ - FDR-Inaugural-Address
460
+ - Mission-Critical-Innovation
461
+ - On-the-Edge-of-Hypermedia
462
+ - harvard-sentences-1
270
463
  ```
271
464
 
272
465
 
@@ -0,0 +1,14 @@
1
+
2
+ Feature: As a user of the API, I am able to list my submitted bundles.
3
+ Scenario: I am building an index page to my bundle collection.
4
+ # This is not a great test, but I wanted to get *A* cuke in place before
5
+ # releasing this test.
6
+ Given I am using the environment's API key
7
+ And I know the following urls referenced as:
8
+ | name | URL |
9
+ | media:statue-of-liberty | http://media.clarify.io/audio/speeches/FDR-Statue-of-Liberty.mp3 |
10
+ When I create a bundle named "Statue of Liberty" with the media url "[media:statue-of-liberty]"
11
+ And I wait until the bundle has the "insight:spoken_words" insight
12
+ Then the spoken words insight should reveal "689" spoken words
13
+
14
+
@@ -2,12 +2,12 @@ Feature: As a user of the API, I am able to list my submitted bundles.
2
2
  Scenario: I am building an index page to my bundle collection.
3
3
  Given I am using the documentation API key
4
4
  And I know the following urls referenced as:
5
- | name | URL |
6
- | media:future-of-women-flying | http://archive.org/download/Greatest_Speeches_of_the_20th_Century/TheFutureofWomeninFlying_64kb.mp3 |
7
- | media:watergate-tapes | http://ia700200.us.archive.org/18/items/Greatest_Speeches_of_the_20th_Century/OnReleasingtheWatergateTapes_64kb.mp3 |
8
- | media:resignation-address | http://ia600200.us.archive.org/18/items/Greatest_Speeches_of_the_20th_Century/ResignationAddress-1974_64kb.mp3 |
5
+ | name | URL |
6
+ | media:statue-of-liberty | http://media.clarify.io/audio/speeches/FDR-Statue-of-Liberty.mp3 |
7
+ | media:gwb-victory-speech | http://media.clarify.io/audio/speeches/GWB-2004-Victory-Speech.mp3 |
8
+ | media:harvard-sentences | http://media.clarify.io/audio/samples/harvard-sentences-2.wav |
9
9
  When I request a list of bundles
10
10
  Then I should get the HTTP status code 200
11
- And my results should include a track with the URL "[media:future-of-women-flying]"
12
- And my results should include a track with the URL "[media:watergate-tapes]"
13
- And my results should include a track with the URL "[media:resignation-address]"
11
+ And my results should include a track with the URL "[media:statue-of-liberty]"
12
+ And my results should include a track with the URL "[media:gwb-victory-speech]"
13
+ And my results should include a track with the URL "[media:harvard-sentences]"
@@ -3,8 +3,8 @@ Feature: As a user of the API, I am able to search for bundles based on the cont
3
3
  Scenario: I am building a search functionality into my application.
4
4
  Given I am using the documentation API key
5
5
  And I know the following urls referenced as:
6
- | name | URL |
7
- | media:future-of-women-flying | http://archive.org/download/Greatest_Speeches_of_the_20th_Century/TheFutureofWomeninFlying_64kb.mp3 |
8
- When I search my bundles for the text "women"
6
+ | name | URL |
7
+ | media:creativity | http://media.clarify.io/video/presentations/SirKenRobinson-TED2006-How-Schools-Kill-Creativity.mp4 |
8
+ When I search my bundles for the text "creativity"
9
9
  Then I should get the HTTP status code 200
10
- And my results should include a track with the URL "[media:future-of-women-flying]"
10
+ And my results should include a track with the URL "[media:creativity]"
@@ -34,6 +34,22 @@ Then(/^my results should include a track with the URL "(.*?)"$/) do |url|
34
34
  expect(media_urls).to include(curies.resolve(url))
35
35
  end
36
36
 
37
+ Then(/^my bundle has exactly "(\d+)" tracks?$/) do |count|
38
+ tracks = customer.restclient.get(@my_bundle.relation('clarify:tracks'))
39
+
40
+ media_urls = tracks.map { |track| track['media_url'] }
41
+
42
+ expect(media_urls.length).to eq(count.to_i)
43
+ end
44
+
45
+ Then(/^my bundle should include a track with the URL "(.*?)"$/) do |url|
46
+ tracks = customer.restclient.get(@my_bundle.relation('clarify:tracks'))
47
+
48
+ media_urls = tracks.map { |track| track['media_url'] }
49
+
50
+ expect(media_urls).to include(curies.resolve(url))
51
+ end
52
+
37
53
  # rubocop:disable Metrics/LineLength
38
54
  When(/^I create a bundle named "(.*?)" with the media url "(.*?)"$/) do |name, url|
39
55
  # rubocop:enable Metrics/LineLength
@@ -41,7 +57,7 @@ When(/^I create a bundle named "(.*?)" with the media url "(.*?)"$/) do |name, u
41
57
  name: names.translate(name),
42
58
  media_url: curies.resolve(url)
43
59
  }
44
- customer.bundle_repository.create!(bundle)
60
+ @my_bundle = customer.bundle_repository.create!(bundle)
45
61
  end
46
62
 
47
63
  Then(/^my results should incude a bundle named "(.*?)"$/) do |name|
@@ -61,6 +77,12 @@ Given(/^I have a bundle named "(.*?)"$/) do |name|
61
77
  @my_bundle = customer.bundle_repository.create!(bundle)
62
78
  end
63
79
 
80
+ When(/^I add a track with the URL "(.*?)" to the bundle$/) do |url|
81
+ create_url = @my_bundle.relation!('clarify:tracks')
82
+
83
+ @result = customer.client.post(create_url, media_url: curies.resolve(url))
84
+ end
85
+
64
86
  When(/^I delete my bundle$/) do
65
87
  customer.bundle_repository.delete!(@my_bundle)
66
88
  end
@@ -74,3 +96,29 @@ Then(/^the server should not list my bundle$/) do
74
96
 
75
97
  expect(bundle_urls).to_not include(@my_bundle.relation('self'))
76
98
  end
99
+
100
+ When(/I wait until the bundle has the "(.*?)" insight/) do |insight|
101
+ insight_url = nil
102
+ 60.times do |i|
103
+ insights_url = @my_bundle.relation('clarify:insights')
104
+ puts "Fetching insight url (#{insights_url}) attempt #{i}"
105
+ insights = customer.client.get(insights_url)
106
+
107
+ if insights.relation(insight)
108
+ insight_url = insights.relation(insight)
109
+ break
110
+ else
111
+ sleep(i)
112
+ end
113
+ end
114
+
115
+ expect(insight_url).to_not eq(nil)
116
+ end
117
+
118
+ Then(/^the spoken words insight should reveal "(\d+)" spoken words$/) do |words|
119
+ insights_url = @my_bundle.relation('clarify:insights')
120
+ insights = customer.client.get(insights_url)
121
+ insight_url = insights.relation('insight:spoken_words')
122
+ insight = customer.client.get(insight_url)
123
+ expect(insight.body['track_data'][0]['word_count']).to eq(words.to_i)
124
+ end
@@ -32,5 +32,11 @@ World do
32
32
  end
33
33
 
34
34
  After do
35
+ customer.log_in_via_environment
36
+ customer.client.pager(customer.bundle_repository.fetch).each do |bundle_url|
37
+ bundle = customer.client.get(bundle_url)
38
+ customer.bundle_repository.delete!(bundle) if names.matches?(bundle.name)
39
+ end
40
+
35
41
  exceptions.raise_pending!
36
42
  end
@@ -9,6 +9,10 @@ module ClarifyTests
9
9
  "#{uuid}{#{name}}"
10
10
  end
11
11
 
12
+ def matches?(name)
13
+ !/^#{uuid}{(.*)}$/.match(name).nil?
14
+ end
15
+
12
16
  def uuid
13
17
  @uuid ||= SecureRandom.uuid
14
18
  end
@@ -0,0 +1,14 @@
1
+ Feature: As a user of the API, I am able to get all of my tracks for a bundle.
2
+ Scenario: A user wants a list of their tracks for a bundle.
3
+ Given I am using the environment's API key
4
+ And I know the following urls referenced as:
5
+ | name | URL |
6
+ | media:dorothy | http://media.clarify.io/audio/books/dorothyandthewizardinoz_01_baum_64kb.mp3 |
7
+ | media:dorothy2 | http://media.clarify.io/audio/books/dorothyandthewizardinoz_01_baum_64kb.mp3 |
8
+ And I have a bundle named "Wizard of Oz"
9
+ And I add a track with the URL "[media:dorothy]" to the bundle
10
+ And I add a track with the URL "[media:dorothy2]" to the bundle
11
+ Then my bundle should include a track with the URL "[media:dorothy]"
12
+ And my bundle should include a track with the URL "[media:dorothy2]"
13
+ And my bundle has exactly "2" tracks
14
+
@@ -9,11 +9,14 @@ require 'clarify/configuration'
9
9
  require 'clarify/errors'
10
10
  require 'clarify/client'
11
11
  require 'clarify/response'
12
- require 'clarify/response_factory'
13
12
  require 'clarify/responses/bundle'
14
13
  require 'clarify/responses/collection'
14
+ require 'clarify/responses/insights'
15
15
  require 'clarify/responses/search_collection'
16
+ require 'clarify/responses/spoken_keywords_insight'
17
+ require 'clarify/responses/spoken_words_insight'
16
18
  require 'clarify/responses/no_body'
17
- require 'clarify/collection_iterator'
18
19
  require 'clarify/responses/tracks'
20
+ require 'clarify/response_factory'
21
+ require 'clarify/collection_iterator'
19
22
  require 'clarify/version'
@@ -20,15 +20,20 @@ module Clarify
20
20
  end
21
21
 
22
22
  def klass_for_class(name)
23
- klasses = {
23
+ klasses.fetch name
24
+ end
25
+
26
+ def klasses
27
+ {
28
+ 'Bundle' => Clarify::Responses::Bundle,
24
29
  'Collection' => Clarify::Responses::Collection,
30
+ 'Insights' => Clarify::Responses::Insights,
31
+ 'Ref' => Clarify::Response,
25
32
  'SearchCollection' => Clarify::Responses::SearchCollection,
26
- 'Bundle' => Clarify::Responses::Bundle,
27
- 'Tracks' => Clarify::Responses::Tracks,
28
- 'Ref' => Clarify::Response
33
+ 'SpokenWordsInsight' => Clarify::Responses::SpokenWordsInsight,
34
+ 'SpokenKeywordsInsight' => Clarify::Responses::SpokenKeywordsInsight,
35
+ 'Tracks' => Clarify::Responses::Tracks
29
36
  }
30
-
31
- klasses.fetch name
32
37
  end
33
38
  end
34
39
  end
@@ -0,0 +1,22 @@
1
+
2
+ require 'json'
3
+
4
+ module Clarify
5
+ module Responses
6
+ # An Insights class represents a list of links to insights which have been
7
+ # processed by the API. This class is used to locate insight documents.
8
+ #
9
+ # You can enumerate over the insight URLs and get names / urls of insights.
10
+ class Insights < Clarify::Response
11
+ include Enumerable
12
+
13
+ def each
14
+ items.each { |name, insight| yield name, insight['href'] }
15
+ end
16
+
17
+ def items
18
+ body['_links'].select { |name, _| name[0..7] == 'insight:' }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,9 @@
1
+
2
+ require 'json'
3
+
4
+ module Clarify
5
+ module Responses
6
+ class SpokenKeywordsInsight < Clarify::Response
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+
2
+ require 'json'
3
+
4
+ module Clarify
5
+ module Responses
6
+ class SpokenWordsInsight < Clarify::Response
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
 
2
2
  # Stub for the gemspec, tick the version on each release.
3
3
  module Clarify
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
@@ -0,0 +1,27 @@
1
+
2
+ describe Clarify::Responses::Insights do
3
+ let(:body) do
4
+ {
5
+ '_links' => {
6
+ 'self' => { 'href' => 'foo' },
7
+ 'parent' => { 'href' => 'bar' },
8
+ 'insight:foo' => { 'href' => 'baz' }
9
+ }
10
+ }
11
+ end
12
+
13
+ describe '#each' do
14
+ it 'iterates over each insight' do
15
+ insights = Clarify::Responses::Insights.new(body, nil)
16
+
17
+ expect { |b| insights.each(&b) }.to yield_control.once
18
+ expect(insights.to_h).to eq('insight:foo' => 'baz')
19
+ end
20
+ end
21
+
22
+ describe '#items' do
23
+ subject { Clarify::Responses::Insights.new(body, nil).items }
24
+
25
+ it { is_expected.to eq('insight:foo' => { 'href' => 'baz' }) }
26
+ end
27
+ end
@@ -78,7 +78,7 @@ require 'pp'
78
78
 
79
79
  clarify = Clarify::Client.new(api_key: 'docs-api-key')
80
80
 
81
- bundle_url = '/v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd'
81
+ bundle_url = '/v1/bundles/d6dcddf1066b4dd4bed78334e553e233'
82
82
  bundle = clarify.get(bundle_url)
83
83
  puts "Bundle Name: #{bundle.name}"
84
84
  pp bundle
@@ -89,6 +89,39 @@ Example output of bundle_fetch.rb:
89
89
  <output of bundle_fetch.rb>
90
90
  ```
91
91
 
92
+ ### Fetch a particular bundle's insight list
93
+
94
+ ```ruby
95
+ # bundle_insight_list.rb
96
+ require 'clarify'
97
+ require 'pp'
98
+
99
+ clarify = Clarify::Client.new(api_key: 'docs-api-key')
100
+
101
+ bundle_url = '/v1/bundles/d6dcddf1066b4dd4bed78334e553e233'
102
+ bundle = clarify.get(bundle_url)
103
+
104
+ bundle_insights_url = bundle.relation('clarify:insights')
105
+
106
+ puts "Insights for Bundle Name: #{bundle.name} (#{bundle_insights_url})"
107
+ insights = clarify.get(bundle_insights_url)
108
+ pp insights
109
+ puts '-----------'
110
+ insights.each do |insight, insight_url|
111
+ puts "Insight #{insight} (#{insight_url})"
112
+ insight = clarify.get(insight_url)
113
+ pp insight
114
+ puts ''
115
+ puts ''
116
+ puts ''
117
+ end
118
+ ```
119
+
120
+ Example output of bundle_insight_list.rb:
121
+ ```
122
+ <output of bundle_insight_list.rb>
123
+ ```
124
+
92
125
  ### Get a list of bundles and their names
93
126
 
94
127
  ```ruby
@@ -3,7 +3,7 @@ require 'pp'
3
3
 
4
4
  clarify = Clarify::Client.new(api_key: 'docs-api-key')
5
5
 
6
- bundle_url = '/v1/bundles/3fbca3fe3678495fb08fe939dbe4f1cd'
6
+ bundle_url = '/v1/bundles/d6dcddf1066b4dd4bed78334e553e233'
7
7
  bundle = clarify.get(bundle_url)
8
8
  puts "Bundle Name: #{bundle.name}"
9
9
  pp bundle
@@ -0,0 +1,22 @@
1
+ require 'clarify'
2
+ require 'pp'
3
+
4
+ clarify = Clarify::Client.new(api_key: 'docs-api-key')
5
+
6
+ bundle_url = '/v1/bundles/d6dcddf1066b4dd4bed78334e553e233'
7
+ bundle = clarify.get(bundle_url)
8
+
9
+ bundle_insights_url = bundle.relation('clarify:insights')
10
+
11
+ puts "Insights for Bundle Name: #{bundle.name} (#{bundle_insights_url})"
12
+ insights = clarify.get(bundle_insights_url)
13
+ pp insights
14
+ puts '-----------'
15
+ insights.each do |insight, insight_url|
16
+ puts "Insight #{insight} (#{insight_url})"
17
+ insight = clarify.get(insight_url)
18
+ pp insight
19
+ puts ''
20
+ puts ''
21
+ puts ''
22
+ end
@@ -26,6 +26,10 @@ configuration and http client setup.
26
26
 
27
27
  <%= example_with_output('bundle_fetch.rb') %>
28
28
 
29
+ ### Fetch a particular bundle's insight list
30
+
31
+ <%= example_with_output('bundle_insight_list.rb') %>
32
+
29
33
  ### Get a list of bundles and their names
30
34
 
31
35
  <%= example_with_output('bundles_list_fetch.rb') %>
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: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clarify Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-18 00:00:00.000000000 Z
11
+ date: 2015-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -131,6 +131,7 @@ files:
131
131
  - features/create-bundles.feature
132
132
  - features/delete-bundle.feature
133
133
  - features/identity-steps.feature
134
+ - features/insights.feature
134
135
  - features/list-bundles.feature
135
136
  - features/search-bundles.feature
136
137
  - features/step_definitions/curied_url_steps.rb
@@ -143,6 +144,7 @@ files:
143
144
  - features/support/lib/customer.rb
144
145
  - features/support/lib/exceptions.rb
145
146
  - features/support/lib/names.rb
147
+ - features/tracks.feature
146
148
  - lib/clarify.rb
147
149
  - lib/clarify/bundle_repository.rb
148
150
  - lib/clarify/client.rb
@@ -153,8 +155,11 @@ files:
153
155
  - lib/clarify/response_factory.rb
154
156
  - lib/clarify/responses/bundle.rb
155
157
  - lib/clarify/responses/collection.rb
158
+ - lib/clarify/responses/insights.rb
156
159
  - lib/clarify/responses/no_body.rb
157
160
  - lib/clarify/responses/search_collection.rb
161
+ - lib/clarify/responses/spoken_keywords_insight.rb
162
+ - lib/clarify/responses/spoken_words_insight.rb
158
163
  - lib/clarify/responses/tracks.rb
159
164
  - lib/clarify/rest_client.rb
160
165
  - lib/clarify/version.rb
@@ -167,6 +172,7 @@ files:
167
172
  - spec/clarify/response_spec.rb
168
173
  - spec/clarify/responses/bundle_spec.rb
169
174
  - spec/clarify/responses/collection_spec.rb
175
+ - spec/clarify/responses/insights_spec.rb
170
176
  - spec/clarify/responses/search_collection_spec.rb
171
177
  - spec/clarify/responses/tracks_spec.rb
172
178
  - spec/clarify/rest_client_spec.rb
@@ -174,6 +180,7 @@ files:
174
180
  - src_readme/README_no_output.md
175
181
  - src_readme/examples/bundle_create.rb
176
182
  - src_readme/examples/bundle_fetch.rb
183
+ - src_readme/examples/bundle_insight_list.rb
177
184
  - src_readme/examples/bundles_list_fetch.rb
178
185
  - src_readme/examples/bundles_paged_over.rb
179
186
  - src_readme/examples/bundles_search.rb
@@ -211,6 +218,7 @@ test_files:
211
218
  - features/create-bundles.feature
212
219
  - features/delete-bundle.feature
213
220
  - features/identity-steps.feature
221
+ - features/insights.feature
214
222
  - features/list-bundles.feature
215
223
  - features/search-bundles.feature
216
224
  - features/step_definitions/curied_url_steps.rb
@@ -223,6 +231,7 @@ test_files:
223
231
  - features/support/lib/customer.rb
224
232
  - features/support/lib/exceptions.rb
225
233
  - features/support/lib/names.rb
234
+ - features/tracks.feature
226
235
  - spec/clarify/bundle_repository_spec.rb
227
236
  - spec/clarify/client_spec.rb
228
237
  - spec/clarify/collection_iterator_spec.rb
@@ -232,6 +241,7 @@ test_files:
232
241
  - spec/clarify/response_spec.rb
233
242
  - spec/clarify/responses/bundle_spec.rb
234
243
  - spec/clarify/responses/collection_spec.rb
244
+ - spec/clarify/responses/insights_spec.rb
235
245
  - spec/clarify/responses/search_collection_spec.rb
236
246
  - spec/clarify/responses/tracks_spec.rb
237
247
  - spec/clarify/rest_client_spec.rb