ku6vms_sdk 0.1.6 → 0.1.7
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/Gemfile +2 -0
- data/Gemfile.lock +4 -0
- data/lib/grand_cloud/base.rb +1 -1
- data/lib/grand_cloud/version.rb +1 -1
- data/lib/grand_cloud/video.rb +11 -9
- data/lib/grandcloud.rb +6 -1
- data/spec/grand_cloud/video_spec.rb +0 -1
- metadata +2 -2
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -26,6 +26,8 @@ GEM
|
|
26
26
|
mocha (0.12.3)
|
27
27
|
metaclass (~> 0.0.1)
|
28
28
|
multipart_body (0.2.1)
|
29
|
+
nokogiri (1.5.10)
|
30
|
+
nori (2.3.0)
|
29
31
|
rspec (2.14.1)
|
30
32
|
rspec-core (~> 2.14.0)
|
31
33
|
rspec-expectations (~> 2.14.0)
|
@@ -44,4 +46,6 @@ DEPENDENCIES
|
|
44
46
|
eventmachine
|
45
47
|
mocha
|
46
48
|
multipart_body
|
49
|
+
nokogiri
|
50
|
+
nori
|
47
51
|
rspec
|
data/lib/grand_cloud/base.rb
CHANGED
@@ -23,7 +23,7 @@ module GrandCloud
|
|
23
23
|
request_params = {}
|
24
24
|
request_params.merge!(options[:timeout]) if options[:timeout]
|
25
25
|
|
26
|
-
params = {:head => {:Accept => options[:header_accept] || 'application/
|
26
|
+
params = {:head => {:Accept => options[:header_accept] || 'application/xml'}}
|
27
27
|
params.merge!(options[:request_params]) if options[:request_params]
|
28
28
|
EM::HttpRequest.new(url, request_params).send((options[:method] && options[:method].downcase) || "get", params)
|
29
29
|
end
|
data/lib/grand_cloud/version.rb
CHANGED
data/lib/grand_cloud/video.rb
CHANGED
@@ -9,7 +9,7 @@ module GrandCloud
|
|
9
9
|
json = common_request do
|
10
10
|
Base.send_request({:method => 'get', :uri => "/video/#{id}"})
|
11
11
|
end
|
12
|
-
wrap_object(json['video'])
|
12
|
+
wrap_object(json['DetailVideoResponse']['video'])
|
13
13
|
rescue Error::ResponseError => e
|
14
14
|
GrandCloud.logger.error(e)
|
15
15
|
return nil
|
@@ -29,7 +29,7 @@ module GrandCloud
|
|
29
29
|
:BypassEncoding => pass_encoding
|
30
30
|
}
|
31
31
|
})
|
32
|
-
creation.callback { block.call(
|
32
|
+
creation.callback { block.call(GrandCloud.nori.parse(creation.response)['CreateVideoResponse']) }
|
33
33
|
|
34
34
|
creation.errback do
|
35
35
|
GrandCloud.logger.error("Error is: #{creation.error}, requesting error...")
|
@@ -117,7 +117,7 @@ module GrandCloud
|
|
117
117
|
}
|
118
118
|
})
|
119
119
|
end
|
120
|
-
json['
|
120
|
+
json['ModifyVideoResponse']['return']
|
121
121
|
rescue Error::ResponseError => e
|
122
122
|
GrandCloud.logger.error(e)
|
123
123
|
return false
|
@@ -130,7 +130,7 @@ module GrandCloud
|
|
130
130
|
:uri => "/videos/#{id}"
|
131
131
|
})
|
132
132
|
end
|
133
|
-
json['
|
133
|
+
json['RemoveVideosResponse']['return']
|
134
134
|
rescue Error::ResponseError => e
|
135
135
|
GrandCloud.logger.error(e)
|
136
136
|
return false
|
@@ -140,7 +140,7 @@ module GrandCloud
|
|
140
140
|
json = common_request do
|
141
141
|
Base.send_request({:method => 'get', :uri => "/videos"})
|
142
142
|
end
|
143
|
-
json['videoSet'].map{|v| wrap_object(v) }
|
143
|
+
json['ListVideoResponse']['videoSet']['item'].map{|v| wrap_object(v) }
|
144
144
|
rescue Error::ResponseError => e
|
145
145
|
GrandCloud.logger.error(e)
|
146
146
|
return []
|
@@ -196,7 +196,7 @@ module GrandCloud
|
|
196
196
|
def get_default_program_id
|
197
197
|
programs = get_programs
|
198
198
|
unless programs.empty?
|
199
|
-
result = programs['programSet'].select{|a| a['programName'] == '默认方案'}
|
199
|
+
result = programs['ListProgramsResponse']['programSet'].select{|a| a['programName'] == '默认方案'}
|
200
200
|
result.empty? ? nil : result[0]['programId']
|
201
201
|
else
|
202
202
|
nil
|
@@ -211,13 +211,15 @@ module GrandCloud
|
|
211
211
|
def callback req, func=nil, additional_attributes=nil
|
212
212
|
response = EM::DefaultDeferrable.new
|
213
213
|
req.callback do
|
214
|
-
rep = req.response.blank? ? {'code' => req.response_header.status} :
|
215
|
-
if rep
|
214
|
+
rep = req.response.blank? ? {'code' => req.response_header.status} : GrandCloud.nori.parse(req.response)
|
215
|
+
rep = JSON.parse(req.response) if rep.blank?
|
216
|
+
if (rep['Response'] && rep['Response']['errors']) || rep['HR']
|
216
217
|
response.fail(rep)
|
217
218
|
else
|
218
219
|
response.succeed(additional_attributes ? rep.merge!(additional_attributes) : rep)
|
219
220
|
end
|
220
|
-
raise Error::ResponseError.new(rep['errors'][
|
221
|
+
raise Error::ResponseError.new(rep['Response']['errors']['message']) if rep['Response'] && ['Response']['errors']
|
222
|
+
raise Error::ResponseError.new('Ku6vms Internal error ...') if rep['HR']
|
221
223
|
func.call(rep) if func
|
222
224
|
EM.stop
|
223
225
|
end
|
data/lib/grandcloud.rb
CHANGED
@@ -16,17 +16,22 @@ require 'grand_cloud/authentication'
|
|
16
16
|
require 'grand_cloud/base'
|
17
17
|
require 'grand_cloud/video'
|
18
18
|
require 'grand_cloud/version'
|
19
|
+
require 'nokogiri'
|
20
|
+
require 'nori'
|
19
21
|
require 'debugger'
|
20
22
|
|
21
23
|
module GrandCloud
|
22
24
|
|
23
25
|
DEFAULT_HOST_URL = "api.ku6vms.com"
|
24
26
|
|
25
|
-
attr_reader :logger
|
27
|
+
attr_reader :logger, :nori
|
26
28
|
|
27
29
|
def self.logger
|
28
30
|
@logger || (@logger = Logger.new(STDOUT))
|
29
31
|
end
|
30
32
|
|
33
|
+
def self.nori
|
34
|
+
@nori || Nori.new
|
35
|
+
end
|
31
36
|
|
32
37
|
end
|
@@ -26,7 +26,6 @@ module GrandCloud
|
|
26
26
|
@video.run do
|
27
27
|
@video.pull_by_vms('spec_pull_video', 'http://storage-huadong-1.sdcloud.cn/images.jiaoxuebang.com/MOV_0399.mp4?SNDAAccessKeyId=BH297OBMKFV0T2LO9MC189P2J&Expires=1377147099&Signature=JpbNOKlBc7SD4%2FYKIiPz8HJDHf4%3D'){ |rep|
|
28
28
|
puts rep
|
29
|
-
debugger
|
30
29
|
rep['code'].should == 202
|
31
30
|
}
|
32
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ku6vms_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: em-http-request
|