Jeff is a light-weight module that mixes in client behaviour for Amazon Web Services (AWS). It wraps Excon, parses with Nokogiri, and implements Signature Version 2.
Build a a hypothetical client.
class Client
include Jeff
end
Customise default headers and parameters.
class Client
headers 'User-Agent' => 'Client'
params 'Service' => 'SomeService',
'Tag' => -> { tag }
attr_accessor :tag
end
Set an AWS endpoint and credentials.
client = Client.new.tap do |config|
config.endpoint = 'http://example.com/path'
config.key = 'key'
config.secret = 'secret'
end
You should now be able to access the endpoint.
res = client.post query: {},
body: 'data'
puts res.status # => 200
puts res.body.root # => { 'Foo' => 'Bar' }
You can upload large files performantly by passing a proc that delivers chunks.
file = File.open 'data'
chunker = -> { file.read Excon::CHUNK_SIZE).to_s }
client.post query: {},
request_block: chunker
Jeff is compatible with all Ruby 1.9 flavours.