limelight_video 0.0.1 → 0.0.2
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.
- data/README.md +5 -1
- data/lib/limelight_video.rb +11 -4
- data/limelight_video.gemspec +1 -1
- data/test/fixtures/cassettes/limelight_upload_io.yml +48 -0
- data/test/integration/limelight_test.rb +14 -3
- data/test/unit/limelight_test.rb +1 -1
- metadata +3 -1
data/README.md
CHANGED
@@ -11,5 +11,9 @@ limelight = Limelight.new(
|
|
11
11
|
secret: 'your secret key',
|
12
12
|
)
|
13
13
|
|
14
|
-
|
14
|
+
# Upload a file
|
15
|
+
limelight.upload('~/Downloads/sample.mp4', title: 'My cool file')
|
16
|
+
|
17
|
+
# Uploads a stream, the filename is needed for the mime type in the upload
|
18
|
+
limelight.upload(io_stream, title: 'My cool file', filename: 'dancing_cat.mp4')
|
15
19
|
```
|
data/lib/limelight_video.rb
CHANGED
@@ -20,13 +20,20 @@ class Limelight
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def upload(
|
24
|
-
|
23
|
+
def upload(filename_or_io, attributes = {})
|
24
|
+
if filename_or_io.is_a?(String) && File.exists?(filename_or_io)
|
25
|
+
filename = filename_or_io
|
26
|
+
elsif filename_or_io.respond_to?(:read)
|
27
|
+
filename = attributes.fetch(:filename)
|
28
|
+
raise KeyError.new("filename") if !filename
|
29
|
+
else
|
30
|
+
raise Errno::ENOENT
|
31
|
+
end
|
25
32
|
|
26
33
|
url = generate_signature('post', @base_url)
|
27
34
|
mime = MIME::Types.type_for(filename)
|
28
|
-
file = Faraday::UploadIO.new(
|
29
|
-
response = @client.post(url, title: title, media_file: file)
|
35
|
+
file = Faraday::UploadIO.new(filename_or_io, mime)
|
36
|
+
response = @client.post(url, title: attributes.fetch(:title, 'Unnamed'), media_file: file)
|
30
37
|
JSON.parse response.body
|
31
38
|
end
|
32
39
|
|
data/limelight_video.gemspec
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://api.videoplatform.limelight.com/rest/organizations/889457f434f14057bdcc9a1f39bd9614/media?access_key=5CIILY3Sw1P%2FqF2VHikRPXMEPdA%3D&expires=1340912257&signature=SWctZD8YciiKqryHLDgZ5uaWpLdyBr%2Bxg0I08H%2BBGUg%3D
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ""
|
9
|
+
headers:
|
10
|
+
content-type:
|
11
|
+
- multipart/form-data;boundary=-----------RubyMultipartPost
|
12
|
+
content-length:
|
13
|
+
- "246148"
|
14
|
+
accept:
|
15
|
+
- "*/*"
|
16
|
+
user-agent:
|
17
|
+
- Ruby
|
18
|
+
connection:
|
19
|
+
- close
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 201
|
23
|
+
message: Created
|
24
|
+
headers:
|
25
|
+
server:
|
26
|
+
- nginx/0.8.54
|
27
|
+
date:
|
28
|
+
- Thu, 28 Jun 2012 19:32:49 GMT
|
29
|
+
content-type:
|
30
|
+
- application/json; charset=utf-8
|
31
|
+
connection:
|
32
|
+
- close
|
33
|
+
cache-control:
|
34
|
+
- no-cache
|
35
|
+
status:
|
36
|
+
- 201 Created
|
37
|
+
x-runtime:
|
38
|
+
- 1569ms
|
39
|
+
content-length:
|
40
|
+
- "747"
|
41
|
+
via:
|
42
|
+
- 1.0 vps-099.iad.llnw.net
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: "{\"publish_date\": null, \"category\": null, \"description\": null, \"sched_end_date\": null, \"tags\": [], \"title\": \"test\", \"media_id\": \"f936e4cc59194782a708d0b3e70ab879\", \"media_type\": \"Video\", \"original_filename\": \"sample-mp4\", \"sched_start_date\": null, \"restrictionrule_id\": null, \"create_date\": 1340911968, \"state\": \"New\", \"total_storage_in_bytes\": 0, \"thumbnails\": [{\"url\": \"http://img.delvenetworks.com/0000000000000000000000/0000000000000000000000/defaultVideoPreviewImage.swf\", \"width\": \"\", \"height\": \"\"}, {\"url\": \"http://img.delvenetworks.com/0000000000000000000000/0000000000000000000000/defaultVideoPreviewImage.swf\", \"width\": \"\", \"height\": \"\"}], \"ref_id\": null, \"update_date\": 1340911968, \"custom_property\": null, \"duration_in_milliseconds\": 0}"
|
46
|
+
http_version: "1.1"
|
47
|
+
recorded_at: Thu, 28 Jun 2012 19:32:49 GMT
|
48
|
+
recorded_with: VCR 2.1.1
|
@@ -2,14 +2,25 @@ require 'test_helper'
|
|
2
2
|
require 'test_fixtures'
|
3
3
|
|
4
4
|
describe Limelight do
|
5
|
-
|
6
|
-
limelight = Limelight.new(
|
5
|
+
before do
|
6
|
+
@limelight = Limelight.new(
|
7
7
|
organization: '889457f434f14057bdcc9a1f39bd9614',
|
8
8
|
access_key: '5CIILY3Sw1P/qF2VHikRPXMEPdA=',
|
9
9
|
secret: 'Frpgy2kz/xDAnrO3IBAWDRkNJ3s='
|
10
10
|
)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should upload a video' do
|
11
14
|
VCR.use_cassette("limelight upload media", match_requests_on: [:host, :path]) do
|
12
|
-
video = limelight.upload('test'
|
15
|
+
video = @limelight.upload(sample_mp4_file, title: 'test')
|
16
|
+
video["media_id"].size.must_equal 32
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should upload an io stream' do
|
21
|
+
VCR.use_cassette("limelight upload io", match_requests_on: [:host, :path]) do
|
22
|
+
io = File.open(sample_mp4_file)
|
23
|
+
video = @limelight.upload(io, title: 'test', filename: sample_mp4_file)
|
13
24
|
video["media_id"].size.must_equal 32
|
14
25
|
end
|
15
26
|
end
|
data/test/unit/limelight_test.rb
CHANGED
@@ -11,7 +11,7 @@ describe Limelight do
|
|
11
11
|
it 'should validate tokens for authorized actions' do
|
12
12
|
limelight = Limelight.new(organization: 'something', access_key: 'another')
|
13
13
|
assert_raises KeyError do
|
14
|
-
limelight.upload('test'
|
14
|
+
limelight.upload(sample_mp4_file, title: 'test')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: limelight_video
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- Rakefile
|
105
105
|
- lib/limelight_video.rb
|
106
106
|
- limelight_video.gemspec
|
107
|
+
- test/fixtures/cassettes/limelight_upload_io.yml
|
107
108
|
- test/fixtures/cassettes/limelight_upload_media.yml
|
108
109
|
- test/fixtures/files/sample.mp4
|
109
110
|
- test/integration/limelight_test.rb
|
@@ -135,6 +136,7 @@ signing_key:
|
|
135
136
|
specification_version: 3
|
136
137
|
summary: Limelight video client
|
137
138
|
test_files:
|
139
|
+
- test/fixtures/cassettes/limelight_upload_io.yml
|
138
140
|
- test/fixtures/cassettes/limelight_upload_media.yml
|
139
141
|
- test/fixtures/files/sample.mp4
|
140
142
|
- test/integration/limelight_test.rb
|