Module: Gitt::Models

Defined in:
lib/gitt/models/tag.rb,
lib/gitt/models/commit.rb,
lib/gitt/models/person.rb,
lib/gitt/models/trailer.rb

Defined Under Namespace

Classes: Commit, Tag

Constant Summary collapse

Person =

Represents a person within a repository.

Data.define :name, :delimiter, :email do
  def self.for(string, parser: Parsers::Person.new) = parser.call string

  def initialize name: nil, delimiter: " ", email: nil
    super
  end

  def to_s
    case self
      in String, String, String then "#{name}#{delimiter}<#{email}>"
      in String, String, nil then name
      in nil, String, String then "<#{email}>"
      else Core::EMPTY_STRING
    end
  end
end
Trailer =

Represents commit trailer details.

Data.define :key, :delimiter, :space, :value do
  def self.for(string, parser: Parsers::Trailer.new) = parser.call string

  def initialize key:, value:, delimiter: ":", space: " "
    super
  end

  def empty? = String(key).empty? || String(value).empty?

  def to_s = to_h.values.join
end