Sha256: e73dab090e33d0043eea09a5bab7973bac76fb66cbfc1fc2589a659df227b433

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "gitt"

module Rubysmith
  module Configuration
    # Dynamically adds Git user if defined.
    module Transformers
      include Dry::Monads[:result]

      GitUser = lambda do |content, git: Gitt::Repository.new|
        if content[:author_given_name] || content[:author_family_name]
          Dry::Monads::Success content
        else
          git.get("user.name").fmap do |name|
            first, last = String(name).split
            content.merge author_given_name: first, author_family_name: last
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubysmith-5.0.1 lib/rubysmith/configuration/transformers/git_user.rb