Sha256: 00984a6c7fa1b8833600618b2e2fc5648935014a96cd7546a454760088be75e3

Contents?: true

Size: 1.29 KB

Versions: 36

Compression:

Stored size: 1.29 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 = OhlohScm::Commit.new
				@commit.diffs = []
				@commit.token = attrs['revision'].to_i
			when 'path'
				@diff = OhlohScm::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

36 entries across 36 versions & 1 rubygems

Version Path
ohloh_scm-2.5.1 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.14 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.13 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.12 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.11 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.10 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.9 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.8 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.7 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.6 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.5 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.4 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.3 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.1 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.4.0 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.3.5 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.3.4 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.3.2 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.3.1 lib/ohloh_scm/parsers/svn_xml_parser.rb
ohloh_scm-2.3.0 lib/ohloh_scm/parsers/svn_xml_parser.rb