Sha256: 3dd43c959e8021e7f53101c7006c2ff3964896d83d049f0296cb9496d8848796

Contents?: true

Size: 793 Bytes

Versions: 8

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

require "dry/monads"
require "refinements/array"

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

        using Refinements::Array

        def initialize key = :template_roots, default: Pathname(__dir__).join("../../templates")
          @key = key
          @default = default
        end

        def call content
          Array(default).map { |path| Pathname path }
                        .including(content[key])
                        .compact
                        .then { |value| Success content.merge!(key => value) }
        end

        private

        attr_reader :key, :default
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rubysmith-6.6.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-6.5.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-6.4.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-6.3.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-6.2.1 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-6.2.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-6.1.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-6.0.0 lib/rubysmith/configuration/transformers/template_root.rb