module Qiniu::Config
Attributes
default_params[R]
host_manager[R]
settings[R]
Public Class Methods
fetch_host(bucket, opts = {})
click to toggle source
# File lib/qiniu/config.rb, line 57 def fetch_host(bucket, opts = {}) @settings[:fetch_host] || @host_manager.fetch_host(bucket, opts) end
initialize_connect(options = {})
click to toggle source
# File lib/qiniu/config.rb, line 27 def initialize_connect options = {} options = if options[:protocol] == :https https_options.merge(options) else http_options.merge(options) end @settings = default_options.merge(options) required_options_keys.each do |opt| raise MissingArgsError, [opt] unless @settings.has_key?(opt) end @host_manager = HostManager.new(@settings) nil end
initialize_connect_https(options = {})
click to toggle source
# File lib/qiniu/config.rb, line 41 def initialize_connect_https options = {} initialize_connect(options.merge(:protocol => :https)) end
load(config_file)
click to toggle source
# File lib/qiniu/config.rb, line 17 def load config_file if File.exist?(config_file) config_options = YAML.load_file(config_file) config_options.symbolize_keys! initialize_connect(config_options) else raise MissingConfError, config_file end end
switch_to_http()
click to toggle source
# File lib/qiniu/config.rb, line 45 def switch_to_http @settings.merge!(http_options) end
switch_to_https()
click to toggle source
# File lib/qiniu/config.rb, line 49 def switch_to_https @settings.merge!(https_options) end
up_host(bucket, opts = {})
click to toggle source
# File lib/qiniu/config.rb, line 53 def up_host(bucket, opts = {}) @settings[:up_host] || @host_manager.up_host(bucket, opts) end
Private Class Methods
default_options()
click to toggle source
# File lib/qiniu/config.rb, line 63 def default_options { :user_agent => 'QiniuRuby/' + Version.to_s + ' ('+RUBY_PLATFORM+')' + ' Ruby/'+ RUBY_VERSION, :method => :post, :content_type => 'application/x-www-form-urlencoded', :auth_url => "https://acc.qbox.me/oauth2/token", :access_key => "", :secret_key => "", :auto_reconnect => true, :max_retry_times => 3, :block_size => 1024*1024*4, :chunk_size => 1024*256, :enable_debug => true, :tmpdir => Dir.tmpdir + File::SEPARATOR + 'QiniuRuby', :multi_region => true }.freeze end
http_options()
click to toggle source
# File lib/qiniu/config.rb, line 81 def http_options { :rs_host => "http://rs.qiniu.com", :rsf_host => "http://rsf.qbox.me", :pub_host => "http://pu.qbox.me:10200", :eu_host => "http://eu.qbox.me", :uc_host => "http://uc.qbox.me", :api_host => "http://api.qiniu.com", :protocol => :http }.freeze end
https_options()
click to toggle source
# File lib/qiniu/config.rb, line 93 def https_options { :rs_host => "https://rs.qbox.me", :rsf_host => "https://rsf.qbox.me", :pub_host => "https://pu.qbox.me", :eu_host => "https://eu.qbox.me", :uc_host => "https://uc.qbox.me", :api_host => "https://api.qiniu.com", :protocol => :https }.freeze end
required_options_keys()
click to toggle source
# File lib/qiniu/config.rb, line 105 def required_options_keys [:access_key, :secret_key].freeze end