7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/cerberus/publisher/rss.rb', line 7
def self.publish(state, manager, options)
config = options[:publisher, :rss]
subject,body = Cerberus::Publisher::Base.formatted_message(state, manager, options)
pub_date = Time.now
begin
feed = RSS::Parser.parse(File.read(config[:file]), false)
raise RSS::Error unless feed
keep = config[:keep] || 1
feed.items.slice!(keep -1 ..-1) rescue RSS::Error, Errno::ENOENT
feed = RSS::Maker.make("2.0") do ||
.channel.title = "#{options[:application_name].to_xs} build status"
.channel.description = "Cerberus build feed for #{options[:application_name].to_xs}"
.channel.generator = "http://rubyforge.org/projects/cerberus"
.channel.link = config[:channel_link] || "file://#{config[:file]}"
end
end
feed.channel.link = config[:channel_link] unless config[:channel_link].nil?
feed.channel.pubDate = pub_date
new_item = RSS::Rss::Channel::Item.new()
new_item.title = subject
new_item.pubDate = pub_date
new_item.description = "<pre>#{body}</pre>"
feed.items.unshift new_item
IO.write(config[:file], feed)
end
|