mailmap 0.1.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 584d60df1c3057edf1c979959458b13eb2dbceb6e9bbf3654bf0619c06446d86
4
- data.tar.gz: 7608f1b15f967216efc0a5832e71fd569ea3873de42f2b3c228b02a52d1c2809
3
+ metadata.gz: d659e60a379065bd575a324d915c318d797f23aecfddf90e9c06486c737813fd
4
+ data.tar.gz: 6fc69c39af05df32d2f21239f4aee331b50dae610b6e71aacaefbe21db3ce6c8
5
5
  SHA512:
6
- metadata.gz: 73665faa795d942fc8a5becca8607675b9750e095d7f46edcfc6a95e07c34f18feb9b4b8c698dfdcaf8d60df3afc74544d85a26b30a01c792e23db3bc3c334aa
7
- data.tar.gz: bcb90879d1d7cda6ff780635d2c7e97a712ada42b9e7d00f4093214ed90ec337e903fc6ce7dae2ca31c8be644a033f1f5bdd2747f824dbc165c9a72f523c5352
6
+ metadata.gz: e5f8d9ed92f6e40525ee41c6b54fe459ea427c3df589e978a80b7a8dcbafbf91707c590e001493c31a71c3f98c600db058aef7580e2107e2ba3452fe20d5414b
7
+ data.tar.gz: '08d9415b709f531e9532bd89698a7a3cac9fdee485061a9ebd42d4daee32f17c2b39c674cde06f5cc0b460518d71ab04a96f9bd056b5509b4785878a477ff22b'
data/lib/mailmap/map.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'forwardable'
4
3
  require 'strscan'
5
4
 
6
5
  module Mailmap
@@ -10,9 +9,7 @@ module Mailmap
10
9
 
11
10
  # A Map represents a .mailmap file.
12
11
  class Map
13
- extend Forwardable
14
-
15
- def_delegators :each, *Enumerable.instance_methods(false)
12
+ include Enumerable
16
13
 
17
14
  class << self
18
15
  # Load a mailmap file and return Map object.
@@ -28,18 +25,20 @@ module Mailmap
28
25
 
29
26
  # @param string [String] the string in .mailmap format
30
27
  def initialize(string)
28
+ # @type ivar @map: Hash[String, Hash[String?, String?]]
31
29
  @map = Hash.new { |h, k| h[k] = {} }
32
30
  parse(string)
33
31
  end
34
32
 
35
33
  def each
36
- return enum_for(:each) unless block_given?
34
+ return enum_for unless block_given?
37
35
 
38
36
  @map.each do |commit_email, entries_by_commit_name|
39
37
  entries_by_commit_name.each do |commit_name, (proper_name, proper_email)|
40
- yield [proper_name, proper_email, commit_name, commit_email]
38
+ yield proper_name, proper_email, commit_name, commit_email
41
39
  end
42
40
  end
41
+ self
43
42
  end
44
43
 
45
44
  # Look up the person's canonical name and email address.
@@ -47,7 +46,9 @@ module Mailmap
47
46
  #
48
47
  # @param commit_name_or_nil [String, nil] the name in commit or nil
49
48
  # @param commit_email [String] the name in commit
50
- # @return [Array<String>] if found, a pair of proper name and email or nil
49
+ # @return [(String, String)] if found, a pair of proper name and email
50
+ # @return [(String, nil)] if only proper name is found
51
+ # @return [(nil, String)] if only proper email is found
51
52
  # @return [nil] if not found
52
53
  def lookup(commit_name_or_nil, commit_email)
53
54
  commit_name = commit_name_or_nil&.downcase
@@ -56,12 +57,13 @@ module Mailmap
56
57
  hash[commit_name] || hash[nil]
57
58
  end
58
59
 
59
- # Like `git-check-mailmap` command, look up the person's canonical name and email address.
60
+ # Like +git-check-mailmap+ command, look up the person's canonical name and email address.
60
61
  # If found, return them; otherwise return the input as-is.
61
62
  #
62
63
  # @param commit_name_or_nil [String, nil] the name in commit or nil
63
64
  # @param commit_email [String] the email in commit
64
- # @return [Array<String>] a pair of proper name and email
65
+ # @return [(String, String)] a pair of proper name and email
66
+ # @return [(nil, String)] if proper name is not found and +commit_name+ is not provided
65
67
  def resolve(commit_name_or_nil, commit_email)
66
68
  proper_name, proper_email = lookup(commit_name_or_nil, commit_email)
67
69
  proper_name ||= commit_name_or_nil
@@ -76,7 +78,7 @@ module Mailmap
76
78
  # @return [Boolean]
77
79
  def include_name?(name)
78
80
  name = name.downcase
79
- any? do |(proper_name, _proper_email, commit_name, _commit_email)|
81
+ any? do |proper_name, _proper_email, commit_name, _commit_email|
80
82
  proper_name&.downcase == name || commit_name == name
81
83
  end
82
84
  end
@@ -88,7 +90,7 @@ module Mailmap
88
90
  # @return [Boolean]
89
91
  def include_email?(email)
90
92
  email = email.downcase
91
- any? do |(_proper_name, proper_email, _commit_name, commit_email)|
93
+ any? do |_proper_name, proper_email, _commit_name, commit_email|
92
94
  proper_email&.downcase == email || commit_email == email
93
95
  end
94
96
  end
@@ -104,7 +106,9 @@ module Mailmap
104
106
  end
105
107
 
106
108
  def parse_name_and_email(line, line_number) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
109
+ # @type var names: Array[String]
107
110
  names = []
111
+ # @type var emails: Array[String]
108
112
  emails = []
109
113
  scanner = StringScanner.new(line)
110
114
  2.times do
@@ -114,9 +118,9 @@ module Mailmap
114
118
  scanner.scan(/[^>]+/).then { |s| emails << s if s }
115
119
  scanner.skip(/>/)
116
120
  end
117
- raise ParserError, "Missing commit email at line #{line_number}" if emails.empty?
118
-
119
121
  commit_email = emails.pop&.downcase
122
+ raise ParserError, "Missing commit email at line #{line_number}" unless commit_email
123
+
120
124
  proper_email = emails.pop
121
125
  proper_name = names.shift
122
126
  commit_name = names.shift&.downcase
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mailmap
4
- VERSION = '0.1.1'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryosuke Ito
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-07 00:00:00.000000000 Z
11
+ date: 2023-03-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parser for Git Mailmap (.mailmap)
14
14
  email:
@@ -27,7 +27,7 @@ metadata:
27
27
  rubygems_mfa_required: 'true'
28
28
  homepage_uri: https://github.com/manicmaniac/mailmap
29
29
  source_code_uri: https://github.com/manicmaniac/mailmap
30
- post_install_message:
30
+ post_install_message:
31
31
  rdoc_options: []
32
32
  require_paths:
33
33
  - lib
@@ -35,15 +35,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
35
35
  requirements:
36
36
  - - ">="
37
37
  - !ruby/object:Gem::Version
38
- version: 2.6.0
38
+ version: 2.7.0
39
39
  required_rubygems_version: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  requirements: []
45
- rubygems_version: 3.0.3.1
46
- signing_key:
45
+ rubygems_version: 3.4.6
46
+ signing_key:
47
47
  specification_version: 4
48
48
  summary: Parser for Git Mailmap (.mailmap)
49
49
  test_files: []