Sha256: 367be59d4dfb24c9b576c557bf7ee618aaaf98c2078fd87e5306f08511f48f1a

Contents?: true

Size: 596 Bytes

Versions: 3

Compression:

Stored size: 596 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"

module Rubysmith
  module Configuration
    module Transformers
      # Dynamically adds GitHub user if user is defined.
      class GitHubUser
        include Import[:git]
        include Dry::Monads[:result]

        def call(content) = content[:git_hub_user] ? Success(content) : user_or(content)

        private

        def user_or content
          git.get("github.user", nil)
             .fmap { |user| user ? content.merge!(git_hub_user: user) : content }
             .or { Success content }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubysmith-5.4.0 lib/rubysmith/configuration/transformers/git_hub_user.rb
rubysmith-5.3.0 lib/rubysmith/configuration/transformers/git_hub_user.rb
rubysmith-5.2.0 lib/rubysmith/configuration/transformers/git_hub_user.rb