Sha256: 619ffe42050ba44356fd577003554a00cafdb6663dfb48c2772a1a4d5624ce70

Contents?: true

Size: 795 Bytes

Versions: 6

Compression:

Stored size: 795 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 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

6 entries across 6 versions & 1 rubygems

Version Path
rubysmith-5.9.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-5.8.1 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-5.8.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-5.7.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-5.6.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-5.5.0 lib/rubysmith/configuration/transformers/template_root.rb