class OhlohScm::BzrXmlParser

Constants

NAME_REGEX

Public Class Methods

capture_name(text) click to toggle source

Bazaar expects committer/author to be specified in this format Name <email>, or John Doe <jdoe@example.com> However, we find many variations in the real world including ones where only email is specified as name.

# File lib/ohloh_scm/parser/bzr_xml_parser.rb, line 161
def self.capture_name(text)
  parts = text.match(NAME_REGEX).to_a
  name = parts[1] || parts[0]
  email = parts[3]
  [name, email]
end
internal_parse(buffer, _) { |c| ... } click to toggle source
# File lib/ohloh_scm/parser/bzr_xml_parser.rb, line 129
def self.internal_parse(buffer, _)
  buffer = '<?xml?>' if buffer.is_a?(StringIO) && buffer.length < 2
  REXML::Document.parse_stream(buffer,
                               BazaarListener.new(proc { |c| yield c if block_given? }))
rescue EOFError => e
  puts e.message
end
remove_dupes(diffs) click to toggle source

rubocop:disable Metrics/AbcSize

# File lib/ohloh_scm/parser/bzr_xml_parser.rb, line 142
def self.remove_dupes(diffs)
  # Bazaar may report that a file was added and modified in a single commit.
  # Reduce these cases to a single 'A' action.
  diffs.delete_if do |d|
    d.action == 'M' && diffs.select { |x| x.path == d.path && x.action == 'A' }.any?
  end

  # Bazaar may report that a file was both deleted and added in a single commit.
  # Reduce these cases to a single 'M' action.
  diffs.each do |d|
    d.action = 'M' if diffs.select { |x| x.path == d.path }.size > 1
  end.uniq
end
scm() click to toggle source
# File lib/ohloh_scm/parser/bzr_xml_parser.rb, line 137
def self.scm
  'bzr'
end