lib/rubysmith/configuration/transformers/template_root.rb in rubysmith-5.0.1 vs lib/rubysmith/configuration/transformers/template_root.rb in rubysmith-5.1.0
- old
+ new
@@ -3,20 +3,30 @@
require "dry/monads"
require "refinements/arrays"
module Rubysmith
module Configuration
- # Prepends template roots to existing content.
module Transformers
- include Dry::Monads[:result]
+ # Appends custom content to default template roots.
+ class TemplateRoot
+ include Dry::Monads[:result]
- using Refinements::Arrays
+ using Refinements::Arrays
- TemplateRoot = lambda do |content, overrides: Pathname(__dir__).join("../../templates")|
- Array(overrides).map { |path| Pathname path }
+ 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| Dry::Monads::Success content.merge!(template_roots: paths) }
+ .then { |paths| Success content.merge!(template_roots: paths) }
+ end
+
+ private
+
+ attr_reader :default
end
end
end
end