Class: Gitt::Parsers::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/gitt/parsers/commit.rb

Overview

Parses raw commit to produce a commit record.

Instance Method Summary collapse

Constructor Details

#initialize(attributer: Attributer.new(Commands::Log::KEY_MAP.keys.append(:statistics)), sanitizers: Sanitizers::CONTAINER, model: Models::Commit) ⇒ Commit

Returns a new instance of Commit.



11
12
13
14
15
16
17
# File 'lib/gitt/parsers/commit.rb', line 11

def initialize attributer: Attributer.new(Commands::Log::KEY_MAP.keys.append(:statistics)),
               sanitizers: Sanitizers::CONTAINER,
               model: Models::Commit
  @attributer = attributer
  @sanitizers = sanitizers
  @model = model
end

Instance Method Details

#call(content) ⇒ Object



19
20
21
22
23
# File 'lib/gitt/parsers/commit.rb', line 19

def call content
  attributer.call(content)
            .then { |attributes| mutate attributes }
            .then { |attributes| model[**attributes] }
end