moovatom 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +177 -48
- data/lib/moovatom.rb +34 -3
- data/lib/moovatom/version.rb +1 -1
- data/moovatom.gemspec +8 -8
- data/spec/delete_spec.rb +106 -0
- data/spec/fixtures/delete.json +4 -0
- data/spec/fixtures/delete.xml +4 -0
- data/spec/fixtures/media_search.json +90 -0
- data/spec/fixtures/media_search.xml +91 -0
- data/spec/search_spec.rb +105 -0
- metadata +43 -11
data/README.md
CHANGED
@@ -10,30 +10,33 @@ This gem provides access to the Moovatom online video processing and streaming s
|
|
10
10
|
2. Getting the status of a current encoding
|
11
11
|
3. Getting the details of a completed encoding
|
12
12
|
4. Canceling an encoding job
|
13
|
-
5.
|
13
|
+
5. Deleting an encoding job
|
14
|
+
6. Editing the attributes of your video player
|
15
|
+
7. Searching for videos you've already encoded
|
14
16
|
|
15
17
|
Installing the gem is done through the usual `gem install moovatom` command, or by adding the following line to your project's Gemfile:
|
16
18
|
|
17
19
|
```
|
18
|
-
gem "moovatom"
|
20
|
+
gem "moovatom"
|
19
21
|
```
|
20
22
|
|
21
|
-
The entire library is wrapped in a module named MoovAtom. Inside that module is a single class named MoovEngine. This class defines one constant,
|
23
|
+
The entire library is wrapped in a module named MoovAtom. Inside that module is a single class named MoovEngine. This class defines one constant, 13 instance variables and seven action methods that interact with Moovatom's RESTful API. The constant `API_URL` defines the URL to which the JSON or XML requests must be POST'd. The 13 instance variables are:
|
22
24
|
|
23
25
|
1. `@uuid`
|
24
26
|
2. `@username`
|
25
27
|
3. `@userkey`
|
26
28
|
4. `@content_type`
|
27
|
-
5. `@
|
28
|
-
6. `@
|
29
|
-
7. `@
|
30
|
-
8. `@
|
31
|
-
9. `@
|
32
|
-
10. `@
|
33
|
-
11. `@
|
34
|
-
12. `@
|
35
|
-
|
36
|
-
|
29
|
+
5. `@search_term`
|
30
|
+
6. `@title`
|
31
|
+
7. `@blurb`
|
32
|
+
8. `@sourcefile`
|
33
|
+
9. `@callbackurl`
|
34
|
+
10. `@format`
|
35
|
+
11. `@player`
|
36
|
+
12. `@action`
|
37
|
+
13. `@response`
|
38
|
+
|
39
|
+
The last 2 are readable only. `@response` will always contain the last response received from the Moovatom servers and `@action` will be set by each of the action methods explained below. `@player` is a struct object (technically an OpenStruct) that provides access to the player attributes for your video. The remaining ten instance variables are writable and correspond to the attributes of the video you want to control as well as your specific Moovatom account credentials. These attributes can be set in a number of ways depending upon the needs of your specific application.
|
37
40
|
|
38
41
|
Instantiating a new (empty) object to communicate with the MoovAtom API is as simple as:
|
39
42
|
|
@@ -61,15 +64,12 @@ me3 = MoovEngine.new
|
|
61
64
|
etc...
|
62
65
|
```
|
63
66
|
|
64
|
-
The object created in the code above isn't very useful though. A MoovEngine object created without any arguments will, however, receive a few default values. `@content_type` will be initialized with a value of 'video', `@format` will be set to 'json' and `@player` will be initialized as an empty struct if no argument or block parameters are provided. The remaining
|
67
|
+
The object created in the code above isn't very useful though. A MoovEngine object created without any arguments will, however, receive a few default values. `@content_type` will be initialized with a value of 'video', `@format` will be set to 'json' and `@player` will be initialized as an empty struct if no argument or block parameters are provided. The remaining ten instance variables need to be set with the credentials for your Moovatom account and the specifics about the video you wish to control. Aside from creating an empty object, as we did above, I've tried to include as much flexibility as I could when it comes to creating a new MoovEngine object. You can pass one or two hashes to the initialize method containing the values you wish to be set for either player or video attributes. The first hash will be used to setup video attributes and your Moovatom account credentials. The second hash is used to initialize an OpenStruct object of player attributes.
|
65
68
|
|
66
69
|
```ruby
|
67
|
-
You can pass literal hashes:
|
68
|
-
me = MoovAtom::MoovEngine.new({uuid: 'j9i8h7g6f5e4d3c2b1a'}, {height: '480'})
|
69
|
-
|
70
|
-
But it may be more readable to create the hashes first and then pass them:
|
71
70
|
vattrs = {uuid: 'j9i8h7g6f5e4d3c2b1a', username: 'USERNAME', etc...}
|
72
71
|
pattrs = {width: "720", height: "480", etc...}
|
72
|
+
|
73
73
|
me = MoovAtom::MoovEngine.new(vattrs, pattrs)
|
74
74
|
```
|
75
75
|
|
@@ -103,15 +103,17 @@ The gem has been designed to be highly customizable. You are free to create a si
|
|
103
103
|
|
104
104
|
# Action Methods
|
105
105
|
|
106
|
-
The MoovEngine class has
|
106
|
+
The MoovEngine class has seven methods that have been designed to interact directly with the RESTful API implemented by Moovatom's servers:
|
107
107
|
|
108
108
|
1. `get_details()` will return details about an encoded video
|
109
109
|
2. `get_status()` will return the status of a video (e.g. - whether or not encoding has completed)
|
110
110
|
3. `encode()` will start a new encoding job
|
111
111
|
4. `cancel()` will cancel an __unfinished__ encoding job
|
112
|
-
5. `
|
112
|
+
5. `delete()` will delete a __finished__ encoding job
|
113
|
+
6. `edit_player()` changes the attributes of your video's online player
|
114
|
+
7. `media_search()` returns videos based on the search terms you've provided
|
113
115
|
|
114
|
-
Each of these methods are almost identical. They all accept a hash/block argument syntax similar to the initialize method. The main difference is that the action methods will accept only one hash and a block. This allows you to easily reuse a MoovEngine object to request information about different videos. The
|
116
|
+
Each of these methods are almost identical. They all accept a hash/block argument syntax similar to the initialize method. The main difference is that the action methods will accept only one hash and a block. This allows you to easily reuse a MoovEngine object to request information about different videos. The seven action methods are able to be used and reused because they share a method that handles the heavy lifting when building and sending the request to Moovatom: `send_request()`. The `send_request()` method takes every instance variable (including player attributes) and creates a hash of the key/value attributes for your video. It then uses the `@format` and `@action` instance variables to build and POST the appropriate request to the Moovatom servers. If the response is successful it will parse it into either JSON or XML and store it in the `@response` instance variable. If the response is anything other than "200 OK" the raw Net::HTTPResponse object will be passed through and stored in `@response`. This allows you and your app to determine how best to handle the specific error response.
|
115
117
|
|
116
118
|
For more specific information about the Moovatom API please see the [documentation](http://moovatom.com/support/v2/api.html).
|
117
119
|
|
@@ -135,17 +137,21 @@ else
|
|
135
137
|
end
|
136
138
|
```
|
137
139
|
|
138
|
-
A details request will POST the __uuid__, __username__ and __userkey__ instance variables from your MoovEngine object
|
140
|
+
A details request will POST the __uuid__, __username__ and __userkey__ instance variables from your MoovEngine object. If successful `@response` will contain either a JSON or XML formatted object (depending on the value of `@format`) ready to be queried and used. The example above shows how you can pass a hash, a block or both to the method. The remaining six action methods all accept the same style of argument passing.
|
139
141
|
|
140
142
|
*Successful get_details() JSON Response:*
|
141
143
|
|
142
144
|
```
|
143
145
|
{
|
144
146
|
"uuid": "UUID",
|
147
|
+
"title": "Video Title",
|
148
|
+
"summary": "A short description about the media.",
|
149
|
+
"duration": "45.347",
|
145
150
|
"media_type": "video",
|
146
151
|
"embed_code": "EMBED CODE SMART SWITCHING FOR AUTOMATIC MOBILE AND WEB SUPPORT.",
|
147
152
|
"iframe_target": "http://www.moovatom.com/media/embed/ID",
|
148
|
-
"
|
153
|
+
"http_live_streaming_playlist": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
154
|
+
"original_download": "http://static.moovatom.com/PATH_TO_FILE",
|
149
155
|
"versions": [
|
150
156
|
{
|
151
157
|
"name": "mobile",
|
@@ -211,7 +217,6 @@ A details request will POST the __uuid__, __username__ and __userkey__ instance
|
|
211
217
|
}
|
212
218
|
```
|
213
219
|
|
214
|
-
|
215
220
|
## Status
|
216
221
|
|
217
222
|
The `get_status()` method allows you to query a video that has begun encoding to check its progress.
|
@@ -236,7 +241,7 @@ unless me.response["processing"]
|
|
236
241
|
end
|
237
242
|
```
|
238
243
|
|
239
|
-
A status request will POST the __uuid__, __username__ and __userkey__ instance variables from your MoovEngine object
|
244
|
+
A status request will POST the __uuid__, __username__ and __userkey__ instance variables from your MoovEngine object. The `@response` variable will contain either a success or error response:
|
240
245
|
|
241
246
|
*Status Success Response:*
|
242
247
|
|
@@ -276,7 +281,7 @@ end
|
|
276
281
|
me.encode
|
277
282
|
```
|
278
283
|
|
279
|
-
An encode request will POST the __username__, __userkey__, __content type__, __title__, __blurb__, __sourcefile__ and __callbackurl__ instance variables from your MoovEngine object
|
284
|
+
An encode request will POST the __username__, __userkey__, __content type__, __title__, __blurb__, __sourcefile__ and __callbackurl__ instance variables from your MoovEngine object. The body of the Moovatom response will contain the uuid assigned by Moovatom's servers to this new video as well as a message stating whether or not your job was started successfully:
|
280
285
|
|
281
286
|
*Encode Started Response:*
|
282
287
|
|
@@ -287,7 +292,7 @@ An encode request will POST the __username__, __userkey__, __content type__, __t
|
|
287
292
|
}
|
288
293
|
```
|
289
294
|
|
290
|
-
After a successful response the `@uuid` variable of your MoovEngine object will be set to the uuid assigned by Moovatom. The encode action implemented on Moovatom's servers differs slightly from the other
|
295
|
+
After a successful response the `@uuid` variable of your MoovEngine object will be set to the uuid assigned by Moovatom. The encode action implemented on Moovatom's servers differs slightly from the other six actions. Once the encoding is complete Moovatom's servers will send a response to the callback URL you set in the `@callbackurl` instance variable. Your app should define a controller (or url handler if it's a [Sinatra](http://www.sinatrarb.com/) app) that will process these callbacks to save/update the video's details in your database. The body of the callback sent by Moovatom looks exactly like the response from a `get_details()` request.
|
291
296
|
|
292
297
|
Additionally, the video you are uploading to Moovatom must be in a __publicly accessibly location__. Moovatom will attempt to transfer that video from the url you define in the `@sourcefile` instance variable. The ability to upload a video directly is planned for a future version of the API and this gem.
|
293
298
|
|
@@ -295,7 +300,7 @@ For more specific information about the Moovatom API please see the [documentati
|
|
295
300
|
|
296
301
|
## Cancel
|
297
302
|
|
298
|
-
If you decide, for whatever reason, that you no longer need or want a specific video on Moovatom you can cancel its encoding anytime __before it finishes__ using the `cancel()` method. A cancel request will POST the __uuid__, __username__ and __userkey__ instance variables from your MoovEngine object
|
303
|
+
If you decide, for whatever reason, that you no longer need or want a specific video on Moovatom you can cancel its encoding anytime __before it finishes__ using the `cancel()` method. A cancel request will POST the __uuid__, __username__ and __userkey__ instance variables from your MoovEngine object. The body of the Moovatom response will contain a message telling you whether or not you've successfully cancelled your video:
|
299
304
|
|
300
305
|
```ruby
|
301
306
|
me = MoovAtom::MoovEngine.new(uuid: 'j9i8h7g6f5e4d3c2b1a') do |me|
|
@@ -321,7 +326,33 @@ end
|
|
321
326
|
}
|
322
327
|
```
|
323
328
|
|
324
|
-
|
329
|
+
## Delete
|
330
|
+
|
331
|
+
If you decide, for whatever reason, that you no longer need or want a specific video on Moovatom you can delete its encoding anytime __after it finishes__ using the `delete()` method. A delete request will POST the __uuid__, __username__ and __userkey__ instance variables from your MoovEngine object. The body of the Moovatom response will contain a message telling you whether or not you've successfully deleted your video:
|
332
|
+
|
333
|
+
```ruby
|
334
|
+
me = MoovAtom::MoovEngine.new(uuid: 'j9i8h7g6f5e4d3c2b1a') do |me|
|
335
|
+
me.username = 'USERNAME'
|
336
|
+
me.userkey = 'a1b2c3d4e5f6g7h8i9j'
|
337
|
+
end
|
338
|
+
|
339
|
+
me.get_status
|
340
|
+
|
341
|
+
unless me.response['processing']
|
342
|
+
me.delete
|
343
|
+
else
|
344
|
+
"...gracefully fail or raise an exception here..."
|
345
|
+
end
|
346
|
+
```
|
347
|
+
|
348
|
+
*Example delete request response:*
|
349
|
+
|
350
|
+
```
|
351
|
+
{
|
352
|
+
"uuid": "UUID",
|
353
|
+
"message": "Your media was successfully deleted."
|
354
|
+
}
|
355
|
+
```
|
325
356
|
|
326
357
|
## Edit Player
|
327
358
|
|
@@ -347,11 +378,9 @@ button_over_color: #92B2BD
|
|
347
378
|
time_color: #01DAFF
|
348
379
|
```
|
349
380
|
|
350
|
-
The `edit_player()` method accepts the same hash/block argument syntax as the
|
381
|
+
The `edit_player()` method accepts the same hash/block argument syntax as the other six action methods, however, it takes the hash you pass and merges those attributes into any previous ones supplied in the second hash passed to the initialize method. Since the `@player` instance variable is just an OpenStruct object you can set any of the attributes above manually, in a hash or through a block.
|
351
382
|
|
352
383
|
```ruby
|
353
|
-
Variables can be set manually, with a hash or a block or both:
|
354
|
-
|
355
384
|
me.player.watermark = "http://www.example.com/path/to/watermark.png"
|
356
385
|
me.player.watermark_url = "http://www.example.com"
|
357
386
|
me.player.show_watermark = true
|
@@ -361,37 +390,137 @@ me.edit_player(width: "800", height: "500") do |me|
|
|
361
390
|
end
|
362
391
|
```
|
363
392
|
|
364
|
-
|
393
|
+
Since `@player` is implemented an an OpenStruct object it will create the attributes dynamically as you need them. This way only the attributes you wish to alter will be sent in your requests.
|
394
|
+
|
395
|
+
## Media Search
|
396
|
+
|
397
|
+
The `media_search()` action method allows you to query the videos you've uploaded to and encoded on Moovatom's servers using search terms entered into the `@search_terms` instance variable. A media_search request will POST the __username__, __userkey__ and __search_term__ instance variables from your MoovEngine object. The body of the Moovatom response will be similar to a details request:
|
365
398
|
|
366
399
|
```ruby
|
367
|
-
me = MoovAtom::MoovEngine.new
|
368
|
-
me.
|
369
|
-
me.
|
370
|
-
|
371
|
-
|
372
|
-
me.
|
373
|
-
me.player.background_color = "#000000"
|
374
|
-
me.player.duration_color = "#FFFFFF"
|
375
|
-
me.player.volume_color = "#000000"
|
376
|
-
me.player.button_color = "#889AA4"
|
377
|
-
me.player.time_color = "#01DAFF"
|
400
|
+
me = MoovAtom::MoovEngine.new(username: 'USERNAME') do |me|
|
401
|
+
me.userkey = 'a1b2c3d4e5f6g7h8i9j'
|
402
|
+
me.search_term = 'dolphin'
|
403
|
+
end
|
404
|
+
|
405
|
+
me.media_search
|
378
406
|
```
|
379
407
|
|
380
|
-
|
408
|
+
*Example media search request response:*
|
409
|
+
|
410
|
+
```
|
411
|
+
{
|
412
|
+
"result_count": "1",
|
413
|
+
"user": "USERNAME",
|
414
|
+
"results": [
|
415
|
+
{
|
416
|
+
"uuid": "UUID",
|
417
|
+
"title": "Dolphin Training",
|
418
|
+
"summary": "How to train your dolphin like a pro.",
|
419
|
+
"duration": "45.347",
|
420
|
+
"media_type": "video",
|
421
|
+
"embed_code": "EMBED CODE IFRAME FOR SMART SWITCHING",
|
422
|
+
"iframe_target": "http://www.moovatom.com/media/embed/ID",
|
423
|
+
"original_download": "http://www.moovatom.com/media/download/orig/UUID",
|
424
|
+
"versions": [
|
425
|
+
{
|
426
|
+
"name": "sample",
|
427
|
+
"type": "video/mp4",
|
428
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
429
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
430
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
431
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
432
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
433
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
434
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
435
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
436
|
+
},
|
437
|
+
{
|
438
|
+
"name": "mobile",
|
439
|
+
"type": "video/mp4",
|
440
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
441
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
442
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
443
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
444
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
445
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
446
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
447
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
448
|
+
},
|
449
|
+
{
|
450
|
+
"name": "mobile_large",
|
451
|
+
"type": "video/mp4",
|
452
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
453
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
454
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
455
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
456
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
457
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
458
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
459
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
460
|
+
},
|
461
|
+
{
|
462
|
+
"name": "small",
|
463
|
+
"type": "video/mp4",
|
464
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
465
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
466
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
467
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
468
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
469
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
470
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
471
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
472
|
+
},
|
473
|
+
{
|
474
|
+
"name": "medium",
|
475
|
+
"type": "video/mp4",
|
476
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
477
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
478
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
479
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
480
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
481
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
482
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
483
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
484
|
+
},
|
485
|
+
{
|
486
|
+
"name": "large",
|
487
|
+
"type": "video/mp4",
|
488
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
489
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
490
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
491
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
492
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
493
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
494
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
495
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
496
|
+
}
|
497
|
+
]
|
498
|
+
}
|
499
|
+
]
|
500
|
+
}
|
501
|
+
```
|
381
502
|
|
382
503
|
For more specific information about the Moovatom API please see the [documentation](http://moovatom.com/support/v2/api.html).
|
383
504
|
|
384
505
|
# Testing
|
385
506
|
|
386
|
-
Development of this gem was done on Ruby 1.9.2-p290
|
507
|
+
Development of this gem was done on Ruby 1.9.2-p290, and has been tested up to 1.9.3-p286. I haven't tried it on Ruby 1.8.7, but you shouldn't be using 1.8.7 anyways. :-)
|
387
508
|
|
388
509
|
This gem uses [Minitest](https://github.com/seattlerb/minitest), [Turn](https://github.com/TwP/turn) and [Fakeweb](https://github.com/chrisk/fakeweb) to implement specs for each of the above request methods, pretty colorized output and for mocking up a connection to the API.
|
389
510
|
|
390
|
-
The entire test suite is under the spec directory. The `spec_helper.rb` file contains the common testing code and gets required by each `*_spec.rb` file. There is one spec file (`init_spec.rb`) that tests the expected functionality related to initializing a new MoovEngine object. Each of the
|
511
|
+
The entire test suite is under the spec directory. The `spec_helper.rb` file contains the common testing code and gets required by each `*_spec.rb` file. There is one spec file (`init_spec.rb`) that tests the expected functionality related to initializing a new MoovEngine object. Each of the six action methods also has a single spec file dedicated to testing its expected functionality. All API requests are mocked through [Fakeweb](https://github.com/chrisk/fakeweb) and the responses come from the files in the fixtures directory.
|
391
512
|
|
392
513
|
The Rakefile's default task is 'minitest', which will load and execute all the `*_spec.rb` files in the spec directory. So a simple call to `rake` on the command line from the project's root directory will run the entire test suite.
|
393
514
|
|
394
|
-
This is the first Ruby project in which I started from a TDD/BDD design perspective. If anyone has a problem with the tests or sees areas where I can improve please [open an issue](https://github.com/humanshell/moovatom/issues) here so it can be discussed and everyone can learn a little. I really enjoyed creating tests that helped drive the design of the code. I'm sure there are *PLENTY* of areas in which I can improve.
|
515
|
+
This is the first Ruby project in which I started from a TDD/BDD design perspective. If anyone has a problem with the tests or sees areas where I can improve please [open an issue](https://github.com/humanshell/moovatom-ruby/issues) here so it can be discussed and everyone can learn a little. I really enjoyed creating tests that helped drive the design of the code. I'm sure there are *PLENTY* of areas in which I can improve.
|
516
|
+
|
517
|
+
# Changelog
|
518
|
+
|
519
|
+
## v0.3.0
|
520
|
+
|
521
|
+
* Added support for the delete action method
|
522
|
+
* Added support for the media_search action method
|
523
|
+
* Updated documentation
|
395
524
|
|
396
525
|
# Moovatom
|
397
526
|
|
data/lib/moovatom.rb
CHANGED
@@ -19,8 +19,8 @@ module MoovAtom
|
|
19
19
|
|
20
20
|
class MoovEngine
|
21
21
|
attr_reader :response, :action
|
22
|
-
attr_accessor :uuid, :username, :userkey, :content_type, :
|
23
|
-
:sourcefile, :callbackurl, :format, :player
|
22
|
+
attr_accessor :uuid, :username, :userkey, :content_type, :search_term, :title,
|
23
|
+
:blurb, :sourcefile, :callbackurl, :format, :player
|
24
24
|
|
25
25
|
##
|
26
26
|
# The initializer populates the class' instance variables to hold all the
|
@@ -138,7 +138,37 @@ module MoovAtom
|
|
138
138
|
@player.instance_variable_get("@table").merge! attrs
|
139
139
|
yield self if block_given?
|
140
140
|
send_request
|
141
|
-
end #--
|
141
|
+
end #-- edit_player method
|
142
|
+
|
143
|
+
##
|
144
|
+
# The delete() method allows you to delete a video that's finished encoding
|
145
|
+
# on the Moovatom servers. It is almost identical to the get_details() and
|
146
|
+
# get_status() methods. You can pass the same type/combination of arguments
|
147
|
+
# and it also sets the @action instance variable to 'delete' for you.
|
148
|
+
#
|
149
|
+
# See README for specific examples
|
150
|
+
|
151
|
+
def delete(attrs={}, &block)
|
152
|
+
@action = 'delete'
|
153
|
+
attrs.each {|k,v| instance_variable_set "@#{k}", v}
|
154
|
+
yield self if block_given?
|
155
|
+
send_request
|
156
|
+
end #-- delete method
|
157
|
+
|
158
|
+
##
|
159
|
+
# The media_search() method allows you to search for a video on the
|
160
|
+
# Moovatom servers. It is almost identical to the get_details() and
|
161
|
+
# get_status() methods. You can pass the same type/combination of arguments
|
162
|
+
# and it also sets the @action instance variable to 'media_search' for you.
|
163
|
+
#
|
164
|
+
# See README for specific examples
|
165
|
+
|
166
|
+
def media_search(attrs={}, &block)
|
167
|
+
@action = 'media_search'
|
168
|
+
attrs.each {|k,v| instance_variable_set "@#{k}", v}
|
169
|
+
yield self if block_given?
|
170
|
+
send_request
|
171
|
+
end #-- media_search method
|
142
172
|
|
143
173
|
private
|
144
174
|
|
@@ -216,6 +246,7 @@ module MoovAtom
|
|
216
246
|
puts "Blurb: #{@blurb}"
|
217
247
|
puts "Source File: #{@sourcefile}"
|
218
248
|
puts "Callback URL: #{@callbackurl}"
|
249
|
+
puts "Search Term: #{@search_term}"
|
219
250
|
puts "Action: #{@action}"
|
220
251
|
puts "Format: #{@format}"
|
221
252
|
puts "Response: #{@response.class}"
|
data/lib/moovatom/version.rb
CHANGED
data/moovatom.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
3
|
-
require
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'moovatom/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
|
7
7
|
#-- author info
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
8
|
+
s.authors = ['Dominic Giglio']
|
9
|
+
s.email = ['humanshell@gmail.com']
|
10
|
+
s.homepage = 'http://moovatom.com'
|
11
11
|
|
12
12
|
#-- gem info
|
13
|
-
s.name =
|
13
|
+
s.name = 'moovatom'
|
14
14
|
s.version = MoovAtom::VERSION
|
15
15
|
s.summary = %q{Access MoovAtom API}
|
16
16
|
s.description = %q{This gem defines methods for controlling your videos on MoovAtom using the MoovEngine API.}
|
17
|
-
s.rubyforge_project =
|
17
|
+
s.rubyforge_project = 'moovatom'
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
-
s.require_paths = [
|
21
|
+
s.require_paths = ['lib']
|
22
22
|
|
23
23
|
#-- release dependencies
|
24
24
|
s.add_dependency('json')
|
data/spec/delete_spec.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
# this file contains all the tests associated with deleting
|
4
|
+
# a video on Moovatom's servers.
|
5
|
+
|
6
|
+
describe MoovAtom::MoovEngine, "Delete Request Unit Tests" do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@vars1 = {
|
10
|
+
uuid: '123',
|
11
|
+
username: 'jsmith',
|
12
|
+
userkey: '987654321',
|
13
|
+
title: 'My Greatest Movie',
|
14
|
+
blurb: 'The greatest movie ever made',
|
15
|
+
sourcefile: 'http://example.com/greatest.mp4',
|
16
|
+
callbackurl: 'http://example.com/callback'
|
17
|
+
}
|
18
|
+
|
19
|
+
@vars2 = {
|
20
|
+
uuid: '321',
|
21
|
+
username: 'asmith',
|
22
|
+
userkey: '123456789',
|
23
|
+
title: 'My Best Movie',
|
24
|
+
blurb: 'The bestest movie ever made',
|
25
|
+
sourcefile: 'http://example.com/best.mp4',
|
26
|
+
callbackurl: 'http://example.com/callback_url'
|
27
|
+
}
|
28
|
+
|
29
|
+
# mock up the connection to moovatom.com
|
30
|
+
@me = MoovAtom::MoovEngine.new @vars1
|
31
|
+
@url = "#{MoovAtom::API_URL}/delete"
|
32
|
+
json = File.join(File.dirname(__FILE__), 'fixtures', 'delete.json')
|
33
|
+
FakeWeb.register_uri(:post, "#{@url}.json", :body => json)
|
34
|
+
xml = File.join(File.dirname(__FILE__), 'fixtures', 'delete.xml')
|
35
|
+
FakeWeb.register_uri(:post, "#{@url}.xml", :body => xml)
|
36
|
+
end
|
37
|
+
|
38
|
+
after do
|
39
|
+
# clean up the registry after each test
|
40
|
+
FakeWeb.clean_registry
|
41
|
+
|
42
|
+
# enable all real requests after testing
|
43
|
+
FakeWeb.allow_net_connect = true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "accepts a hash to update attributes" do
|
47
|
+
|
48
|
+
# create a MoovEngine object using the values from the @vars1 hash
|
49
|
+
me = MoovAtom::MoovEngine.new @vars1
|
50
|
+
|
51
|
+
# call delete() passing the hash of values from @vars2
|
52
|
+
me.delete @vars2
|
53
|
+
|
54
|
+
# the instance 'me' should now contain the values from the @vars2 hash
|
55
|
+
@vars2.each {|k,v| me.instance_variable_get("@#{k}").must_equal v}
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
it "accepts a block to update attributes" do
|
60
|
+
|
61
|
+
# create a new MoovEngine object with a block using the values from @vars1
|
62
|
+
me = MoovAtom::MoovEngine.new do |me|
|
63
|
+
@vars1.each {|k,v| me.instance_variable_set "@#{k}", v}
|
64
|
+
end
|
65
|
+
|
66
|
+
# call delete() passing a block that sets instance variables to the
|
67
|
+
# values in the @vars2 hash
|
68
|
+
me.delete do |me|
|
69
|
+
@vars2.each {|k,v| me.instance_variable_set "@#{k}", v}
|
70
|
+
end
|
71
|
+
|
72
|
+
# the instance 'me' should now contain the values from the @vars2 hash
|
73
|
+
@vars2.each {|k,v| me.instance_variable_get("@#{k}").must_equal v}
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
it "sets the action attribute to delete" do
|
78
|
+
|
79
|
+
# create a new MoovEngine object
|
80
|
+
me = MoovAtom::MoovEngine.new @vars1
|
81
|
+
|
82
|
+
# call the delete() method
|
83
|
+
me.delete
|
84
|
+
|
85
|
+
# after calling delete() @action should be 'delete'
|
86
|
+
me.action.must_equal 'delete'
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
# tests for the api call to delete an existing video
|
91
|
+
describe "API Requests" do
|
92
|
+
|
93
|
+
it "deletes a video using json" do
|
94
|
+
@me.delete
|
95
|
+
@me.response["uuid"].must_equal @vars1[:uuid]
|
96
|
+
end
|
97
|
+
|
98
|
+
it "deletes a video using xml" do
|
99
|
+
@me.format = 'xml'
|
100
|
+
@me.delete
|
101
|
+
@me.response.root.elements["uuid"].text.must_equal @vars1[:uuid]
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
{
|
2
|
+
"result_count": "1",
|
3
|
+
"user": "USERNAME",
|
4
|
+
"results": [
|
5
|
+
{
|
6
|
+
"uuid": "123",
|
7
|
+
"title": "Video Title",
|
8
|
+
"summary": "A short description about the media.",
|
9
|
+
"duration": "45.347",
|
10
|
+
"media_type": "video",
|
11
|
+
"embed_code": "EMBED CODE IFRAME FOR SMART SWITCHING",
|
12
|
+
"iframe_target": "http://www.moovatom.com/media/embed/ID",
|
13
|
+
"original_download": "http://www.moovatom.com/media/download/orig/UUID",
|
14
|
+
"versions": [
|
15
|
+
{
|
16
|
+
"name": "sample",
|
17
|
+
"type": "video/mp4",
|
18
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
19
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
20
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
21
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
22
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
23
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
24
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
25
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"name": "mobile",
|
29
|
+
"type": "video/mp4",
|
30
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
31
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
32
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
33
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
34
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
35
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
36
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
37
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "mobile_large",
|
41
|
+
"type": "video/mp4",
|
42
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
43
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
44
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
45
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
46
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
47
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
48
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
49
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"name": "small",
|
53
|
+
"type": "video/mp4",
|
54
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
55
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
56
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
57
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
58
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
59
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
60
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
61
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"name": "medium",
|
65
|
+
"type": "video/mp4",
|
66
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
67
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
68
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
69
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
70
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
71
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
72
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
73
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"name": "large",
|
77
|
+
"type": "video/mp4",
|
78
|
+
"holdframe_download": "http://www.moovatom.com/PATH_TO_FILE",
|
79
|
+
"thumbnail_download": "http://www.moovatom.com/PATH_TO_FILE",
|
80
|
+
"holdframe_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
81
|
+
"thumbnail_serve": "http://static.moovatom.com/PATH_TO_FILE",
|
82
|
+
"rtmp_stream": "rtmp://media.moovatom.com/PATH_TO_FILE",
|
83
|
+
"http_stream": "http://media.moovatom.com:1935/PATH_TO_FILE",
|
84
|
+
"rtsp_stream": "rtsp://media.moovatom.com:1935/PATH_TO_FILE",
|
85
|
+
"download": "http://www.moovatom.com/PATH_TO_FILE"
|
86
|
+
}
|
87
|
+
]
|
88
|
+
}
|
89
|
+
]
|
90
|
+
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<response>
|
3
|
+
<result_count>1</result_count>
|
4
|
+
<user>USERNAME</user>
|
5
|
+
<results>
|
6
|
+
<result>
|
7
|
+
<uuid>123</uuid>
|
8
|
+
<title>Video Title</title>
|
9
|
+
<summary>A short description about the media.</summary>
|
10
|
+
<duration>45.347</duration>
|
11
|
+
<media_type>video</media_type>
|
12
|
+
<embed_code>EMBED CODE IFRAME FOR SMART SWITCHING</embed_code>
|
13
|
+
<iframe_target>http://www.moovatom.com/media/embed/ID</iframe_target>
|
14
|
+
<original_download>http://PATH_TO_FILE</original_download>
|
15
|
+
<versions>
|
16
|
+
<version>
|
17
|
+
<name>sample</name>
|
18
|
+
<type>video/mp4</type>
|
19
|
+
<holdframe_download>http://PATH_TO_FILE</holdframe_download>
|
20
|
+
<thumbnail_download>http://PATH_TO_FILE</thumbnail_download>
|
21
|
+
<holdframe_serve>http://PATH_TO_FILE</holdframe_serve>
|
22
|
+
<thumbnail_serve>http://PATH_TO_FILE</thumbnail_serve>
|
23
|
+
<rtmp_stream>rtmp://PATH_TO_FILE</rtmp_stream>
|
24
|
+
<http_stream>http://PATH_TO_FILE</http_stream>
|
25
|
+
<rtsp_stream>rtsp://PATH_TO_FILE</rtsp_stream>
|
26
|
+
<download>http://PATH_TO_FILE</download>
|
27
|
+
</version>
|
28
|
+
<version>
|
29
|
+
<name>mobile</name>
|
30
|
+
<type>video/mp4</type>
|
31
|
+
<holdframe_download>http://PATH_TO_FILE</holdframe_download>
|
32
|
+
<thumbnail_download>http://PATH_TO_FILE</thumbnail_download>
|
33
|
+
<holdframe_serve>http://PATH_TO_FILE</holdframe_serve>
|
34
|
+
<thumbnail_serve>http://PATH_TO_FILE</thumbnail_serve>
|
35
|
+
<rtmp_stream>rtmp://PATH_TO_FILE</rtmp_stream>
|
36
|
+
<http_stream>http://PATH_TO_FILE</http_stream>
|
37
|
+
<rtsp_stream>rtsp://PATH_TO_FILE</rtsp_stream>
|
38
|
+
<download>http://PATH_TO_FILE</download>
|
39
|
+
</version>
|
40
|
+
<version>
|
41
|
+
<name>mobile_large</name>
|
42
|
+
<type>video/mp4</type>
|
43
|
+
<holdframe_download>http://PATH_TO_FILE</holdframe_download>
|
44
|
+
<thumbnail_download>http://PATH_TO_FILE</thumbnail_download>
|
45
|
+
<holdframe_serve>http://PATH_TO_FILE</holdframe_serve>
|
46
|
+
<thumbnail_serve>http://PATH_TO_FILE</thumbnail_serve>
|
47
|
+
<rtmp_stream>rtmp://PATH_TO_FILE</rtmp_stream>
|
48
|
+
<http_stream>http://PATH_TO_FILE</http_stream>
|
49
|
+
<rtsp_stream>rtsp://PATH_TO_FILE</rtsp_stream>
|
50
|
+
<download>http://PATH_TO_FILE</download>
|
51
|
+
</version>
|
52
|
+
<version>
|
53
|
+
<name>small</name>
|
54
|
+
<type>video/mp4</type>
|
55
|
+
<holdframe_download>http://PATH_TO_FILE</holdframe_download>
|
56
|
+
<thumbnail_download>http://PATH_TO_FILE</thumbnail_download>
|
57
|
+
<holdframe_serve>http://PATH_TO_FILE</holdframe_serve>
|
58
|
+
<thumbnail_serve>http://PATH_TO_FILE</thumbnail_serve>
|
59
|
+
<rtmp_stream>rtmp://PATH_TO_FILE</rtmp_stream>
|
60
|
+
<http_stream>http://PATH_TO_FILE</http_stream>
|
61
|
+
<rtsp_stream>rtsp://PATH_TO_FILE</rtsp_stream>
|
62
|
+
<download>http://PATH_TO_FILE</download>
|
63
|
+
</version>
|
64
|
+
<version>
|
65
|
+
<name>medium</name>
|
66
|
+
<type>video/mp4</type>
|
67
|
+
<holdframe_download>http://PATH_TO_FILE</holdframe_download>
|
68
|
+
<thumbnail_download>http://PATH_TO_FILE</thumbnail_download>
|
69
|
+
<holdframe_serve>http://PATH_TO_FILE</holdframe_serve>
|
70
|
+
<thumbnail_serve>http://PATH_TO_FILE</thumbnail_serve>
|
71
|
+
<rtmp_stream>rtmp://PATH_TO_FILE</rtmp_stream>
|
72
|
+
<http_stream>http://PATH_TO_FILE</http_stream>
|
73
|
+
<rtsp_stream>rtsp://PATH_TO_FILE</rtsp_stream>
|
74
|
+
<download>http://PATH_TO_FILE</download>
|
75
|
+
</version>
|
76
|
+
<version>
|
77
|
+
<name>large</name>
|
78
|
+
<type>video/mp4</type>
|
79
|
+
<holdframe_download>http://PATH_TO_FILE</holdframe_download>
|
80
|
+
<thumbnail_download>http://PATH_TO_FILE</thumbnail_download>
|
81
|
+
<holdframe_serve>http://PATH_TO_FILE</holdframe_serve>
|
82
|
+
<thumbnail_serve>http://PATH_TO_FILE</thumbnail_serve>
|
83
|
+
<rtmp_stream>rtmp://PATH_TO_FILE</rtmp_stream>
|
84
|
+
<http_stream>http://PATH_TO_FILE</http_stream>
|
85
|
+
<rtsp_stream>rtsp://PATH_TO_FILE</rtsp_stream>
|
86
|
+
<download>http://PATH_TO_FILE</download>
|
87
|
+
</version>
|
88
|
+
</versions>
|
89
|
+
</result>
|
90
|
+
</results>
|
91
|
+
</response>
|
data/spec/search_spec.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
# this file contains all the tests associated with searching for
|
4
|
+
# videos on Moovatom's servers.
|
5
|
+
|
6
|
+
describe MoovAtom::MoovEngine, "Media Search Request Unit Tests" do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@vars1 = {
|
10
|
+
uuid: '123',
|
11
|
+
username: 'jsmith',
|
12
|
+
userkey: '987654321',
|
13
|
+
search_term: 'Example Query',
|
14
|
+
title: 'My Greatest Movie',
|
15
|
+
blurb: 'The greatest movie ever made',
|
16
|
+
sourcefile: 'http://example.com/greatest.mp4',
|
17
|
+
callbackurl: 'http://example.com/callback'
|
18
|
+
}
|
19
|
+
|
20
|
+
@vars2 = {
|
21
|
+
uuid: '321',
|
22
|
+
username: 'asmith',
|
23
|
+
userkey: '123456789',
|
24
|
+
search_term: 'Example Query',
|
25
|
+
title: 'My Best Movie',
|
26
|
+
blurb: 'The bestest movie ever made',
|
27
|
+
sourcefile: 'http://example.com/best.mp4',
|
28
|
+
callbackurl: 'http://example.com/callback_url'
|
29
|
+
}
|
30
|
+
|
31
|
+
# mock up the connection to moovatom.com
|
32
|
+
@me = MoovAtom::MoovEngine.new @vars1
|
33
|
+
@url = "#{MoovAtom::API_URL}/media_search"
|
34
|
+
json = File.join(File.dirname(__FILE__), 'fixtures', 'media_search.json')
|
35
|
+
FakeWeb.register_uri(:post, "#{@url}.json", :body => json)
|
36
|
+
xml = File.join(File.dirname(__FILE__), 'fixtures', 'media_search.xml')
|
37
|
+
FakeWeb.register_uri(:post, "#{@url}.xml", :body => xml)
|
38
|
+
end
|
39
|
+
|
40
|
+
after do
|
41
|
+
# clean up the registry after each test
|
42
|
+
FakeWeb.clean_registry
|
43
|
+
|
44
|
+
# enable all real requests after testing
|
45
|
+
FakeWeb.allow_net_connect = true
|
46
|
+
end
|
47
|
+
|
48
|
+
it "accepts a hash to update attributes" do
|
49
|
+
|
50
|
+
# create a MoovEngine object using the values from the @vars1 hash
|
51
|
+
me = MoovAtom::MoovEngine.new @vars1
|
52
|
+
|
53
|
+
# call get_details() passing the hash of values from @vars2
|
54
|
+
me.media_search @vars2
|
55
|
+
|
56
|
+
# the instance 'me' should now contain the values from the @vars2 hash
|
57
|
+
@vars2.each {|k,v| me.instance_variable_get("@#{k}").must_equal v}
|
58
|
+
end
|
59
|
+
|
60
|
+
it "accepts a block to update attributes" do
|
61
|
+
|
62
|
+
# create a new MoovEngine object with a block using the values from @vars1
|
63
|
+
me = MoovAtom::MoovEngine.new do |me|
|
64
|
+
@vars1.each {|k,v| me.instance_variable_set "@#{k}", v}
|
65
|
+
end
|
66
|
+
|
67
|
+
# call get_details() passing a block that sets instance variables to the
|
68
|
+
# values in the @vars2 hash
|
69
|
+
me.media_search do |me|
|
70
|
+
@vars2.each {|k,v| me.instance_variable_set "@#{k}", v}
|
71
|
+
end
|
72
|
+
|
73
|
+
# the instance 'me' should now contain the values from the @vars2 hash
|
74
|
+
@vars2.each {|k,v| me.instance_variable_get("@#{k}").must_equal v}
|
75
|
+
end
|
76
|
+
|
77
|
+
it "sets the action attribute to media_search" do
|
78
|
+
|
79
|
+
# create a new MoovEngine object
|
80
|
+
me = MoovAtom::MoovEngine.new @vars1
|
81
|
+
|
82
|
+
# call the get_details() method
|
83
|
+
me.media_search
|
84
|
+
|
85
|
+
# after calling get_details() @action should be 'detail'
|
86
|
+
me.action.must_equal 'media_search'
|
87
|
+
end
|
88
|
+
|
89
|
+
# tests for the api call to get details about an existing video
|
90
|
+
describe "API Requests" do
|
91
|
+
|
92
|
+
it "searches for a video using json" do
|
93
|
+
@me.media_search
|
94
|
+
@me.response["user"].must_equal "USERNAME"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "searches for a video using xml" do
|
98
|
+
@me.format = 'xml'
|
99
|
+
@me.media_search
|
100
|
+
@me.response.root.elements["user"].text.must_equal "USERNAME"
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moovatom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: minitest
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: turn
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: fakeweb
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,7 +69,12 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
description: This gem defines methods for controlling your videos on MoovAtom using
|
59
79
|
the MoovEngine API.
|
60
80
|
email:
|
@@ -73,14 +93,19 @@ files:
|
|
73
93
|
- lib/moovatom/version.rb
|
74
94
|
- moovatom.gemspec
|
75
95
|
- spec/cancel_spec.rb
|
96
|
+
- spec/delete_spec.rb
|
76
97
|
- spec/details_spec.rb
|
77
98
|
- spec/encode_spec.rb
|
78
99
|
- spec/fixtures/cancel.json
|
79
100
|
- spec/fixtures/cancel.xml
|
101
|
+
- spec/fixtures/delete.json
|
102
|
+
- spec/fixtures/delete.xml
|
80
103
|
- spec/fixtures/detail.json
|
81
104
|
- spec/fixtures/detail.xml
|
82
105
|
- spec/fixtures/encode.json
|
83
106
|
- spec/fixtures/encode.xml
|
107
|
+
- spec/fixtures/media_search.json
|
108
|
+
- spec/fixtures/media_search.xml
|
84
109
|
- spec/fixtures/player_error.json
|
85
110
|
- spec/fixtures/player_error.xml
|
86
111
|
- spec/fixtures/player_success.json
|
@@ -91,6 +116,7 @@ files:
|
|
91
116
|
- spec/fixtures/status_success.xml
|
92
117
|
- spec/init_spec.rb
|
93
118
|
- spec/player_spec.rb
|
119
|
+
- spec/search_spec.rb
|
94
120
|
- spec/spec_helper.rb
|
95
121
|
- spec/status_spec.rb
|
96
122
|
homepage: http://moovatom.com
|
@@ -113,20 +139,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
139
|
version: '0'
|
114
140
|
requirements: []
|
115
141
|
rubyforge_project: moovatom
|
116
|
-
rubygems_version: 1.8.
|
142
|
+
rubygems_version: 1.8.23
|
117
143
|
signing_key:
|
118
144
|
specification_version: 3
|
119
145
|
summary: Access MoovAtom API
|
120
146
|
test_files:
|
121
147
|
- spec/cancel_spec.rb
|
148
|
+
- spec/delete_spec.rb
|
122
149
|
- spec/details_spec.rb
|
123
150
|
- spec/encode_spec.rb
|
124
151
|
- spec/fixtures/cancel.json
|
125
152
|
- spec/fixtures/cancel.xml
|
153
|
+
- spec/fixtures/delete.json
|
154
|
+
- spec/fixtures/delete.xml
|
126
155
|
- spec/fixtures/detail.json
|
127
156
|
- spec/fixtures/detail.xml
|
128
157
|
- spec/fixtures/encode.json
|
129
158
|
- spec/fixtures/encode.xml
|
159
|
+
- spec/fixtures/media_search.json
|
160
|
+
- spec/fixtures/media_search.xml
|
130
161
|
- spec/fixtures/player_error.json
|
131
162
|
- spec/fixtures/player_error.xml
|
132
163
|
- spec/fixtures/player_success.json
|
@@ -137,5 +168,6 @@ test_files:
|
|
137
168
|
- spec/fixtures/status_success.xml
|
138
169
|
- spec/init_spec.rb
|
139
170
|
- spec/player_spec.rb
|
171
|
+
- spec/search_spec.rb
|
140
172
|
- spec/spec_helper.rb
|
141
173
|
- spec/status_spec.rb
|