Module: Svn2rss
- Defined in:
- lib/svn2rss.rb,
lib/svn2rss/version.rb
Overview
:nodoc:
Defined Under Namespace
Modules: VERSION Classes: LogEntry
Instance Method Summary collapse
- #createRSSFeed(log, feed_url, feed_title, feed_description, language, managingEditor, webmaster, verbose = nil) ⇒ Object
-
#parseSvnLog(url, limit = 10, verbose = false) ⇒ Object
Parses the SVN log located at the given URL.
Instance Method Details
#createRSSFeed(log, feed_url, feed_title, feed_description, language, managingEditor, webmaster, verbose = nil) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/svn2rss.rb', line 55 def createRSSFeed(log, feed_url, feed_title, feed_description, language, managingEditor, webmaster, verbose = nil) raise Exception("The log variable is null!") if log.nil? puts "Starting..." if verbose xml = Builder::XmlMarkup.new(:indent => 2) xml.instruct! xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do xml.channel do xml.title feed_title xml.link feed_url xml.description feed_description xml.language language xml.pubDate Time.parse(Time.now.to_s).rfc822 xml.lastBuildDate Time.parse(Time.now.to_s).rfc822 xml.docs "http://cyber.law.harvard.edu/rss/rss.html" xml.generator "svn2rss #{ENV['SVN2RSS_VERSION']}" xml.managingEditor managingEditor xml.webMaster webmaster guid = feed_url guid << "/" if !/\/$/.match(guid) puts "Created the channel" if verbose for entry in log xml.item do xml.title "Revision #{entry.revision} by #{entry.}: #{entry.msg}" xml.link guid + "#" + entry.revision if entry.diff xml.description entry.diff else xml.description "No diff available" end xml.pubDate Time.parse(entry.date).rfc822 xml.guid guid + "#" + entry.revision puts "Created an entry" if verbose end end end end puts xml.target! if verbose xml.target! end |
#parseSvnLog(url, limit = 10, verbose = false) ⇒ Object
Parses the SVN log located at the given URL. You cans et some options: verbose: the function will have more output limit: the number of items that should be parsed.
Example:
parseSvnLog(“svn2rss.rubyforge.org/svn2rss/svn”, :verbose => true, :limit => 2)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/svn2rss.rb', line 27 def parseSvnLog(url, limit = 10, verbose = false) batchcommand = "svn log " + url batchcommand += " --limit " + limit.to_s batchcommand += " --xml" # easier to parse puts batchcommand if verbose log = XmlSimple.xml_in(%x[#{batchcommand}]) entries = Array.new log['logentry'].each do |entry| logEntry = LogEntry.new logEntry.revision = entry['revision'] logEntry. = entry['author'][0] logEntry.date = entry['date'][0] logEntry.msg = entry['msg'][0] previousRevision = logEntry.revision.to_i previousRevision = previousRevision - 1 puts "svn diff #{url} -r #{logEntry.revision}:#{previousRevision.to_s}" if verbose logEntry.diff = %x[svn diff #{url} -r #{logEntry.revision}:#{previousRevision.to_s}] if previousRevision > 0 if (logEntry.diff) logEntry.diff.gsub!(/</,"<" ) # transform the current tag brackets by lt and gt so that they will be rendered with amp, and shown in the feed. logEntry.diff.gsub!(/>/,">" ) logEntry.diff.gsub!(/\n/,"<br/>\n" ) # have the br tags with brackets, so that it will be interpreted by Google Reader. puts logEntry.diff if verbose end entries << logEntry end entries end |