Sha256: 933dffeb219fa954a35edb68906331932838a67fd4441cf65f3860530cae41bd

Contents?: true

Size: 767 Bytes

Versions: 4

Compression:

Stored size: 767 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "refinements/arrays"

module Rubysmith
  module Configuration
    module Transformers
      # Appends custom content to default template roots.
      class TemplateRoot
        include Dry::Monads[:result]

        using Refinements::Arrays

        def initialize default = Pathname(__dir__).join("../../templates")
          @default = default
        end

        def call content
          Array(default).map { |path| Pathname path }
                        .including(content[:template_roots])
                        .compact
                        .then { |paths| Success content.merge!(template_roots: paths) }
        end

        private

        attr_reader :default
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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