Skip to content

Latest commit

 

History

History
73 lines (53 loc) · 1.53 KB

README.md

File metadata and controls

73 lines (53 loc) · 1.53 KB

Jeff

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.

jeff

Usage

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' }

Chunked Requests

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

Compatibility

Jeff is compatible with all Ruby 1.9 flavours.