Sha256: 91bd314e55c5543667426a49f6da8a85aa2d36c3d225230aad040b6be70c3e57
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true require "refinements/strings" require "refinements/structs" module Rubysmith module Builders # Builds project skeleton core structure and minimum file support. class Core using Refinements::Strings using Refinements::Structs def self.call(...) = new(...).call def initialize configuration, builder: Builder @configuration = configuration @builder = builder end def call render_implementation render_specification configuration end private def render_implementation builder.call(configuration.merge(template_path: "%project_name%/lib/%project_path%.rb.erb")) .render .replace(" require", "require") .replace(/ (?=(Zeit|loader|end))/, "") .replace("\n \n", "\n\n") .insert_before("module #{module_name}", "#{indentation}# Main namespace.\n") end def render_specification return unless configuration.build_zeitwerk path = "%project_name%/spec/lib/%project_path%_spec.rb.erb" builder.call(configuration.merge(template_path: path)).render end def indentation = ::Core::EMPTY_STRING.indent configuration.project_levels def module_name = configuration.project_class attr_reader :configuration, :builder end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubysmith-5.9.0 | lib/rubysmith/builders/core.rb |