diff --git a/Gemfile.lock b/Gemfile.lock index aaba350..f88b6d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - qiniu-rs (3.3.0) + qiniu-rs (3.3.1) json (~> 1.7) mime-types (~> 1.19) rest-client (~> 1.6) diff --git a/lib/qiniu/rs/version.rb b/lib/qiniu/rs/version.rb index 0e5cf34..0ddef51 100755 --- a/lib/qiniu/rs/version.rb +++ b/lib/qiniu/rs/version.rb @@ -5,7 +5,7 @@ module Qiniu module Version MAJOR = 3 MINOR = 3 - PATCH = 0 + PATCH = 1 # Returns a version string by joining MAJOR, MINOR, and PATCH with '.' # # Example diff --git a/spec/qiniu/rs/eu_spec.rb b/spec/qiniu/rs/eu_spec.rb index 979a276..5e5894a 100755 --- a/spec/qiniu/rs/eu_spec.rb +++ b/spec/qiniu/rs/eu_spec.rb @@ -10,8 +10,8 @@ module Qiniu describe EU do before :all do - @customer_id = "awhy.xu@gmail.com" - @bucket = "wm_test_bucket" + @customer_id = "why404@gmail.com" + @bucket = 'RubySdkTest' + (Time.now.to_i+rand(1000)).to_s @key = "image_logo_for_test.png" result = Qiniu::RS.mkbucket(@bucket) @@ -35,7 +35,6 @@ module Qiniu end after :all do - @bucket = "wm_test_bucket" result = Qiniu::RS.drop(@bucket) puts result.inspect result.should_not be_false diff --git a/spec/qiniu/rs/image_spec.rb b/spec/qiniu/rs/image_spec.rb index b65f463..1da498c 100755 --- a/spec/qiniu/rs/image_spec.rb +++ b/spec/qiniu/rs/image_spec.rb @@ -11,7 +11,7 @@ module Qiniu before :all do - @bucket = "test_images_12345" + @bucket = 'RubySdkTest' + (Time.now.to_i+rand(1000)).to_s @key = "image_logo_for_test.png" result = Qiniu::RS.mkbucket(@bucket) @@ -20,7 +20,7 @@ module Qiniu local_file = File.expand_path('../' + @key, __FILE__) - upopts = {:scope => @bucket, :expires_in => 3600, :customer => "awhy.xu@gmail.com"} + upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"} uptoken = Qiniu::RS.generate_upload_token(upopts) data = Qiniu::RS.upload_file :uptoken => uptoken, :file => local_file, :bucket => @bucket, :key => @key puts data.inspect @@ -42,7 +42,6 @@ module Qiniu end after :all do - @bucket = "test_images_12345" result = Qiniu::RS.drop(@bucket) puts result.inspect result.should_not be_false diff --git a/spec/qiniu/rs/io_spec.rb b/spec/qiniu/rs/io_spec.rb index 05ce823..51075b9 100755 --- a/spec/qiniu/rs/io_spec.rb +++ b/spec/qiniu/rs/io_spec.rb @@ -10,7 +10,7 @@ module Qiniu describe IO do before :all do - @bucket = "io_test_bucket" + @bucket = 'RubySdkTest' + (Time.now.to_i+rand(1000)).to_s @key = Digest::SHA1.hexdigest((Time.now.to_i+rand(100)).to_s) result = Qiniu::RS.mkbucket(@bucket) @@ -19,7 +19,6 @@ module Qiniu end after :all do - @bucket = "io_test_bucket" result = Qiniu::RS.drop(@bucket) puts result.inspect result.should_not be_false @@ -48,7 +47,7 @@ module Qiniu context ".upload_with_token" do it "should works" do - upopts = {:scope => @bucket, :expires_in => 3600, :customer => "awhy.xu@gmail.com"} + upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"} uptoken = Qiniu::RS.generate_upload_token(upopts) code, data = Qiniu::RS::IO.upload_with_token(uptoken, __FILE__, @bucket, @key, nil, nil, nil, true) code.should == 200 diff --git a/spec/qiniu/rs/pub_spec.rb b/spec/qiniu/rs/pub_spec.rb index 3fd3a88..1addab7 100755 --- a/spec/qiniu/rs/pub_spec.rb +++ b/spec/qiniu/rs/pub_spec.rb @@ -10,14 +10,13 @@ module Qiniu describe Pub do before :all do - @bucket = "pub_test_bucket" + @bucket = 'RubySdkTest' + (Time.now.to_i+rand(1000)).to_s result = Qiniu::RS.mkbucket(@bucket) puts result.inspect result.should_not be_false end after :all do - @bucket = "pub_test_bucket" result = Qiniu::RS.drop(@bucket) puts result.inspect result.should_not be_false diff --git a/spec/qiniu/rs/rs_spec.rb b/spec/qiniu/rs/rs_spec.rb index ca7ea91..123c990 100755 --- a/spec/qiniu/rs/rs_spec.rb +++ b/spec/qiniu/rs/rs_spec.rb @@ -11,9 +11,9 @@ module Qiniu describe RS do before :all do - @bucket = "rs_test_bucket" + @bucket = 'RubySdkTest' + (Time.now.to_i+rand(1000)).to_s @key = Digest::SHA1.hexdigest((Time.now.to_i+rand(100)).to_s) - @domain = 'rs-test-bucket.dn.qbox.me' + #@domain = @bucket + '.dn.qbox.me' code, data = Qiniu::RS::RS.mkbucket(@bucket) puts [code, data].inspect @@ -21,7 +21,6 @@ module Qiniu end after :all do - @bucket = "rs_test_bucket" code, data = Qiniu::RS::RS.drop(@bucket) puts [code, data].inspect code.should == 200 @@ -90,6 +89,7 @@ module Qiniu end end +=begin context ".publish" do it "should works" do code, data = Qiniu::RS::RS.publish(@domain, @bucket) @@ -105,6 +105,7 @@ module Qiniu puts data.inspect end end +=end context ".delete" do it "should works" do diff --git a/spec/qiniu/rs/up_spec.rb b/spec/qiniu/rs/up_spec.rb index 28e6736..91b0849 100755 --- a/spec/qiniu/rs/up_spec.rb +++ b/spec/qiniu/rs/up_spec.rb @@ -12,7 +12,7 @@ module Qiniu before :all do @localfile = "bigfile.txt" File.open(@localfile, "w"){|f| 5242888.times{f.write(rand(9).to_s)}} - @bucket = "up_test_bucket" + @bucket = 'RubySdkTest' + (Time.now.to_i+rand(1000)).to_s @key = Digest::SHA1.hexdigest(@localfile+Time.now.to_s) code, data = Qiniu::RS::RS.mkbucket(@bucket) @@ -30,7 +30,7 @@ module Qiniu context ".upload_with_token" do it "should works" do - upopts = {:scope => @bucket, :expires_in => 3600, :customer => "awhy.xu@gmail.com"} + upopts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com"} uptoken = Qiniu::RS.generate_upload_token(upopts) code, data = Qiniu::RS::UP.upload_with_token(uptoken, @localfile, @bucket, @key) puts data.inspect diff --git a/spec/qiniu/rs_spec.rb b/spec/qiniu/rs_spec.rb index 1e7f87e..d6fdab1 100755 --- a/spec/qiniu/rs_spec.rb +++ b/spec/qiniu/rs_spec.rb @@ -9,14 +9,14 @@ module Qiniu describe RS do before :all do - @bucket = 'qiniu_rs_test' + @bucket = 'RubySdkTest' + (Time.now.to_i+rand(1000)).to_s @key = Digest::SHA1.hexdigest Time.now.to_s - @domain = 'qiniu-rs-test.dn.qbox.me' + #@domain = @bucket + '.dn.qbox.me' result = Qiniu::RS.mkbucket(@bucket) result.should_not be_false - @test_image_bucket = 'test_images_12345' + @test_image_bucket = 'RubySdkTest' + (Time.now.to_i+rand(1000)).to_s result2 = Qiniu::RS.mkbucket(@test_image_bucket) puts result2.inspect result2.should be_true @@ -24,15 +24,15 @@ module Qiniu @test_image_key = 'image_logo_for_test.png' local_file = File.expand_path('./rs/' + @test_image_key, File.dirname(__FILE__)) puts local_file.inspect - upopts = {:scope => @test_image_bucket, :expires_in => 3600, :customer => "awhy.xu@gmail.com"} + upopts = {:scope => @test_image_bucket, :expires_in => 3600, :customer => "why404@gmail.com"} uptoken = Qiniu::RS.generate_upload_token(upopts) data = Qiniu::RS.upload_file :uptoken => uptoken, :file => local_file, :bucket => @test_image_bucket, :key => @test_image_key puts data.inspect end after :all do - result = Qiniu::RS.unpublish(@domain) - result.should_not be_false + #result = Qiniu::RS.unpublish(@domain) + #result.should_not be_false result1 = Qiniu::RS.drop(@bucket) puts result1.inspect @@ -186,7 +186,7 @@ module Qiniu File.open(localfile, "w"){|f| 5242888.times{f.write(rand(9).to_s)}} key = Digest::SHA1.hexdigest(localfile+Time.now.to_s) # generate the upload token - uptoken_opts = {:scope => @bucket, :expires_in => 3600, :customer => "awhy.xu@gmail.com", :escape => 0} + uptoken_opts = {:scope => @bucket, :expires_in => 3600, :customer => "why404@gmail.com", :escape => 0} uptoken = Qiniu::RS.generate_upload_token(uptoken_opts) # uploading upload_opts = { @@ -277,12 +277,14 @@ module Qiniu end end +=begin context ".publish" do it "should works" do result = Qiniu::RS.publish(@domain, @bucket) result.should_not be_false end end +=end =begin context ".unpublish" do @@ -338,10 +340,6 @@ module Qiniu data.should_not be_empty puts data.inspect - dest_bucket = "test_thumbnails_bucket" - result = Qiniu::RS.mkbucket(dest_bucket) - result.should_not be_false - dest_key = "cropped-" + @test_image_key src_img_url = data["url"] mogrify_options = { @@ -353,7 +351,7 @@ module Qiniu :format => "jpg", :auto_orient => true } - result2 = Qiniu::RS.image_mogrify_save_as(dest_bucket, dest_key, src_img_url, mogrify_options) + result2 = Qiniu::RS.image_mogrify_save_as(@test_image_bucket, dest_key, src_img_url, mogrify_options) result2.should_not be_false result2.should_not be_empty puts result2.inspect @@ -362,7 +360,7 @@ module Qiniu context ".generate_upload_token" do it "should works" do - data = Qiniu::RS.generate_upload_token({:scope => 'test_bucket', :expires_in => 3600, :escape => 0}) + data = Qiniu::RS.generate_upload_token({:scope => @bucket, :expires_in => 3600, :escape => 0}) data.should_not be_empty puts data.inspect data.split(":").length.should == 3 @@ -371,7 +369,7 @@ module Qiniu context ".generate_download_token" do it "should works" do - data = Qiniu::RS.generate_download_token({:expires_in => 1, :pattern => 'http://qiniu-rs-test.dn.qbox.me/*'}) + data = Qiniu::RS.generate_download_token({:expires_in => 1, :pattern => 'http://*.dn.qbox.me/*'}) data.should_not be_empty puts data.inspect data.split(":").length.should == 3