lib/feed_cache.rb in feed_cache-0.0.1 vs lib/feed_cache.rb in feed_cache-0.1.0

- old
+ new

@@ -1,9 +1,11 @@ module FeedCache DEFAULT_ENTRIES_LIMIT = 10 DEFAULT_EXPIRES_IN = 900 + class MissingEntries < StandardError; end + class << self attr_accessor :cache attr_writer :default_entries_limit, :default_expires_in def default_entries_limit @@ -26,11 +28,15 @@ feed.valid_feed? ? feed : nil end def self.entries_for(url, options = {}) limit = options.delete(:limit) || default_entries_limit - feed = fetch(url, options) - (feed ? feed.entries : []).take(limit) + begin + feed = fetch(url, options) + (feed ? feed.entries : []).take(limit) + rescue TypeError + raise FeedCache::MissingEntries + end end end require File.expand_path("feed_cache/fetcher", File.dirname(__FILE__)) require File.expand_path("feed_cache/version", File.dirname(__FILE__))