bitsontherun 0.1.1 → 0.1.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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bitsontherun (0.1.1)
4
+ bitsontherun (0.1.2)
5
5
  curb (>= 0.7.0)
6
6
  json (>= 1.4.0)
7
7
 
@@ -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"
@@ -1,3 +1,3 @@
1
1
  module BitsOnTheRun
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,29 +1,62 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "API call to store new video file" do
4
- it_should_behave_like "Successful response"
5
-
6
- before do
7
- @responses = []
8
- @file = 'spec/test.mp4'
9
- @responses << BitsOnTheRun::store('videos/create', @file)
10
-
11
- @manual = BitsOnTheRun::API.new(:store)
12
- @manual.method('videos/create')
13
- @manual.file(@file)
14
- @responses << @manual.execute
15
- end
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
- after do
18
- @responses.each do |video|
19
- BitsOnTheRun::call('videos/delete', :video_key => video.media.key)
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
- it "should contain information about uploaded video" do
24
- @responses.each do |r|
25
- r.file(:md5).size.should eql(32)
26
- r.file(:size).to_i.should > 0
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.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-16 00:00:00 +01:00
13
+ date: 2011-02-17 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency