class Bake::Modernize::License::Mailmap

Represents a mailmap file which maps commit emails to proper names.

def self.for(root)

Load the mailmap from a directory.
def self.for(root)
	full_path = File.join(root, ".mailmap")
	
	if File.exist?(full_path)
		mailmap = self.new
		mailmap.extract(full_path)
		return mailmap
	end
end

def extract(path)

Extract the mailmap from the given path.
def extract(path)
	File.open(path, "r") do |file|
		file.each_line do |line|
			# Skip comments
			next if line =~ /^#/
			# Skip empty lines
			next if line =~ /^\s*$/
			# Parse line
			
			
			user = extract_from_line(line)
			if commit_email = user[:commit_email] and proper_name = user[:proper_name]
				@names[commit_email] = proper_name
			end
		end
	end
end

def extract_from_line(line)

Extract the mailmap format from a line of input.
def extract_from_line(line)
	line.match(PATTERN)
end

def initialize

Create a new, empty, mailmap.
def initialize
	@names = {}
end