Class: DamageControl::Visitor::RssWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/damagecontrol/visitor/rss_writer.rb

Overview

Visitor that writes RSS for ChangeSets.

Instance Method Summary collapse

Constructor Details

#initialize(rss, title, link, description, message_linker, change_linker) ⇒ RssWriter

Creates a new RssWriter that will populate the rss object when it is accepted by a ChangeSets object.



8
9
10
11
12
13
14
15
16
# File 'lib/damagecontrol/visitor/rss_writer.rb', line 8

def initialize(rss, title, link, description, message_linker, change_linker)
  raise "title" unless title
  raise "link" unless link
  raise "description" unless description
  raise "message_linker" unless message_linker
  raise "change_linker" unless change_linker

  @rss, @title, @link, @description, @message_linker, @change_linker = rss, title, link, description, message_linker, change_linker
end

Instance Method Details

#visit_change(change) ⇒ Object



37
38
39
# File 'lib/damagecontrol/visitor/rss_writer.rb', line 37

def visit_change(change)
  @item.description << @change_linker.change_url(change, true) << "<br/>\n"
end

#visit_changeset(changeset) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/damagecontrol/visitor/rss_writer.rb', line 25

def visit_changeset(changeset)
  @item = @rss.items.new_item

  @item.pubDate = changeset.time
  @item.author = changeset.developer
  @item.title = changeset.message
  @item.link = @change_linker.changeset_url(changeset, true)

  @item.description = "<b>#{changeset.developer}</b><br/>\n"
  @item.description << @message_linker.highlight(changeset.message).gsub(/\n/, "<br/>\n") << "<p/>\n"
end

#visit_changesets(changesets) ⇒ Object



18
19
20
21
22
23
# File 'lib/damagecontrol/visitor/rss_writer.rb', line 18

def visit_changesets(changesets)
  @rss.channel.title = @title
  @rss.channel.link = @link
  @rss.channel.description = @description
  @rss.channel.generator = "DamageControl"
end