Class: Myzofeedtosis::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/myzofeedtosis/client.rb

Overview

Myzofeedtosis::Client is the primary interface to the feed reader. Call it with a url that was previously fetched while connected to the configured backend, and it will 1) only do a retrieval if deemed necessary based on the etag and modified-at of the last etag and 2) mark all entries retrieved as either new or not new. Entries retrieved are normalized using the feed-normalizer gem.

Constant Summary collapse

DEFAULTS =
{
  :backend => {
    :moneta_klass => 'Moneta::Memory'
  }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = { }) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
23
24
25
# File 'lib/myzofeedtosis/client.rb', line 18

def initialize(url, options = { })
  @url      = url
  @options  = DEFAULTS.merge(options)
  
  @backend  = HashBack::Backend.new( 'Myzofeedtosis', 
                @options[:backend][:moneta_klass], 
                @options[:backend].except(:moneta_klass) )
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/myzofeedtosis/client.rb', line 10

def options
  @options
end

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/myzofeedtosis/client.rb', line 10

def url
  @url
end

Instance Method Details

#fetchObject

Retrieves the latest entries from this feed. Returns a Myzofeedtosis::Result object which delegates methods to the Curl::Easy object making the request and the FeedNormalizer::Feed object that may have been created from the HTTP response body.



31
32
33
34
35
36
# File 'lib/myzofeedtosis/client.rb', line 31

def fetch
  curl = build_curl_easy
  curl.perform
  feed = process_curl_response(curl)
  Myzofeedtosis::Result.new(curl, feed)
end