ku6vms_sdk 0.1.0 → 0.1.1

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,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module GrandCloud
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
@@ -20,9 +20,7 @@ module GrandCloud
20
20
  EM.run { yield }
21
21
  end
22
22
 
23
- # upload is an async method
24
- def upload title, file_path, &block
25
- file = File.new(file_path)
23
+ def create title, &block
26
24
  creation = Base.send_request({
27
25
  :method => 'post',
28
26
  :uri => '/video',
@@ -30,9 +28,21 @@ module GrandCloud
30
28
  :Title => title
31
29
  }
32
30
  })
33
- creation.callback do
34
- rep = JSON.parse(creation.response)
31
+ creation.callback { block.call(JSON.parse(creation.response)) }
32
+
33
+ creation.errback do
34
+ GrandCloud.logger.error('requesting error...')
35
+ end
36
+ end
37
+
38
+ # upload is an async method
39
+ def upload title, file_path, &block
40
+ file = File.new(file_path)
41
+
42
+ self.create(title) do |rep|
43
+
35
44
  GrandCloud.logger.warn(rep)
45
+
36
46
  req = Base.file_upload({
37
47
  :method => 'post',
38
48
  :uri => '/vmsUpload.htm',
@@ -48,8 +58,26 @@ module GrandCloud
48
58
  })
49
59
  callback(req, block.to_proc, rep.select{|k, v| k =='sid' || k =='vid'})
50
60
  end
51
- creation.errback do
52
- GrandCloud.logger.error('requesting error...')
61
+ end
62
+
63
+ def pull_by_vms title, download_url, &block
64
+ self.create(title) do |rep|
65
+
66
+ GrandCloud.logger.warn(rep)
67
+
68
+ req = Base.send_request({
69
+ :method => 'post',
70
+ :uri => '/video/urlupload',
71
+ :additional_params => {
72
+ :sid => rep['sid'],
73
+ :videoUrl => CGI::escape(download_url),
74
+ :uploadUrl => rep['uploadUrl'],
75
+ :accessKey => Base.snda_access_key_id,
76
+ :secretKey => Base.secret_access_key
77
+ }
78
+
79
+ })
80
+ callback(req, block.to_proc, rep.select{|k, v| k =='sid' || k == 'vid'})
53
81
  end
54
82
  end
55
83
 
data/lib/grandcloud.rb CHANGED
@@ -14,6 +14,7 @@ require 'grand_cloud/authentication'
14
14
  require 'grand_cloud/base'
15
15
  require 'grand_cloud/video'
16
16
  require 'grand_cloud/version'
17
+ require 'debugger'
17
18
 
18
19
  module GrandCloud
19
20
 
@@ -21,6 +21,14 @@ module GrandCloud
21
21
 
22
22
  context "#video must done successfully functions" do
23
23
 
24
+ it "should pulled by ku6vms" do
25
+ @video.run do
26
+ @video.pull_by_vms('spec_pull_video', 'http://storage-huadong-1.sdcloud.cn/images.jiaoxuebang.com/nec_ppt.mp4?SNDAAccessKeyId=BH297OBMKFV0T2LO9MC189P2J&Expires=1376880551&Signature=MxRKaSen2q65pd8jjUK9Tt8Ffz8%3D'){ |rep|
27
+ rep['code'].should == 200
28
+ }
29
+ end
30
+ end
31
+
24
32
  it 'should upload video' do
25
33
  @video.run do
26
34
  GrandCloud.logger.info('start uploading, please wait...')
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ku6vms_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Tim Lang
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-08-15 00:00:00.000000000 Z
12
+ date: 2013-08-19 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: em-http-request
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: bundler
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -49,7 +54,7 @@ files:
49
54
  - Gemfile
50
55
  - Gemfile.lock
51
56
  - LICENSE
52
- - README.md
57
+ - README.rdoc
53
58
  - ku6vms_sdk.gemspec
54
59
  - lib/grand_cloud/authentication.rb
55
60
  - lib/grand_cloud/base.rb
@@ -63,26 +68,27 @@ files:
63
68
  homepage: https://github.com/TimLang/ku6vms_sdk
64
69
  licenses:
65
70
  - MIT
66
- metadata: {}
67
71
  post_install_message:
68
72
  rdoc_options: []
69
73
  require_paths:
70
74
  - lib
71
75
  required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
72
77
  requirements:
73
78
  - - ! '>='
74
79
  - !ruby/object:Gem::Version
75
80
  version: '0'
76
81
  required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
77
83
  requirements:
78
84
  - - ! '>='
79
85
  - !ruby/object:Gem::Version
80
86
  version: 1.3.6
81
87
  requirements: []
82
88
  rubyforge_project:
83
- rubygems_version: 2.0.6
89
+ rubygems_version: 1.8.25
84
90
  signing_key:
85
- specification_version: 4
91
+ specification_version: 3
86
92
  summary: Library for accessing Ku6vms
87
93
  test_files: []
88
94
  has_rdoc:
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZWI1NTZmNjIzMDhiMjVhMjQxMjQwMjRlNjhjYzBhZmY1ZDFjODkzOQ==
5
- data.tar.gz: !binary |-
6
- ZDgzZTJhMjU4ODU2YmVlZDlmNGQ3MDQyNmM4MTczNjQ1YTIzMDI2Ng==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NGFiN2IyMmNkOWU1MjljZTJiMTBhYWNiNTE2ZTFiMWZhNGUxNTFkN2M0NjI1
10
- OGQ0YjRhOGFmZDFhMmE2OTZmZTE5MzkxZGI3ODViZGQ3Yzk0ODBhM2FlZDNk
11
- ZjkyYjFiODdhMzgwZWRmMDg5ZjVkM2M3YzQ0MzkyZGMwMGFmMTM=
12
- data.tar.gz: !binary |-
13
- ODE0MDFhZDFmODkyYTQ5MWZmMTkzZTgzY2UzZWM3YzAyYzI0MjE0ZGI0OTJh
14
- MjdhOTVlNTQyOWMyYTlhMzkwMTdiODUwZGMwNzlkYjFmM2M2NzMzMmMzNWM5
15
- Mzc3MjY5M2U0YjA3YTg1OGM5MWFiY2E2NzhjNGZmZTRiNGFhYzg=
File without changes