aliyun-sdk 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b100cc95c5037862d703916b478002db371f0a6
4
- data.tar.gz: cad01a4961627efe0b9f7b715ebc74de14542e85
3
+ metadata.gz: 96cdc1616990ccc7955bcb5a53736adebc159af0
4
+ data.tar.gz: afef99f79b8ab82e8b4cae152b621391eb2a2481
5
5
  SHA512:
6
- metadata.gz: 9ae0b923399d7480680b824e719def6da96fe278234b9e3e51496880b76699bb744f5fbd164dafe7d54f5b853d131b480a567017c2c8c25905432291d020b177
7
- data.tar.gz: fe7398a96244d8f9c64aa89a7196753f2569ae6922c329761c9c48fc13432650d8a0dcafc42e3646094ede356294c6410268279e605b9b97f4eb3d60b6f759c4
6
+ metadata.gz: 9b5534e876814e787bbbb3ed21cb6fbdef571acf67e3bf9e0bafa54b1b363440cf06e61bd7a3b9441380a89bb9abf4d677b118ec39a5090e4bd8dc2ac02c2dd6
7
+ data.tar.gz: 899d71d9038bc6fe11eace3aad493ff5ca90348713f37ab48e678dd574a19f6add94508f760466172977ce1d3869f5e35f2ace060912cfa7440b252beb268940
@@ -42,7 +42,8 @@ module Aliyun
42
42
  end
43
43
 
44
44
  def message
45
- @attrs['Message'] || "UnknownError, HTTP Code: #{http_code}"
45
+ msg = @attrs['Message'] || "UnknownError[#{http_code}]."
46
+ "#{msg} RequestId: #{request_id}"
46
47
  end
47
48
 
48
49
  def to_s
@@ -3,7 +3,7 @@
3
3
  module Aliyun
4
4
  module OSS
5
5
 
6
- VERSION = "0.1.2"
6
+ VERSION = "0.1.3"
7
7
 
8
8
  end # OSS
9
9
  end # Aliyun
@@ -171,15 +171,17 @@ module Aliyun
171
171
  end
172
172
 
173
173
  def mock_error(code, message)
174
- builder = Nokogiri::XML::Builder.new do |xml|
174
+ Nokogiri::XML::Builder.new do |xml|
175
175
  xml.Error {
176
176
  xml.Code code
177
177
  xml.Message message
178
178
  xml.RequestId '0000'
179
179
  }
180
- end
180
+ end.to_xml
181
+ end
181
182
 
182
- builder.to_xml
183
+ def err(msg, reqid = '0000')
184
+ "#{msg} RequestId: #{reqid}"
183
185
  end
184
186
 
185
187
  context "Create bucket" do
@@ -348,7 +350,7 @@ module Aliyun
348
350
 
349
351
  expect {
350
352
  @protocol.delete_bucket(@bucket)
351
- }.to raise_error(Exception, message)
353
+ }.to raise_error(ServerError, err(message))
352
354
  end
353
355
  end # delete bucket
354
356
 
@@ -77,6 +77,10 @@ module Aliyun
77
77
  end.to_xml
78
78
  end
79
79
 
80
+ def err(msg, reqid = '0000')
81
+ "#{msg} RequestId: #{reqid}"
82
+ end
83
+
80
84
  context "bucket operations" do
81
85
  it "should get acl" do
82
86
  query = {'acl' => ''}
@@ -262,7 +266,7 @@ module Aliyun
262
266
 
263
267
  expect {
264
268
  @bucket.get_object(key)
265
- }.to raise_error(Exception, "UnknownError, HTTP Code: 404")
269
+ }.to raise_error(ServerError, err("UnknownError[404].", ''))
266
270
 
267
271
  expect(@bucket.object_exists?(key)).to be false
268
272
  expect(@bucket.object_exist?(key)).to be false
@@ -288,7 +292,7 @@ module Aliyun
288
292
 
289
293
  expect {
290
294
  @bucket.object_exists?(key)
291
- }.to raise_error(Exception, "UnknownError, HTTP Code: 500")
295
+ }.to raise_error(ServerError, err("UnknownError[500].", ''))
292
296
  end
293
297
 
294
298
  it "should update object metas" do
@@ -87,15 +87,17 @@ module Aliyun
87
87
  end
88
88
 
89
89
  def mock_error(code, message)
90
- builder = Nokogiri::XML::Builder.new do |xml|
90
+ Nokogiri::XML::Builder.new do |xml|
91
91
  xml.Error {
92
92
  xml.Code code
93
93
  xml.Message message
94
94
  xml.RequestId '0000'
95
95
  }
96
- end
96
+ end.to_xml
97
+ end
97
98
 
98
- builder.to_xml
99
+ def err(msg, reqid = '0000')
100
+ "#{msg} RequestId: #{reqid}"
99
101
  end
100
102
 
101
103
  context "Initiate multipart upload" do
@@ -143,7 +145,7 @@ module Aliyun
143
145
 
144
146
  expect {
145
147
  @protocol.initiate_multipart_upload(@bucket, @object)
146
- }.to raise_error(Exception, message)
148
+ }.to raise_error(ServerError, err(message))
147
149
 
148
150
  expect(WebMock).to have_requested(:post, request_path)
149
151
  .with(:body => nil, :query => query)
@@ -200,7 +202,7 @@ module Aliyun
200
202
 
201
203
  expect {
202
204
  @protocol.upload_part(@bucket, @object, txn_id, part_no) {}
203
- }.to raise_error(Exception, message)
205
+ }.to raise_error(ServerError, err(message))
204
206
 
205
207
  expect(WebMock).to have_requested(:put, request_path)
206
208
  .with(:body => nil, :query => query)
@@ -302,7 +304,7 @@ module Aliyun
302
304
 
303
305
  expect {
304
306
  @protocol.upload_part_by_copy(@bucket, @object, txn_id, part_no, 'src_obj')
305
- }.to raise_error(Exception, message)
307
+ }.to raise_error(ServerError, err(message))
306
308
 
307
309
  expect(WebMock).to have_requested(:put, request_path)
308
310
  .with(:body => nil, :query => query, :headers => headers)
@@ -351,7 +353,7 @@ module Aliyun
351
353
 
352
354
  expect {
353
355
  @protocol.complete_multipart_upload(@bucket, @object, txn_id, [])
354
- }.to raise_error(Exception, message)
356
+ }.to raise_error(ServerError, err(message))
355
357
 
356
358
  expect(WebMock).to have_requested(:post, request_path)
357
359
  .with(:query => query)
@@ -386,7 +388,7 @@ module Aliyun
386
388
 
387
389
  expect {
388
390
  @protocol.abort_multipart_upload(@bucket, @object, txn_id)
389
- }.to raise_error(Exception, message)
391
+ }.to raise_error(ServerError, err(message))
390
392
 
391
393
  expect(WebMock).to have_requested(:delete, request_path)
392
394
  .with(:body => nil, :query => query)
@@ -568,7 +570,7 @@ module Aliyun
568
570
 
569
571
  expect {
570
572
  @protocol.list_multipart_uploads(@bucket)
571
- }.to raise_error(Exception, message)
573
+ }.to raise_error(ServerError, err(message))
572
574
 
573
575
  expect(WebMock).to have_requested(:get, request_path)
574
576
  .with(:body => nil, :query => query)
@@ -662,7 +664,7 @@ module Aliyun
662
664
 
663
665
  expect {
664
666
  @protocol.list_parts(@bucket, @object, txn_id)
665
- }.to raise_error(Exception, message)
667
+ }.to raise_error(ServerError, err(message))
666
668
 
667
669
  expect(WebMock).to have_requested(:get, request_path)
668
670
  .with(:body => nil, :query => query)
@@ -80,14 +80,17 @@ module Aliyun
80
80
  end
81
81
 
82
82
  def mock_error(code, message)
83
- builder = Nokogiri::XML::Builder.new do |xml|
83
+ Nokogiri::XML::Builder.new do |xml|
84
84
  xml.Error {
85
85
  xml.Code code
86
86
  xml.Message message
87
+ xml.RequestId '0000'
87
88
  }
88
- end
89
+ end.to_xml
90
+ end
89
91
 
90
- builder.to_xml
92
+ def err(msg, reqid = '0000')
93
+ "#{msg} RequestId: #{reqid}"
91
94
  end
92
95
 
93
96
  context "Put object" do
@@ -120,7 +123,7 @@ module Aliyun
120
123
  @protocol.put_object(@bucket, object_name) do |c|
121
124
  c << content
122
125
  end
123
- }.to raise_error(Exception, message)
126
+ }.to raise_error(ServerError, err(message))
124
127
 
125
128
  expect(WebMock).to have_requested(:put, url)
126
129
  .with(:body => content, :query => {})
@@ -226,7 +229,7 @@ module Aliyun
226
229
  @protocol.append_object(@bucket, object_name, 11) do |c|
227
230
  c << content
228
231
  end
229
- }.to raise_error(Exception, message)
232
+ }.to raise_error(Exception, err(message))
230
233
 
231
234
  expect(WebMock).to have_requested(:post, url)
232
235
  .with(:body => content, :query => query)
@@ -382,7 +385,7 @@ module Aliyun
382
385
  message = 'The object to copy is too large.'
383
386
  stub_request(:put, url).to_return(
384
387
  :status => 400,
385
- :headers => {'x-oss-request-id' => '0000-1111'},
388
+ :headers => {'x-oss-request-id' => '0000'},
386
389
  :body => mock_error(code, message))
387
390
 
388
391
  begin
@@ -391,8 +394,8 @@ module Aliyun
391
394
  rescue ServerError => e
392
395
  expect(e.http_code).to eq(400)
393
396
  expect(e.error_code).to eq(code)
394
- expect(e.message).to eq(message)
395
- expect(e.request_id).to eq('0000-1111')
397
+ expect(e.message).to eq(err(message))
398
+ expect(e.request_id).to eq('0000')
396
399
  end
397
400
 
398
401
  expect(WebMock).to have_requested(:put, url)
@@ -462,7 +465,7 @@ module Aliyun
462
465
 
463
466
  expect {
464
467
  @protocol.get_object(@bucket, object_name) {|c| true}
465
- }.to raise_error(Exception, message)
468
+ }.to raise_error(ServerError, err(message))
466
469
 
467
470
  expect(WebMock).to have_requested(:get, url)
468
471
  .with(:body => nil, :query => {})
@@ -619,7 +622,7 @@ module Aliyun
619
622
 
620
623
  expect {
621
624
  @protocol.delete_object(@bucket, object_name)
622
- }.to raise_error(Exception, message)
625
+ }.to raise_error(ServerError, err(message))
623
626
 
624
627
  expect(WebMock).to have_requested(:delete, url)
625
628
  .with(:body => nil, :query => {})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliyun-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tianlong Wu
@@ -56,28 +56,28 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.4'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '='
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '3.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.3'
83
83
  - !ruby/object:Gem::Dependency