划分出Fop与Misc命名空间。

This commit is contained in:
Liang Tao
2014-03-06 15:33:53 +08:00
parent f1cb65d79a
commit ab81095c0c
7 changed files with 32 additions and 27 deletions
+9 -9
View File
@@ -7,14 +7,14 @@ module Qiniu
autoload :Config, 'qiniu/config'
autoload :Log, 'qiniu/log'
autoload :Exception, 'qiniu/exceptions'
autoload :Pub, 'qiniu/pub'
autoload :Image, 'qiniu/image'
autoload :AccessToken, 'qiniu/tokens/access_token'
autoload :QboxToken, 'qiniu/tokens/qbox_token'
autoload :UploadToken, 'qiniu/tokens/upload_token'
autoload :DownloadToken, 'qiniu/tokens/download_token'
autoload :Abstract, 'qiniu/abstract'
autoload :Storage, 'qiniu/storage'
autoload :Fop, 'qiniu/fop'
autoload :Misc, 'qiniu/misc'
class << self
@@ -35,22 +35,22 @@ module Qiniu
end
def set_protected(bucket, protected_mode)
code, data = Pub.set_protected(bucket, protected_mode)
code, data = Misc.set_protected(bucket, protected_mode)
code == StatusOK
end
def set_separator(bucket, separator)
code, data = Pub.set_separator(bucket, separator)
code, data = Misc.set_separator(bucket, separator)
code == StatusOK
end
def set_style(bucket, name, style)
code, data = Pub.set_style(bucket, name, style)
code, data = Misc.set_style(bucket, name, style)
code == StatusOK
end
def unset_style(bucket, name)
code, data = Pub.unset_style(bucket, name)
code, data = Misc.unset_style(bucket, name)
code == StatusOK
end
@@ -182,17 +182,17 @@ module Qiniu
end
def image_info(url)
code, data = Image.info(url)
code, data = Fop::Image.info(url)
code == StatusOK ? data : false
end
def image_exif(url)
code, data = Image.exif(url)
code, data = Fop::Image.exif(url)
code == StatusOK ? data : false
end
def image_mogrify_preview_url(source_image_url, options)
Image.mogrify_preview_url(source_image_url, options)
Fop::Image.mogrify_preview_url(source_image_url, options)
end
def image_mogrify_save_as(bucket, key, source_image_url, options)
+3
View File
@@ -0,0 +1,3 @@
# -*- encoding: utf-8 -*-
require 'qiniu/image'
+2
View File
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
module Qiniu
module Fop
module Image
class << self
include Utils
@@ -33,4 +34,5 @@ module Qiniu
end
end # module Image
end # module Fop
end # module Qiniu
+1 -1
View File
@@ -90,7 +90,7 @@ module Qiniu
end # save_as
def image_mogrify_save_as(bucket, key, source_image_url, options)
mogrify_params_string = Image.generate_mogrify_params_string(options)
mogrify_params_string = Fop::Image.generate_mogrify_params_string(options)
save_as(bucket, key, source_image_url, mogrify_params_string)
end # image_mogrify_save_as
+2 -2
View File
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
module Qiniu
module Pub
module Misc
class << self
include Utils
@@ -30,6 +30,6 @@ module Qiniu
end
end
end # module Pub
end # module Misc
end # module Qiniu
+7 -7
View File
@@ -3,11 +3,11 @@
require 'spec_helper'
require 'qiniu/auth'
require 'qiniu'
require 'qiniu/image'
require 'qiniu/fop'
module Qiniu
module Image
describe Image do
module Fop
describe Fop do
before :all do
@@ -60,7 +60,7 @@ module Qiniu
context ".info" do
it "should works" do
code, data = Qiniu::Image.info(@source_image_url)
code, data = Qiniu::Fop::Image.info(@source_image_url)
code.should == 200
puts data.inspect
end
@@ -69,7 +69,7 @@ module Qiniu
=begin
context ".exif" do
it "should works" do
code, data = Qiniu::Image.exif(@source_image_url)
code, data = Qiniu::Fop::Image.exif(@source_image_url)
puts data.inspect
end
end
@@ -77,11 +77,11 @@ module Qiniu
context ".mogrify_preview_url" do
it "should works" do
mogrify_preview_url = Qiniu::Image.mogrify_preview_url(@source_image_url, @mogrify_options)
mogrify_preview_url = Qiniu::Fop::Image.mogrify_preview_url(@source_image_url, @mogrify_options)
puts mogrify_preview_url.inspect
end
end
end
end # module Image
end # module Fop
end # module Qiniu
@@ -3,11 +3,11 @@
require 'spec_helper'
require 'qiniu/auth'
require 'qiniu'
require 'qiniu/pub'
require 'qiniu/misc'
module Qiniu
module Pub
describe Pub do
module Misc
describe Misc do
before :all do
@bucket = 'RubySdkTest' + (Time.now.to_i+rand(1000)).to_s
@@ -24,7 +24,7 @@ module Qiniu
context ".set_protected" do
it "should works" do
code, data = Qiniu::Pub.set_protected(@bucket, 1)
code, data = Qiniu::Misc.set_protected(@bucket, 1)
code.should == 200
puts data.inspect
end
@@ -32,7 +32,7 @@ module Qiniu
context ".set_separator" do
it "should works" do
code, data = Qiniu::Pub.set_separator(@bucket, "-")
code, data = Qiniu::Misc.set_separator(@bucket, "-")
code.should == 200
puts data.inspect
end
@@ -40,7 +40,7 @@ module Qiniu
context ".set_style" do
it "should works" do
code, data = Qiniu::Pub.set_style(@bucket, "small.jpg", "imageMogr/auto-orient/thumbnail/!120x120r/gravity/center/crop/!120x120/quality/80")
code, data = Qiniu::Misc.set_style(@bucket, "small.jpg", "imageMogr/auto-orient/thumbnail/!120x120r/gravity/center/crop/!120x120/quality/80")
code.should == 200
puts data.inspect
end
@@ -48,12 +48,12 @@ module Qiniu
context ".unset_style" do
it "should works" do
code, data = Qiniu::Pub.unset_style(@bucket, "small.jpg")
code, data = Qiniu::Misc.unset_style(@bucket, "small.jpg")
code.should == 200
puts data.inspect
end
end
end
end # module Pub
end # module Misc
end # module Qiniu