bitsontherun 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.markdown +5 -1
- data/lib/bitsontherun/response.rb +4 -0
- data/lib/bitsontherun/version.rb +1 -1
- data/spec/lib/store_spec.rb +52 -19
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -30,10 +30,14 @@ Basic call:
|
|
30
30
|
BitsOnTheRun::call('version') => {:status => "ok", :version => "X.X.X"}
|
31
31
|
BitsOnTheRun::call('videos/update', :video_key => 'your video key', :title => 'New title for video').ok? => true
|
32
32
|
|
33
|
-
Basic store:
|
33
|
+
Basic store (upload a video):
|
34
34
|
|
35
35
|
BitsOnTheRun::store('videos/create', 'video.mp4') => {:status => "ok", ...}
|
36
36
|
|
37
|
+
Basic store (create a new video object on the plaform and generate upload url):
|
38
|
+
|
39
|
+
BitsOnTheRun::call('videos/create').upload_url => http://upload.bitsontherun.com/v1/videos/upload?api_format=json&key=<key>&token=<token>
|
40
|
+
|
37
41
|
Extended call methods:
|
38
42
|
|
39
43
|
call = BitsOnTheRun::API.new(:call)
|
@@ -8,6 +8,10 @@ module BitsOnTheRun
|
|
8
8
|
@parsed = Parser::parse(response)
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
def upload_url
|
13
|
+
"#{link.protocol}://#{link.address}#{link.path}?api_format=#{BitsOnTheRun.format}&key=#{link.query.key}&token=#{link.query.token}"
|
14
|
+
end
|
11
15
|
|
12
16
|
def ok?
|
13
17
|
status == "ok"
|
data/lib/bitsontherun/version.rb
CHANGED
data/spec/lib/store_spec.rb
CHANGED
@@ -1,29 +1,62 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "API call to store new video file" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
context "Store an existing file" do
|
5
|
+
it_should_behave_like "Successful response"
|
6
|
+
|
7
|
+
before do
|
8
|
+
@responses = []
|
9
|
+
@file = 'spec/test.mp4'
|
10
|
+
@responses << BitsOnTheRun::store('videos/create', @file)
|
11
|
+
|
12
|
+
@manual = BitsOnTheRun::API.new(:store)
|
13
|
+
@manual.method('videos/create')
|
14
|
+
@manual.file(@file)
|
15
|
+
@responses << @manual.execute
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
@responses.each do |video|
|
20
|
+
BitsOnTheRun::call('videos/delete', :video_key => video.media.key)
|
21
|
+
end
|
22
|
+
end
|
16
23
|
|
17
|
-
|
18
|
-
|
19
|
-
|
24
|
+
it "should contain information about uploaded video" do
|
25
|
+
@responses.each do |r|
|
26
|
+
r.file(:md5).size.should eql(32)
|
27
|
+
r.file(:size).to_i.should > 0
|
28
|
+
end
|
20
29
|
end
|
21
30
|
end
|
22
31
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
32
|
+
context "Store a user uploaded file" do
|
33
|
+
it_should_behave_like "Successful response"
|
34
|
+
|
35
|
+
before do
|
36
|
+
@responses = []
|
37
|
+
@responses << BitsOnTheRun::call('videos/create')
|
38
|
+
|
39
|
+
@manual = BitsOnTheRun::API.new(:call)
|
40
|
+
@manual.method('videos/create')
|
41
|
+
@responses << @manual.execute
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should contain a video key and params to build the upload URL" do
|
45
|
+
@responses.each do |r|
|
46
|
+
r.media(:type).should eql('video')
|
47
|
+
r.media(:key).should_not be_empty
|
48
|
+
r.link(:path).should eql('/v1/videos/upload')
|
49
|
+
r.link.query(:token).should_not be_empty
|
50
|
+
r.link.query(:key).should_not be_empty
|
51
|
+
r.link.protocol.should eql('http')
|
52
|
+
r.link.address.should_not be_empty
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should allow to create upload url" do
|
57
|
+
@responses.each do |r|
|
58
|
+
r.upload_url.should == "http://#{r.link.address}/v1/videos/upload?api_format=json&key=#{r.link.query.key}&token=#{r.link.query.token}"
|
59
|
+
end
|
27
60
|
end
|
28
61
|
end
|
29
62
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: bitsontherun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Adrian Duli\xC4\x87"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-17 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|