Class/Module Index [+]

Quicksearch

FeedTools::FeedToolsHelper

Public Class Methods

default_local_path() click to toggle source

Returns the default path to load local files from

# File lib/feed_tools/helpers/feed_tools_helper.rb, line 38
def self.default_local_path
  @@default_local_path
end
default_local_path=(new_default_local_path) click to toggle source

Sets the default path to load local files from

# File lib/feed_tools/helpers/feed_tools_helper.rb, line 43
def self.default_local_path=(new_default_local_path)
  @@default_local_path = new_default_local_path
end

Protected Instance Methods

with_feed(options={}) click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.