Sha256: 1387214d4e49347d9036e33ba3e5b8eab87b66396d0da05c50682089d24982cc
Contents?: true
Size: 858 Bytes
Versions: 12
Compression:
Stored size: 858 Bytes
Contents
# frozen_string_literal: true require "dry/monads" module Rubysmith module Configuration module Transformers # Dynamically adds Git user if defined. class GitUser include Import[:git] include Dry::Monads[:result] def call attributes if attributes[:author_given_name] || attributes[:author_family_name] Success attributes else name_or attributes end end private def name_or(attributes) = split(attributes).or { Success attributes } def split attributes git.get("user.name", nil).fmap do |name| next attributes unless name first, last = String(name).split attributes.merge! author_given_name: first, author_family_name: last end end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems