Sha256: f2b7a88ff6fbd9139214a87e87d1eb825c821f03bc33482a9935d9bd1f8dc00c

Contents?: true

Size: 594 Bytes

Versions: 1

Compression:

Stored size: 594 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 content
          return Success content if content[:author_given_name] || content[:author_family_name]

          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.1.0 lib/rubysmith/configuration/transformers/git_user.rb