class Bake::Modernize::License::Mailmap
Represents a mailmap file which maps commit emails to proper names.
def self.for(root)
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)
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)
def extract_from_line(line) line.match(PATTERN) end
def initialize
def initialize @names = {} end