Class: Munola::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/munola/installer.rb

Defined Under Namespace

Classes: Report

Instance Method Summary collapse

Constructor Details

#initialize(root, tenant_column: nil, binary: nil, stderr: $stderr) ⇒ Installer

Returns a new instance of Installer.



18
19
20
21
22
23
24
# File 'lib/munola/installer.rb', line 18

def initialize(root, tenant_column: nil, binary: nil, stderr: $stderr)
  @root = File.expand_path(root)
  @tenant_column = tenant_column
  @binary = binary
  @stderr = stderr
  @report = Report.new(written: [], bound: [], commented: [], notes: [])
end

Instance Method Details

#installObject

The Rails layer first (starter laws, the binary's own init, upstream's recipes commented), then what only munola carries: the catalogue, the bindings the tree justifies, the providers both on by default. enola-rb carries the installer this reuses; it is required here rather than at load time so require "munola" stays a wrapper and pulls in no Rails machinery for a project that only drives the binary.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/munola/installer.rb', line 32

def install
  require "enola-rb"
  rails = EnolaRb::Installer.new(@root, binary: resolved_binary, stderr: @stderr).install
  @report.written.concat(rails.written)
  @report.notes.concat(rails.notes)

  detector = Detector.new(@root)
  tenant = detector.tenant(column: @tenant_column)
  values = tenant&.table ? { column: tenant.column, table: tenant.table } : nil
  @report.written.concat(Catalogue.write(@root, tenant: values).map { |p| relative(p) })
  bind(detector.bindings + (tenant&.table ? ["tenant-foreign-key"] : []))
  note_tenant(tenant)
  providers
  @report.bound = (rails.bound + @bound).uniq
  @report.commented = rails.unbound + @commented
  @report
end