qiniu 6.8.1 → 6.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ require 'qiniu'
6
6
  require 'qiniu/fop'
7
7
 
8
8
  module Qiniu
9
- module Fop
9
+ module Fop
10
10
  describe Fop do
11
11
 
12
12
  before :all do
@@ -32,10 +32,11 @@ module Qiniu
32
32
  data["width"].should_not be_zero
33
33
  data["height"].should_not be_zero
34
34
 
35
- result = Qiniu.get(@bucket, @key)
36
- result["url"].should_not be_empty
37
- puts result.inspect
38
- @source_image_url = result["url"]
35
+ code, domains, = Qiniu::Storage.domains(@bucket)
36
+ code.should be 200
37
+ domains.should_not be_empty
38
+ @bucket_domain = domains.first['domain']
39
+ @source_image_url = "http://#{@bucket_domain}/#{@key}"
39
40
 
40
41
  @mogrify_options = {
41
42
  :thumbnail => "!120x120>",
@@ -48,37 +49,32 @@ module Qiniu
48
49
  }
49
50
  end
50
51
 
51
- after :all do
52
- end
53
-
54
- context ".info" do
55
- it "should works" do
56
- code, data = Qiniu::Fop::Image.info(@source_image_url)
57
- code.should == 200
58
- puts data.inspect
59
- end
60
- end
61
-
62
- context ".exif" do
63
- it "should works" do
64
- result = Qiniu.get(@bucket, 'gogopher.jpg')
65
- result["url"].should_not be_empty
66
- puts result.inspect
52
+ # context ".info" do
53
+ # it "should works" do
54
+ # pending('This function cannot work for private bucket file')
55
+ # code, data = Qiniu::Fop::Image.info(@source_image_url)
56
+ # code.should == 200
57
+ # puts data.inspect
58
+ # end
59
+ # end
67
60
 
68
- code, data, headers = Qiniu::Fop::Image.exif(result["url"])
69
- code.should == 200
70
- puts data.inspect
71
- puts headers.inspect
72
- end
73
- end
74
-
75
- context ".mogrify_preview_url" do
76
- it "should works" do
77
- mogrify_preview_url = Qiniu::Fop::Image.mogrify_preview_url(@source_image_url, @mogrify_options)
78
- puts mogrify_preview_url.inspect
79
- end
80
- end
61
+ # context ".exif" do
62
+ # it "should works" do
63
+ # pending('This function cannot work for private bucket file')
64
+ # code, data, headers = Qiniu::Fop::Image.exif("http://#{@bucket_domain}/gogopher.jpg")
65
+ # code.should == 200
66
+ # puts data.inspect
67
+ # puts headers.inspect
68
+ # end
69
+ # end
81
70
 
71
+ # context ".mogrify_preview_url" do
72
+ # it "should works" do
73
+ # pending('This function cannot work for private bucket file')
74
+ # mogrify_preview_url = Qiniu::Fop::Image.mogrify_preview_url(@source_image_url, @mogrify_options)
75
+ # puts mogrify_preview_url.inspect
76
+ # end
77
+ # end
82
78
  end
83
- end # module Fop
79
+ end # module Fop
84
80
  end # module Qiniu
@@ -44,14 +44,6 @@ module Qiniu
44
44
  end
45
45
  end
46
46
 
47
- context ".get" do
48
- it "should works" do
49
- code, data = Storage.get(@bucket, @key)
50
- puts data.inspect
51
- code.should == 200
52
- end
53
- end
54
-
55
47
  context ".batch" do
56
48
  it "should works" do
57
49
  code, data = Storage.batch("stat", @bucket, [@key])
@@ -68,17 +60,9 @@ module Qiniu
68
60
  end
69
61
  end
70
62
 
71
- context ".batch_get" do
72
- it "should works" do
73
- code, data = Storage.batch_get(@bucket, [@key])
74
- puts data.inspect
75
- code.should == 200
76
- end
77
- end
78
-
79
63
  context ".batch_copy" do
80
64
  it "should works" do
81
- code, data = Storage.batch_copy @bucket, @key, @bucket, @key2
65
+ code, data = Storage.batch_copy [@bucket, @key, @bucket, @key2]
82
66
  puts data.inspect
83
67
  code.should == 200
84
68
 
@@ -23,21 +23,21 @@ module Qiniu
23
23
  code, body, headers = Qiniu::Storage.stat(@bucket, @key)
24
24
  if code == 404 || code == 612 then
25
25
  # 文件不存在,尝试上传
26
- pp = Qiniu::Auth.PutPolicy.new(@bucket, @key)
26
+ pp = Qiniu::Auth::PutPolicy.new(@bucket, @key)
27
27
  code, body, headers = Qiniu::Storage.upload_with_put_policy(
28
28
  pp,
29
- local_file
29
+ local_file,
30
+ nil,
31
+ nil,
32
+ bucket: @bucket
30
33
  )
31
34
  puts "Put a test file for Persistance cases"
32
35
  puts code.inspect
33
36
  puts body.inspect
34
- puts header.inspect
37
+ puts headers.inspect
35
38
  end
36
39
  end
37
40
 
38
- after :all do
39
- end
40
-
41
41
  context ".pfop" do
42
42
  it "should works" do
43
43
  pp = Persistance::PfopPolicy.new(
@@ -152,22 +152,6 @@ module Qiniu
152
152
  end
153
153
  end
154
154
 
155
- context ".get" do
156
- it "should works" do
157
- result = Qiniu.get(@bucket, @key, "qiniu_spec.rb", 10)
158
- expect(result).to_not be_empty
159
- puts result.inspect
160
- end
161
- end
162
-
163
- context ".download" do
164
- it "should works" do
165
- result = Qiniu.download(@bucket, @key, "rs_spec.rb", 10)
166
- expect(result).to_not be_empty
167
- puts result.inspect
168
- end
169
- end
170
-
171
155
  context ".batch" do
172
156
  it "should works" do
173
157
  result = Qiniu.batch("stat", @bucket, [@key])
@@ -184,43 +168,27 @@ module Qiniu
184
168
  end
185
169
  end
186
170
 
187
- context ".batch_get" do
188
- it "should works" do
189
- result = Qiniu.batch_get(@bucket, [@key])
190
- expect(result).to_not be_empty
191
- puts result.inspect
192
- end
193
- end
194
-
195
- context ".batch_download" do
196
- it "should works" do
197
- result = Qiniu.batch_download(@bucket, [@key])
198
- expect(result).to_not be_empty
199
- puts result.inspect
200
- end
201
- end
202
-
203
171
  =begin
204
172
  context ".batch_copy" do
205
173
  it "should works" do
206
174
  result = Qiniu.batch_copy [@bucket, @key, @bucket, @key2]
207
- result.should_not be_false
175
+ result.should_not be_falsey
208
176
 
209
177
  #result2 = Qiniu.stat(@bucket, @key2)
210
- #result2.should_not be_false
178
+ #result2.should_not be_falsey
211
179
  end
212
180
  end
213
181
 
214
182
  context ".batch_move" do
215
183
  it "should works" do
216
184
  result = Qiniu.batch_move [@bucket, @key, @bucket, @key2]
217
- result.should_not be_false
185
+ result.should_not be_falsey
218
186
 
219
187
  #result2 = Qiniu.stat(@bucket, @key2)
220
- #result2.should_not be_false
188
+ #result2.should_not be_falsey
221
189
 
222
190
  result3 = Qiniu.batch_move [@bucket, @key2, @bucket, @key]
223
- result3.should_not be_false
191
+ result3.should_not be_falsey
224
192
  end
225
193
  end
226
194
  =end
@@ -255,39 +223,45 @@ module Qiniu
255
223
  end
256
224
  end
257
225
 
258
- context ".image_info" do
259
- it "should works" do
260
- data = Qiniu.get(@test_image_bucket, @test_image_key)
261
- expect(data).to_not be_empty
262
- puts data.inspect
263
- result = Qiniu.image_info(data["url"])
264
- expect(result).to_not be_empty
265
- puts result.inspect
266
- end
267
- end
268
-
269
- context ".image_mogrify_save_as" do
270
- it "should works" do
271
- data = Qiniu.get(@test_image_bucket, @test_image_key)
272
- expect(data).to_not be_empty
273
- puts data.inspect
274
-
275
- dest_key = "cropped-" + @test_image_key
276
- src_img_url = data["url"]
277
- mogrify_options = {
278
- :thumbnail => "!120x120>",
279
- :gravity => "center",
280
- :crop => "!120x120a0a0",
281
- :quality => 85,
282
- :rotate => 45,
283
- :format => "jpg",
284
- :auto_orient => true
285
- }
286
- result2 = Qiniu.image_mogrify_save_as(@test_image_bucket, dest_key, src_img_url, mogrify_options)
287
- expect(result2).to_not be_empty
288
- puts result2.inspect
289
- end
290
- end
226
+ # context ".image_info" do
227
+ # it "should works" do
228
+ # pending 'This function cannot work for private bucket file'
229
+ # code, domains, = Qiniu::Storage.domains(@test_image_bucket)
230
+ # code.should be 200
231
+ # domains.should_not be_empty
232
+ # domain = domains.first['domain']
233
+ # url = "http://#{domain}/#{@test_image_key}"
234
+
235
+ # result = Qiniu.image_info(url)
236
+ # expect(result).to_not be_falsey
237
+ # puts result.inspect
238
+ # end
239
+ # end
240
+
241
+ # context ".image_mogrify_save_as" do
242
+ # it "should works" do
243
+ # pending 'This function cannot work for private bucket file'
244
+ # code, domains, = Qiniu::Storage.domains(@test_image_bucket)
245
+ # code.should be 200
246
+ # domains.should_not be_empty
247
+ # domain = domains.first['domain']
248
+ # src_img_url = "http://#{domain}/#{@test_image_key}"
249
+
250
+ # dest_key = "cropped-" + @test_image_key
251
+ # mogrify_options = {
252
+ # :thumbnail => "!120x120>",
253
+ # :gravity => "center",
254
+ # :crop => "!120x120a0a0",
255
+ # :quality => 85,
256
+ # :rotate => 45,
257
+ # :format => "jpg",
258
+ # :auto_orient => true
259
+ # }
260
+ # result2 = Qiniu.image_mogrify_save_as(@test_image_bucket, dest_key, src_img_url, mogrify_options)
261
+ # expect(result2).to_not be_falsey
262
+ # puts result2.inspect
263
+ # end
264
+ # end
291
265
 
292
266
  context ".generate_upload_token" do
293
267
  it "should works" do
@@ -49,6 +49,10 @@ module Qiniu
49
49
 
50
50
  ### 测试单文件直传
51
51
  context ".upload_with_token" do
52
+ before do
53
+ Qiniu::Storage.delete(@bucket, @key)
54
+ end
55
+
52
56
  after do
53
57
  code, data = Qiniu::Storage.delete(@bucket, @key)
54
58
  puts data.inspect
@@ -79,6 +83,10 @@ module Qiniu
79
83
  end
80
84
 
81
85
  context ".upload_with_token_2" do
86
+ before do
87
+ Qiniu::Storage.delete(@bucket, @key)
88
+ end
89
+
82
90
  after do
83
91
  code, data = Qiniu::Storage.delete(@bucket, @key)
84
92
  puts data.inspect
@@ -108,6 +116,10 @@ module Qiniu
108
116
  end # .upload_with_token_2
109
117
 
110
118
  context ".upload_with_put_policy" do
119
+ before do
120
+ Qiniu::Storage.delete(@bucket, @key)
121
+ end
122
+
111
123
  after do
112
124
  code, data = Qiniu::Storage.delete(@bucket, @key)
113
125
  puts data.inspect
@@ -149,6 +161,10 @@ module Qiniu
149
161
  end # .upload_with_put_policy
150
162
 
151
163
  context ".upload_buffer_with_put_policy" do
164
+ before do
165
+ Qiniu::Storage.delete(@bucket, @key)
166
+ end
167
+
152
168
  after do
153
169
  code, data = Qiniu::Storage.delete(@bucket, @key)
154
170
  puts data.inspect
@@ -180,6 +196,10 @@ module Qiniu
180
196
 
181
197
  ### 测试断点续上传
182
198
  context ".resumable_upload_with_token" do
199
+ before do
200
+ Qiniu::Storage.delete(@bucket, @key_5m)
201
+ end
202
+
183
203
  after do
184
204
  code, data = Qiniu::Storage.delete(@bucket, @key_5m)
185
205
  puts data.inspect
@@ -207,6 +227,10 @@ module Qiniu
207
227
  end
208
228
 
209
229
  context ".resumable_upload_with_token2" do
230
+ before do
231
+ Qiniu::Storage.delete(@bucket, @key_4m)
232
+ end
233
+
210
234
  after do
211
235
  code, data = Qiniu::Storage.delete(@bucket, @key_4m)
212
236
  puts data.inspect
@@ -234,6 +258,10 @@ module Qiniu
234
258
  end
235
259
 
236
260
  context ".resumable_upload_with_token3" do
261
+ before do
262
+ Qiniu::Storage.delete(@bucket, @key_8m)
263
+ end
264
+
237
265
  after do
238
266
  code, data = Qiniu::Storage.delete(@bucket, @key_8m)
239
267
  puts data.inspect
@@ -261,6 +289,10 @@ module Qiniu
261
289
  end
262
290
 
263
291
  context ".resumable_upload_with_token4" do
292
+ before do
293
+ Qiniu::Storage.delete(@bucket, @key_1m)
294
+ end
295
+
264
296
  after do
265
297
  code, data = Qiniu::Storage.delete(@bucket, @key_1m)
266
298
  puts data.inspect
@@ -1,19 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  require 'spec_helper'
4
- require 'fakeweb'
5
4
  require 'qiniu/utils'
6
5
 
7
6
  module Qiniu
8
7
  module RS
9
8
  describe Utils do
10
- before :all do
11
- Struct.new("Response", :code, :body)
12
- end
9
+ include WebMock::API
13
10
 
14
11
  after :each do
15
- FakeWeb.clean_registry
16
- FakeWeb.allow_net_connect = true
12
+ WebMock.disable!
17
13
  end
18
14
 
19
15
  context "safe_json_parse" do
@@ -25,8 +21,8 @@ module Qiniu
25
21
 
26
22
  context ".send_request_with" do
27
23
  it "should works" do
28
- FakeWeb.allow_net_connect = false
29
- FakeWeb.register_uri(:get, "http://develoepr.qiniu.com/", :body => {:abc => 123}.to_json)
24
+ WebMock.enable!
25
+ stub_request(:get, "develoepr.qiniu.com/").to_return(body: {abc: 123}.to_json)
30
26
  res = Utils.send_request_with 'http://develoepr.qiniu.com/', nil, :method => :get
31
27
  res.should == [200, {"abc" => 123}, {}]
32
28
  end
@@ -34,11 +30,11 @@ module Qiniu
34
30
  [400, 500].each do |code|
35
31
  context "upstream return http #{code}" do
36
32
  it "should raise RestClient::RequestFailed" do
37
- FakeWeb.allow_net_connect = false
38
- FakeWeb.register_uri(:get, "http://develoepr.qiniu.com/", :status => code)
39
- lambda {
40
- res = Utils.send_request_with 'http://develoepr.qiniu.com/', nil, :method => :get
41
- }.should raise_error RestClient::RequestFailed
33
+ WebMock.enable!
34
+ stub_request(:get, "develoepr.qiniu.com/").to_return(status: code)
35
+ expect do
36
+ Utils.send_request_with 'http://develoepr.qiniu.com/', nil, :method => :get
37
+ end.to raise_error RestClient::RequestFailed
42
38
  end
43
39
  end
44
40
  end
@@ -3,6 +3,7 @@
3
3
  require 'bundler/setup'
4
4
  require 'qiniu'
5
5
  require 'rspec'
6
+ require 'webmock'
6
7
 
7
8
  RSpec.configure do |config|
8
9
  config.before :all do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qiniu
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.8.1
4
+ version: 6.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - why404
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-29 00:00:00.000000000 Z
12
+ date: 2017-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -17,56 +17,42 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0.9'
20
+ version: '12'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '0.9'
27
+ version: '12'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '2.11'
34
+ version: '3.5'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '2.11'
41
+ version: '3.5'
42
42
  - !ruby/object:Gem::Dependency
43
- name: fakeweb
43
+ name: webmock
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.3'
48
+ version: '2.3'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '1.3'
56
- - !ruby/object:Gem::Dependency
57
- name: json
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '1.8'
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '1.8'
55
+ version: '2.3'
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: rest-client
72
58
  requirement: !ruby/object:Gem::Requirement
@@ -74,9 +60,6 @@ dependencies:
74
60
  - - "~>"
75
61
  - !ruby/object:Gem::Version
76
62
  version: '2.0'
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: 2.0.0
80
63
  type: :runtime
81
64
  prerelease: false
82
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -84,43 +67,20 @@ dependencies:
84
67
  - - "~>"
85
68
  - !ruby/object:Gem::Version
86
69
  version: '2.0'
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 2.0.0
90
70
  - !ruby/object:Gem::Dependency
91
71
  name: mime-types
92
72
  requirement: !ruby/object:Gem::Requirement
93
73
  requirements:
94
74
  - - "~>"
95
75
  - !ruby/object:Gem::Version
96
- version: '2.4'
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: 2.4.0
100
- type: :runtime
101
- prerelease: false
102
- version_requirements: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - "~>"
105
- - !ruby/object:Gem::Version
106
- version: '2.4'
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: 2.4.0
110
- - !ruby/object:Gem::Dependency
111
- name: ruby-hmac
112
- requirement: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '0.4'
76
+ version: '3.1'
117
77
  type: :runtime
118
78
  prerelease: false
119
79
  version_requirements: !ruby/object:Gem::Requirement
120
80
  requirements:
121
81
  - - "~>"
122
82
  - !ruby/object:Gem::Version
123
- version: '0.4'
83
+ version: '3.1'
124
84
  description: 'Qiniu Resource (Cloud) Storage SDK for Ruby. See: http://developer.qiniu.com/docs/v6/sdk/ruby-sdk.html'
125
85
  email:
126
86
  - sdk@qiniu.com
@@ -128,28 +88,9 @@ executables: []
128
88
  extensions: []
129
89
  extra_rdoc_files: []
130
90
  files:
131
- - ".gitignore"
132
- - ".rspec"
133
- - ".travis.yml"
134
91
  - CHANGELOG.md
135
- - Gemfile
136
92
  - LICENSE
137
93
  - README.md
138
- - Rakefile
139
- - docs/README.md
140
- - examples/copy.rb
141
- - examples/delete.rb
142
- - examples/download.rb
143
- - examples/fetch.rb
144
- - examples/fops.rb
145
- - examples/list.rb
146
- - examples/move.rb
147
- - examples/pfop_vframe.rb
148
- - examples/pfop_watermark.rb
149
- - examples/stat.rb
150
- - examples/upload.rb
151
- - examples/upload_callback.rb
152
- - examples/upload_pfops.rb
153
94
  - lib/qiniu-rs.rb
154
95
  - lib/qiniu.rb
155
96
  - lib/qiniu/abstract.rb
@@ -174,12 +115,8 @@ files:
174
115
  - lib/qiniu/upload.rb
175
116
  - lib/qiniu/utils.rb
176
117
  - lib/qiniu/version.rb
177
- - qiniu.gemspec
178
- - rails3/Gemfile
179
- - rails3/qiniu.gemspec
180
118
  - spec/qiniu/abstract_spec.rb
181
119
  - spec/qiniu/auth_spec.rb
182
- - spec/qiniu/image_logo_for_test.png
183
120
  - spec/qiniu/image_spec.rb
184
121
  - spec/qiniu/management_spec.rb
185
122
  - spec/qiniu/misc_spec.rb
@@ -200,9 +137,9 @@ require_paths:
200
137
  - lib
201
138
  required_ruby_version: !ruby/object:Gem::Requirement
202
139
  requirements:
203
- - - ">="
140
+ - - "~>"
204
141
  - !ruby/object:Gem::Version
205
- version: '0'
142
+ version: '2.1'
206
143
  required_rubygems_version: !ruby/object:Gem::Requirement
207
144
  requirements:
208
145
  - - ">="
@@ -210,27 +147,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
147
  version: '0'
211
148
  requirements: []
212
149
  rubyforge_project:
213
- rubygems_version: 2.5.1
150
+ rubygems_version: 2.6.14
214
151
  signing_key:
215
152
  specification_version: 4
216
153
  summary: Qiniu Resource (Cloud) Storage SDK for Ruby
217
154
  test_files:
218
- - examples/copy.rb
219
- - examples/delete.rb
220
- - examples/download.rb
221
- - examples/fetch.rb
222
- - examples/fops.rb
223
- - examples/list.rb
224
- - examples/move.rb
225
- - examples/pfop_vframe.rb
226
- - examples/pfop_watermark.rb
227
- - examples/stat.rb
228
- - examples/upload.rb
229
- - examples/upload_callback.rb
230
- - examples/upload_pfops.rb
231
155
  - spec/qiniu/abstract_spec.rb
232
156
  - spec/qiniu/auth_spec.rb
233
- - spec/qiniu/image_logo_for_test.png
234
157
  - spec/qiniu/image_spec.rb
235
158
  - spec/qiniu/management_spec.rb
236
159
  - spec/qiniu/misc_spec.rb