Sha256: 6b9083f48ef09588e0a3183ac0980d73fabccd4ffd641f8297802f741e1921c9

Contents?: true

Size: 799 Bytes

Versions: 12

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

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

module Rubysmith
  module Configuration
    module Transformers
      # Appends custom path 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 attributes
          Array(default).map { |path| Pathname path }
                        .including(attributes[key])
                        .compact
                        .then { |value| Success attributes.merge!(key => value) }
        end

        private

        attr_reader :key, :default
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rubysmith-7.9.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-7.8.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-7.7.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-7.6.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-7.5.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-7.4.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-7.3.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-7.2.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-7.1.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-7.0.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-6.10.0 lib/rubysmith/configuration/transformers/template_root.rb
rubysmith-6.9.0 lib/rubysmith/configuration/transformers/template_root.rb