Class: Myzofeedtosis::Client
- Inherits:
-
Object
- Object
- Myzofeedtosis::Client
- 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' } }
- @@backends =
{}
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#fetch ⇒ Object
Retrieves the latest entries from this feed.
-
#initialize(url, options = { }) ⇒ Client
constructor
Initializes a new myzofeedtosis library.
Constructor Details
#initialize(url, options = { }) ⇒ Client
Initializes a new myzofeedtosis library. The backend can be a hash of options, in which case we initialize a new HashBack::Backend. Or, it may be a pre-initialized backend, in which case we set the backend to the given HashBack::Backend object.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/myzofeedtosis/client.rb', line 23 def initialize(url, = { }) @url = url if [:backend].is_a?(HashBack::Backend) @backend = [:backend] else = DEFAULTS.merge(.dup) @backend = HashBack::Backend.new( 'Myzofeedtosis', [:backend][:moneta_klass], [:backend].except(:moneta_klass) ) end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/myzofeedtosis/client.rb', line 10 def end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/myzofeedtosis/client.rb', line 10 def url @url end |
Instance Method Details
#fetch ⇒ Object
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.
38 39 40 41 42 43 |
# File 'lib/myzofeedtosis/client.rb', line 38 def fetch curl = build_curl_easy curl.perform feed = process_curl_response(curl) Myzofeedtosis::Result.new(curl, feed) end |