Loads a feed within a block for more consistent syntax and control over the FeedTools environment.
# File lib/feed_tools/helpers/feed_tools_helper.rb, line 50 def with_feed(options={}) FeedTools::GenericHelper.validate_options([ :from_file, :from_url, :from_data, :feed_cache ], options.keys) options = { :feed_cache => FeedTools.configurations[:feed_cache] }.merge(options) if options[:from_file] file_path = File.expand_path(@@default_local_path + '/' + options[:from_file]) if !File.exists?(file_path) file_path = File.expand_path(options[:from_file]) end if !File.exists?(file_path) raise "No such file - #{file_path}" end feed = FeedTools::Feed.open("file://#{file_path}") elsif options[:from_url] feed = FeedTools::Feed.open(options[:from_url]) elsif options[:from_data] feed = FeedTools::Feed.new feed.feed_data = options[:from_data] else raise "No data source specified" end @@save_cache = FeedTools.configurations[:feed_cache].to_s FeedTools.configurations[:feed_cache] = options[:feed_cache].to_s yield feed FeedTools.configurations[:feed_cache] = @@save_cache feed = nil end
Generated with the Darkfish Rdoc Generator 2.