Class: MKBrut::Base

Inherits:
Object
  • Object
show all
Includes:
MKBrut
Defined in:
lib/mkbrut/base.rb

Overview

Constructs the base of any Brut app.

Defined Under Namespace

Classes: ErbBinding

Constant Summary

Constants included from MKBrut

VERSION

Instance Method Summary collapse

Constructor Details

#initialize(app_options:, current_dir:, templates_dir:) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
# File 'lib/mkbrut/base.rb', line 11

def initialize(app_options:, current_dir:, templates_dir:)
  @project_root  = current_dir / app_options.app_name
  @templates_dir = templates_dir / "Base"
  @erb_binding   = ErbBinding.new(app_options)
end

Instance Method Details

#create!Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mkbrut/base.rb', line 17

def create!
  if @project_root.exist?
    raise "Project root #{@project_root} already exists"
  end
  operations = [ Ops::Mkdir.new(@project_root) ]           + 
                 copy_files(@templates_dir, @project_root)

  operations.each do |operation|
    operation.call
  end
end