Sha256: c922cdab0266fe63df7c235b190225c97c9af11b1a105e13dd3d35d5d4c8c36f

Contents?: true

Size: 675 Bytes

Versions: 9

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

require "gitt"
require "refinements/strings"
require "refinements/structs"

module Rubysmith
  module Configuration
    # Dynamically adds Git user if defined.
    module Enhancers
      using Refinements::Strings
      using Refinements::Structs

      GitUser = lambda do |content, git: Gitt::Repository.new|
        return content unless String(content.author_name).blank?

        git.get("user.name")
           .value_or("")
           .then { |name| String(name).split }
           .then { |first, last| {author_given_name: first, author_family_name: last} }
           .then { |user| content.merge(**user) }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubysmith-4.9.0 lib/rubysmith/configuration/enhancers/git_user.rb
rubysmith-4.8.0 lib/rubysmith/configuration/enhancers/git_user.rb
rubysmith-4.7.0 lib/rubysmith/configuration/enhancers/git_user.rb
rubysmith-4.6.1 lib/rubysmith/configuration/enhancers/git_user.rb
rubysmith-4.6.0 lib/rubysmith/configuration/enhancers/git_user.rb
rubysmith-4.5.0 lib/rubysmith/configuration/enhancers/git_user.rb
rubysmith-4.4.0 lib/rubysmith/configuration/enhancers/git_user.rb
rubysmith-4.3.0 lib/rubysmith/configuration/enhancers/git_user.rb
rubysmith-4.2.0 lib/rubysmith/configuration/enhancers/git_user.rb