Class: Gitt::Parsers::Trailer
- Inherits:
-
Object
- Object
- Gitt::Parsers::Trailer
- Defined in:
- lib/gitt/parsers/trailer.rb
Overview
Parses raw trailer data to produce a trailer record.
Constant Summary collapse
- PATTERN =
/ \A # Start of line. (?<key>[a-zA-Z\-]+) # Key. (?<delimiter>:) # Delimiter (colon). (?<space>\s?) # Space (optional). (?<value>.*?) # Value. \Z # End of line. /x
- EMPTY =
Models::Trailer[key: nil, value: nil]
Instance Method Summary collapse
- #call(content) ⇒ Object
-
#initialize(pattern: PATTERN, model: Models::Trailer, empty: EMPTY) ⇒ Trailer
constructor
A new instance of Trailer.
Constructor Details
Instance Method Details
#call(content) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/gitt/parsers/trailer.rb', line 24 def call content return empty if content.start_with? "#" content.match(pattern) .then { |data| data ? model[**data.named_captures(symbolize_names: true)] : empty } end |