Class: Rubysmith::Builders::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/rubysmith/builders/core.rb

Overview

Builds project skeleton core structure and minimum file support.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, builder: Builder) ⇒ Core

Returns a new instance of Core.



15
16
17
18
# File 'lib/rubysmith/builders/core.rb', line 15

def initialize configuration, builder: Builder
  @configuration = configuration
  @builder = builder
end

Class Method Details

.callObject



13
# File 'lib/rubysmith/builders/core.rb', line 13

def self.call(...) = new(...).call

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubysmith/builders/core.rb', line 20

def call
  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")
         .replace("end\n  end", "    end\n  end")

  configuration
end