qiniu-rs 2.3.3 → 3.0.3

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.
@@ -11,31 +11,34 @@ module Qiniu
11
11
  describe RS do
12
12
 
13
13
  before :all do
14
- =begin
15
- code, data = Qiniu::RS::Auth.exchange_by_password!("test@qbox.net", "test")
14
+
15
+ @bucket = "test_bucket_1234"
16
+ @key = Digest::SHA1.hexdigest (Time.now.to_i+rand(100)).to_s
17
+ @domain = 'iovip.qbox.me/test'
18
+
19
+ code, data = Qiniu::RS::RS.mkbucket(@bucket)
16
20
  code.should == 200
17
- data.should be_an_instance_of(Hash)
18
- data["access_token"].should_not be_empty
19
- data["refresh_token"].should_not be_empty
20
- data["refresh_token"].should_not be_empty
21
21
  puts data.inspect
22
- =end
22
+ end
23
23
 
24
- code2, data2 = Qiniu::RS::IO.put_auth()
25
- code2.should == 200
26
- data2["url"].should_not be_empty
27
- data2["expiresIn"].should_not be_zero
28
- puts data2.inspect
24
+ context "IO.upload_file" do
25
+ it "should works" do
26
+ code, data = Qiniu::RS::IO.put_auth()
27
+ code.should == 200
28
+ data["url"].should_not be_empty
29
+ data["expiresIn"].should_not be_zero
30
+ puts data.inspect
31
+ @put_url = data["url"]
29
32
 
30
- @put_url = data2["url"]
31
- @bucket = "test"
32
- @key = Digest::SHA1.hexdigest (Time.now.to_i+rand(100)).to_s
33
- @domain = 'cdn.example.com'
33
+ code2, data2 = Qiniu::RS::IO.upload_file(@put_url, __FILE__, @bucket, @key)
34
+ code2.should == 200
35
+ puts data2.inspect
36
+ end
34
37
  end
35
38
 
36
- context "IO.upload_file" do
39
+ context ".buckets" do
37
40
  it "should works" do
38
- code, data = Qiniu::RS::IO.upload_file(@put_url, __FILE__, @bucket, @key)
41
+ code, data = Qiniu::RS::RS.buckets
39
42
  code.should == 200
40
43
  puts data.inspect
41
44
  end
@@ -13,16 +13,69 @@ module Qiniu
13
13
 
14
14
  @test_image_bucket = 'test_images_12345'
15
15
  @test_image_key = 'image_logo_for_test.png'
16
+
17
+ result = Qiniu::RS.mkbucket(@bucket)
18
+ result.should_not be_false
16
19
  end
17
20
 
18
- =begin
19
- context ".login!" do
21
+ context ".buckets" do
20
22
  it "should works" do
21
- result = Qiniu::RS.login!("test@qbox.net", "test")
22
- result.should be_true
23
+ result = Qiniu::RS.buckets
24
+ result.should_not be_false
25
+ puts result.inspect
26
+ end
27
+ end
28
+
29
+ context ".set_protected" do
30
+ it "should works" do
31
+ result = Qiniu::RS.set_protected(@bucket, 1)
32
+ result.should_not be_false
33
+ puts result.inspect
34
+ end
35
+ end
36
+
37
+ context ".set_separator" do
38
+ it "should works" do
39
+ result = Qiniu::RS.set_separator(@bucket, "-")
40
+ result.should_not be_false
41
+ puts result.inspect
42
+ end
43
+ end
44
+
45
+ context ".set_style" do
46
+ it "should works" do
47
+ result = Qiniu::RS.set_style(@bucket, "small.jpg", "imageMogr/auto-orient/thumbnail/!120x120r/gravity/center/crop/!120x120/quality/80")
48
+ result.should_not be_false
49
+ puts result.inspect
50
+ end
51
+ end
52
+
53
+ context ".unset_style" do
54
+ it "should works" do
55
+ result = Qiniu::RS.unset_style(@bucket, "small.jpg")
56
+ result.should_not be_false
57
+ puts result.inspect
58
+ end
59
+ end
60
+
61
+ context ".set_watermark" do
62
+ it "should works" do
63
+ options = {
64
+ :text => "Powered by QiniuRS"
65
+ }
66
+ result = Qiniu::RS.set_watermark(1, options)
67
+ result.should_not be_false
68
+ puts result.inspect
69
+ end
70
+ end
71
+
72
+ context ".get_watermark" do
73
+ it "should works" do
74
+ result = Qiniu::RS.get_watermark(1)
75
+ result.should_not be_false
76
+ puts result.inspect
23
77
  end
24
78
  end
25
- =end
26
79
 
27
80
  context ".put_auth" do
28
81
  it "should works" do
@@ -60,6 +113,22 @@ module Qiniu
60
113
  end
61
114
  end
62
115
 
116
+ context ".upload_file" do
117
+ it "should works" do
118
+ uptoken_opts = {:scope => @bucket, :expires_in => 3600}
119
+ upload_opts = {
120
+ :uptoken => Qiniu::RS.generate_upload_token(uptoken_opts),
121
+ :file => __FILE__,
122
+ :bucket => @bucket,
123
+ :key => @key,
124
+ :enable_crc32_check => true
125
+ }
126
+ result = Qiniu::RS.upload_file(upload_opts)
127
+ result.should_not be_false
128
+ puts result.inspect
129
+ end
130
+ end
131
+
63
132
  context ".stat" do
64
133
  it "should works" do
65
134
  result = Qiniu::RS.stat(@bucket, @key)
@@ -183,6 +252,9 @@ module Qiniu
183
252
  puts data.inspect
184
253
 
185
254
  dest_bucket = "test_thumbnails_bucket"
255
+ result = Qiniu::RS.mkbucket(dest_bucket)
256
+ result.should_not be_false
257
+
186
258
  dest_key = "cropped-" + @test_image_key
187
259
  src_img_url = data["url"]
188
260
  mogrify_options = {
@@ -194,10 +266,10 @@ module Qiniu
194
266
  :format => "jpg",
195
267
  :auto_orient => true
196
268
  }
197
- result = Qiniu::RS.image_mogrify_save_as(dest_bucket, dest_key, src_img_url, mogrify_options)
198
- result.should_not be_false
199
- result.should_not be_empty
200
- puts result.inspect
269
+ result2 = Qiniu::RS.image_mogrify_save_as(dest_bucket, dest_key, src_img_url, mogrify_options)
270
+ result2.should_not be_false
271
+ result2.should_not be_empty
272
+ puts result2.inspect
201
273
  end
202
274
  end
203
275
 
data/spec/spec_helper.rb CHANGED
@@ -6,7 +6,19 @@ require 'rspec'
6
6
 
7
7
  RSpec.configure do |config|
8
8
  config.before :all do
9
+ #=begin
9
10
  Qiniu::RS.establish_connection! :access_key => "3fPHl_SLkPXdioqI_A8_NGngPWVJhlDk2ktRjogH",
10
- :secret_key => "bXTPMDJrVYRJUiSDRFtFYwycVD_mjXxYWrCYlDHy"
11
+ :secret_key => "bXTPMDJrVYRJUiSDRFtFYwycVD_mjXxYWrCYlDHy",
12
+ #=end
13
+ =begin
14
+ Qiniu::RS.establish_connection! :access_key => "bE21M6FW9V7zAFrBY5psgKOKJQLiBj12qMWTpc57",
15
+ :secret_key => "uMo7Nyq_eDK_CuQ8_FYCxoTHQZqjiaPh-cbiKO7L",
16
+ :auth_url => "http://m1.qbox.me:13001/oauth2/token",
17
+ :rs_host => "http://m1.qbox.me:13003",
18
+ :io_host => "http://m1.qbox.me:13004",
19
+ :up_host => "http://m1.qbox.me:13019",
20
+ :pub_host => "http://m1.qbox.me:13012",
21
+ :eu_host => "http://m1.qbox.me:13050"
22
+ =end
11
23
  end
12
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qiniu-rs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 3.0.3
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: 2012-07-28 00:00:00.000000000 Z
12
+ date: 2012-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.9.2.2
21
+ version: '0.9'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 0.9.2.2
29
+ version: '0.9'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rspec
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 2.10.0
37
+ version: '2.11'
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 2.10.0
45
+ version: '2.11'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: fakeweb
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +123,7 @@ dependencies:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
125
  version: 0.4.0
126
- description: ! 'Qiniu Resource (Cloud) Storage SDK for Ruby. See: http://docs.qiniutek.com/v2/sdk/ruby/'
126
+ description: ! 'Qiniu Resource (Cloud) Storage SDK for Ruby. See: http://docs.qiniutek.com/v3/sdk/ruby/'
127
127
  email:
128
128
  - why404@gmail.com
129
129
  executables: []
@@ -143,10 +143,12 @@ files:
143
143
  - lib/qiniu/rs.rb
144
144
  - lib/qiniu/rs/auth.rb
145
145
  - lib/qiniu/rs/config.rb
146
+ - lib/qiniu/rs/eu.rb
146
147
  - lib/qiniu/rs/exceptions.rb
147
148
  - lib/qiniu/rs/image.rb
148
149
  - lib/qiniu/rs/io.rb
149
150
  - lib/qiniu/rs/log.rb
151
+ - lib/qiniu/rs/pub.rb
150
152
  - lib/qiniu/rs/rs.rb
151
153
  - lib/qiniu/rs/utils.rb
152
154
  - lib/qiniu/rs/version.rb
@@ -155,9 +157,11 @@ files:
155
157
  - lib/qiniu/tokens/upload_token.rb
156
158
  - qiniu-rs.gemspec
157
159
  - spec/qiniu/rs/auth_spec.rb
160
+ - spec/qiniu/rs/eu_spec.rb
158
161
  - spec/qiniu/rs/image_logo_for_test.png
159
162
  - spec/qiniu/rs/image_spec.rb
160
163
  - spec/qiniu/rs/io_spec.rb
164
+ - spec/qiniu/rs/pub_spec.rb
161
165
  - spec/qiniu/rs/rs_spec.rb
162
166
  - spec/qiniu/rs/utils_spec.rb
163
167
  - spec/qiniu/rs/version_spec.rb
@@ -177,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
181
  version: '0'
178
182
  segments:
179
183
  - 0
180
- hash: -269804960925193007
184
+ hash: -762983906388000240
181
185
  required_rubygems_version: !ruby/object:Gem::Requirement
182
186
  none: false
183
187
  requirements:
@@ -186,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
190
  version: '0'
187
191
  segments:
188
192
  - 0
189
- hash: -269804960925193007
193
+ hash: -762983906388000240
190
194
  requirements: []
191
195
  rubyforge_project:
192
196
  rubygems_version: 1.8.24
@@ -195,9 +199,11 @@ specification_version: 3
195
199
  summary: Qiniu Resource (Cloud) Storage SDK for Ruby
196
200
  test_files:
197
201
  - spec/qiniu/rs/auth_spec.rb
202
+ - spec/qiniu/rs/eu_spec.rb
198
203
  - spec/qiniu/rs/image_logo_for_test.png
199
204
  - spec/qiniu/rs/image_spec.rb
200
205
  - spec/qiniu/rs/io_spec.rb
206
+ - spec/qiniu/rs/pub_spec.rb
201
207
  - spec/qiniu/rs/rs_spec.rb
202
208
  - spec/qiniu/rs/utils_spec.rb
203
209
  - spec/qiniu/rs/version_spec.rb