update excon, pass a block instead of params[:block]

This commit is contained in:
geemus 2010-05-09 16:23:03 -07:00
Родитель 1a1985db25
Коммит 242d7a5088
7 изменённых файлов: 58 добавлений и 57 удалений

Просмотреть файл

@ -1,7 +1,7 @@
source 'http://gemcutter.org'
gem 'rake'
gem 'excon', '>= 0.0.21'
gem 'excon', '>= 0.0.22'
gem 'formatador', ">= 0.0.10"
gem 'json', ">= 0"
gem 'mime-types', ">= 0"

Просмотреть файл

@ -1,15 +1,56 @@
---
dependencies:
formatador:
group:
- :default
version: ">= 0.0.10"
rake:
group:
- :default
version: ">= 0"
ruby-hmac:
group:
- :default
version: ">= 0"
mime-types:
group:
- :default
version: ">= 0"
rspec:
group:
- :default
version: ">= 0"
net-ssh:
group:
- :default
version: ">= 0"
json:
group:
- :default
version: ">= 0"
excon:
group:
- :default
version: ">= 0.0.22"
shindo:
group:
- :default
version: ">= 0"
nokogiri:
group:
- :default
version: ">= 0"
specs:
- rake:
version: 0.8.7
- excon:
version: 0.0.21
version: 0.0.22
- formatador:
version: 0.0.14
- gestalt:
version: 0.0.6
- json:
version: 1.4.2
version: 1.4.3
- mime-types:
version: "1.16"
- net-ssh:
@ -22,48 +63,7 @@ specs:
version: 0.4.0
- shindo:
version: 0.0.18
hash: e443f12a9a7794f2ff4fc8e8d201b12b1e8b30bb
hash: a39d842433b002231eebfd269d32fe72b489b62f
sources:
- Rubygems:
uri: http://gemcutter.org
dependencies:
formatador:
version: ">= 0.0.10"
group:
- :default
nokogiri:
version: ">= 0"
group:
- :default
rake:
version: ">= 0"
group:
- :default
rspec:
version: ">= 0"
group:
- :default
ruby-hmac:
version: ">= 0"
group:
- :default
mime-types:
version: ">= 0"
group:
- :default
net-ssh:
version: ">= 0"
group:
- :default
json:
version: ">= 0"
group:
- :default
excon:
version: ">= 0.0.21"
group:
- :default
shindo:
version: ">= 0"
group:
- :default

Просмотреть файл

@ -34,14 +34,13 @@ module Fog
headers['If-Unmodified-Since'] = options['If-Unmodified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since']
headers.merge!(options)
request({
:block => block,
:expects => 200,
:headers => headers,
:host => "#{bucket_name}.#{@host}",
:idempotent => true,
:method => 'GET',
:path => CGI.escape(object_name)
})
}, &block)
end
def get_object_url(bucket_name, object_name, expires)

Просмотреть файл

@ -141,12 +141,12 @@ module Fog
private
def request(params)
def request(params, &block)
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
params[:headers]['Date'] = Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S +0000")
params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}"
response = @connection.request(params)
response = @connection.request(params, &block)
response
end

Просмотреть файл

@ -5,13 +5,15 @@ module Fog
@excon = Excon.new(url)
end
def request(params)
if parser = params.delete(:parser)
body = Nokogiri::XML::SAX::PushParser.new(parser)
params[:block] = lambda { |chunk| body << chunk }
def request(params, &block)
unless block_given?
if (parser = params.delete(:parser))
body = Nokogiri::XML::SAX::PushParser.new(parser)
block = lambda { |chunk| body << chunk }
end
end
response = @excon.request(params)
response = @excon.request(params, &block)
if parser
body.finish

Просмотреть файл

@ -112,7 +112,7 @@ module Fog
response
end
def storage_request(params, parse_json = true)
def storage_request(params, parse_json = true, &block)
@storage_connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}")
response = @storage_connection.request({
:body => params[:body],
@ -125,7 +125,7 @@ module Fog
:method => params[:method],
:path => "#{@storage_path}/#{params[:path]}",
:query => params[:query]
})
}, &block)
if !response.body.empty? && parse_json
response.body = JSON.parse(response.body)
end

Просмотреть файл

@ -15,7 +15,7 @@ module Fog
:expects => 200,
:method => 'GET',
:path => "#{CGI.escape(container)}/#{CGI.escape(object)}"
}, false)
}, false, &block)
response
end