Sha256: 92100076d81c0985669f217309fd9e5aa8c898fe7ef41cb6f4c900d20ea6bf81

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

module DamageControl
  module Visitor
    # Visitor that writes RSS for ChangeSets.
    class RssWriter

      # Creates a new RssWriter that will populate the +rss+
      # object when it is accepted by a ChangeSets object.
      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

      def visit_changesets(changesets)
        @rss.channel.title = @title
        @rss.channel.link = @link
        @rss.channel.description = @description
        @rss.channel.generator = "RSCM - Ruby Source Control Management"
      end

      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

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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
damagecontrol-0.5.0 lib/damagecontrol/visitor/rss_writer.rb