Skip to content

Commit

Permalink
Initial typhoeus adapter implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Saher El-Neklawy committed Dec 1, 2012
1 parent 0610910 commit 9b133ef
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ group :development, :test do

# gem 'nokogiri'
end

gem 'typhoeus', '~> 0.4.2'
7 changes: 6 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ GIT
PATH
remote: .
specs:
uber-s3 (0.2.3)
uber-s3 (0.2.4)
mime-types (~> 1.17)

GEM
Expand All @@ -33,6 +33,7 @@ GEM
eventmachine (>= 1.0.0.beta.4)
eventmachine (1.0.0.beta.4)
eventmachine (1.0.0.beta.4-java)
ffi (1.1.5)
http_parser.rb (0.5.3)
http_parser.rb (0.5.3-java)
method_source (0.7.1)
Expand All @@ -59,6 +60,9 @@ GEM
rspec-mocks (2.7.0)
slop (2.4.4)
spoon (0.0.1)
typhoeus (0.4.2)
ffi (~> 1.0)
mime-types (~> 1.18)

PLATFORMS
java
Expand All @@ -72,4 +76,5 @@ DEPENDENCIES
pry-nav
rake
rspec (~> 2.7.0)
typhoeus (~> 0.4.2)
uber-s3!
28 changes: 28 additions & 0 deletions lib/uber-s3/connection/typhoeus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'typhoeus'

HYDRA = ::Typhoeus::Hydra.new

module UberS3::Connection
class Typhoeus < Adapter

def request(verb, url, headers={}, body=nil)
# TODO: see extra steps done in NET::HTTP adapter
params = {}
params[:headers] = headers
params[:method] = verb.to_sym
params[:body] = body if body

r = ::Typhoeus::Request.new(url, params)
HYDRA.queue(r)
HYDRA.run

UberS3::Response.new({
:status => r.response.code,
:header => r.response.headers,
:body => r.response.body,
:raw => r.response
})
end

end
end

0 comments on commit 9b133ef

Please sign in to comment.