Class: UpyunRainbow::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/upyun-rainbow/upyun-rainbow.rb

Instance Method Summary collapse

Constructor Details

#initialize(bucket = nil, user = nil, pwd = nil, api_host = "http://v0.api.upyun.com") ⇒ Util

Returns a new instance of Util.



11
12
13
14
15
16
# File 'lib/upyun-rainbow/upyun-rainbow.rb', line 11

def initialize bucket=nil, user=nil, pwd=nil, api_host="http://v0.api.upyun.com" 
  @api_host = api_host || configatron.upaiyun.api_host
  @bucket   = bucket   || configatron.upaiyun.bucket_name
  @user     = user     || configatron.upaiyun.user_name
  @password = pwd      || configatron.upaiyun.password
end

Instance Method Details

#delete(url, options = {}) ⇒ Object



33
34
35
36
# File 'lib/upyun-rainbow/upyun-rainbow.rb', line 33

def delete url, options={}
  relative_path = get_relative_path url
  result = process :delete, relative_path, options 
end

#get(url, options = {}) ⇒ Object



18
19
20
21
# File 'lib/upyun-rainbow/upyun-rainbow.rb', line 18

def get url, options={}
  relative_path = get_relative_path url
  result = process :get, relative_path, options
end

#post(url, data, options = {}) ⇒ Object



28
29
30
31
# File 'lib/upyun-rainbow/upyun-rainbow.rb', line 28

def post url, data, options={}
  relative_path = get_relative_path url
  result = process :post, relative_path, data, {'Expect' => '', 'Mkdir' => 'true'}.merge(options) 
end

#put(url, data, options = {}) ⇒ Object



23
24
25
26
# File 'lib/upyun-rainbow/upyun-rainbow.rb', line 23

def put url, data, options={}
  relative_path = get_relative_path url
  result = process :put, relative_path, data, options
end