Class: Bake::Modernize::License::Mailmap
- Inherits:
-
Object
- Object
- Bake::Modernize::License::Mailmap
- Defined in:
- lib/bake/modernize/license.rb
Overview
Represents a mailmap file which maps commit emails to proper names.
Constant Summary collapse
- PATTERN =
Format: Proper Name <proper@email.xx> Commit Name <commit@email.xx>
/ (?<proper_name>[^<]+)? (\s+<(?<proper_email>[^>]+)>)? (\s+(?<commit_name>[^<]+)?)? \s+<(?<commit_email>[^>]+)> /x
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
- #The mapping of commit emails to proper names.(mappingofcommitemailstopropernames.) ⇒ Object readonly
Class Method Summary collapse
-
.for(root) ⇒ Object
Load the mailmap from a directory.
Instance Method Summary collapse
-
#extract(path) ⇒ Object
Extract the mailmap from the given path.
-
#extract_from_line(line) ⇒ Object
Extract the mailmap format from a line of input.
-
#initialize ⇒ Mailmap
constructor
Create a new, empty, mailmap.
Constructor Details
#initialize ⇒ Mailmap
Create a new, empty, mailmap.
67 68 69 |
# File 'lib/bake/modernize/license.rb', line 67 def initialize @names = {} end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
72 73 74 |
# File 'lib/bake/modernize/license.rb', line 72 def names @names end |
#The mapping of commit emails to proper names.(mappingofcommitemailstopropernames.) ⇒ Object (readonly)
72 |
# File 'lib/bake/modernize/license.rb', line 72 attr :names |
Class Method Details
Instance Method Details
#extract(path) ⇒ Object
Extract the mailmap from the given path.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/bake/modernize/license.rb', line 75 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 |
#extract_from_line(line) ⇒ Object
Extract the mailmap format from a line of input.
102 103 104 |
# File 'lib/bake/modernize/license.rb', line 102 def extract_from_line(line) line.match(PATTERN) end |