Class: Git::Lint::Parsers::Trailers::Collaborator
- Inherits:
-
Object
- Object
- Git::Lint::Parsers::Trailers::Collaborator
- Defined in:
- lib/git/lint/parsers/trailers/collaborator.rb
Constant Summary collapse
- DEFAULT_KEY_PATTERN =
/\ACo.*Authored.*By.*\Z/i
- DEFAULT_MATCH_PATTERN =
/ (?<key>\A.+) # Key (anchored to start of line). (?<delimiter>:) # Key delimiter. (?<key_space>\s?) # Space delimiter (optional). (?<name>.*?) # Collaborator name (smallest possible). (?<name_space>\s?) # Space delimiter (optional). (?<email><.+>)? # Collaborator email (optional). \Z # End of line. /x
Instance Method Summary collapse
- #email ⇒ Object
-
#initialize(text, key_pattern: DEFAULT_KEY_PATTERN, match_pattern: DEFAULT_MATCH_PATTERN) ⇒ Collaborator
constructor
A new instance of Collaborator.
- #key ⇒ Object
- #match? ⇒ Boolean
- #name ⇒ Object
Constructor Details
#initialize(text, key_pattern: DEFAULT_KEY_PATTERN, match_pattern: DEFAULT_MATCH_PATTERN) ⇒ Collaborator
Returns a new instance of Collaborator.
20 21 22 23 24 25 26 27 28 |
# File 'lib/git/lint/parsers/trailers/collaborator.rb', line 20 def initialize text, key_pattern: DEFAULT_KEY_PATTERN, match_pattern: DEFAULT_MATCH_PATTERN @text = String text @key_pattern = key_pattern @match_pattern = match_pattern @matches = build_matches end |
Instance Method Details
#email ⇒ Object
38 39 40 |
# File 'lib/git/lint/parsers/trailers/collaborator.rb', line 38 def email String(matches["email"]).delete_prefix("<").delete_suffix(">") end |
#key ⇒ Object
30 31 32 |
# File 'lib/git/lint/parsers/trailers/collaborator.rb', line 30 def key String matches["key"] end |
#match? ⇒ Boolean
42 43 44 |
# File 'lib/git/lint/parsers/trailers/collaborator.rb', line 42 def match? text.match? key_pattern end |
#name ⇒ Object
34 35 36 |
# File 'lib/git/lint/parsers/trailers/collaborator.rb', line 34 def name String matches["name"] end |