Sha256: 9b4bbd6b11320935ecc58abf4f759237f6e051fb06dd235fd5dd36692e8b2226
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'rexml/document' require 'rexml/streamlistener' module OhlohScm::Parsers class SubversionListener include REXML::StreamListener attr_accessor :callback def initialize(callback) @callback = callback end attr_accessor :text, :commit, :diff def tag_start(name, attrs) case name when 'logentry' @commit = Scm::Commit.new @commit.diffs = [] @commit.token = attrs['revision'].to_i when 'path' @diff = Scm::Diff.new(:action => attrs['action'], :from_path => attrs['copyfrom-path'], :from_revision => attrs['copyfrom-rev'].to_i) end end def tag_end(name) case name when 'logentry' @callback.call(@commit) when 'author' @commit.committer_name = @text when 'date' @commit.committer_date = Time.parse(@text).round.utc when 'path' @diff.path = @text @commit.diffs << @diff when 'msg' @commit.message = @text end end def text(text) @text = text end end class SvnXmlParser < Parser def self.internal_parse(buffer, opts) buffer = '<?xml?>' if buffer.is_a?(StringIO) and buffer.length < 2 begin REXML::Document.parse_stream(buffer, SubversionListener.new(Proc.new { |c| yield c if block_given? })) rescue EOFError end end def self.scm 'svn' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ohloh_scm-2.0.0 | lib/ohloh_scm/parsers/svn_xml_parser.rb |