Class: Genit::RssFeed

Inherits:
Object
  • Object
show all
Defined in:
lib/genit/project/rss_feed.rb

Overview

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.

Instance Method Summary collapse

Constructor Details

#initialize(working_dir, news_files, config) ⇒ RssFeed

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)



18
19
20
21
22
23
# File 'lib/genit/project/rss_feed.rb', line 18

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

Instance Method Details

#generate_rssObject

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



27
28
29
30
31
32
33
# File 'lib/genit/project/rss_feed.rb', line 27

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