Module: Love

Defined in:
lib/love.rb

Overview

Love is a small Ruby library to interact with the Tender REST API. The main object to work with is Client, which is returned by calling Love.connect.

It is dedicated to the awesome work Aaeron Patterson has been giving to the Ruby community.

Defined Under Namespace

Modules: ResourceURI Classes: Client, Exception, NotFound, Unauthorized

Constant Summary collapse

VERSION =

The current gem version. Will be updated automatically by the gem release script.

"0.0.5"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.connect(site, api_key, options = {}) {|Love::Client| ... } ⇒ Object .connect(site, api_key, options = {}) ⇒ Love::Client

Connects to the Tender API to access a site using an API key.

This method doesn’t do any communication yet with the Tender API, it will only set up the client with the provided credentials and options.

By default, the client will use a new connection for every request. It can also open a persistent connection if you want to do multiple requests, by passing :persistent => true as option. In this case, you need to call Love::Client#close_connection when you are done with your session. You can also provide a block to this method which will automatically open up a persistent connection and close it at the end of the block.

Overloads:

  • .connect(site, api_key, options = {}) {|Love::Client| ... } ⇒ Object

    Returns The return value of the block. The persistent connection will be closed.

    Yields:

    • (Love::Client)

      An API client to work with using a persistent connection.

    Returns:

    • The return value of the block. The persistent connection will be closed

  • .connect(site, api_key, options = {}) ⇒ Love::Client

    Returns An API client to work with. By default, the returned client will not use a persistent TCP connection, so a new connection will be.

    Returns:

    • (Love::Client)

      An API client to work with. By default, the returned client will not use a persistent TCP connection, so a new connection will be

Parameters:

  • site (String)

    The site to work with.

  • api_key (String)

    The API key for this site.

  • options (Hash) (defaults to: {})

    Connectivity options.

Options Hash (options):

  • :persistent (Boolean) — default: false

    Whether to create a persistent TCP connection.

  • :sleep_between_requests (Float) — default: 0.5

    The time between requests in seconds.

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/love.rb', line 52

def self.connect(site, api_key, options = {}, &block)
  if block_given?
    begin
      client = Love::Client.new(site, api_key, options.merge(:persistent => true))
      block.call(client)
    ensure
      client.close_connection
    end
  else
    Love::Client.new(site, api_key, options)
  end
end

Instance Method Details

#loggerLogger

HTTP connectivity somewhere.

Returns:

  • (Logger)

    Set this attribute to a Logger instance to log the



67
# File 'lib/love.rb', line 67

mattr_accessor :logger