class Genit::RssFeed

RssFeed could generate the RSS (version 2.0) file of the project. To generate the RSS file, we need data from the project config file (.config) and the list of the news.

Public Class Methods

new(working_dir, news_files, config) click to toggle source

Public: Constructor.

working_dir - The String working directory, where live the project. news_files - An Array filled with the full path name

of the news files

config - A Hash representing the project config file (.config)

# File lib/genit/project/rss_feed.rb, line 17
def initialize working_dir, news_files, config
  @working_dir = working_dir
  @news_files = news_files
  @config = config
  @destination = File.join(@working_dir, 'rss.xml')
end

Public Instance Methods

generate_rss() click to toggle source

Public: Generate the RSS file (named rss.xml) at the web site root (www/).

# File lib/genit/project/rss_feed.rb, line 26
def generate_rss
  content = RSS::Maker.make("2.0") do |feed|
    RssFeedMeta.fill feed, @config
    RssFeedItems.new(feed, @news_files, @config).fill
  end
  File.open(@destination, "w") { |file| file.write(content) }
end