Class: Igniter::Contracts::Assembly::Kernel

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/contracts/assembly/kernel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes: Registry.new(name: :nodes), dsl_keywords: Registry.new(name: :dsl_keywords), validators: OrderedRegistry.new(name: :validators), normalizers: OrderedRegistry.new(name: :normalizers), runtime_handlers: Registry.new(name: :runtime_handlers), diagnostics_contributors: OrderedRegistry.new(name: :diagnostics_contributors), effects: Registry.new(name: :effects), executors: Registry.new(name: :executors)) ⇒ Kernel

Returns a new instance of Kernel.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/igniter/contracts/assembly/kernel.rb', line 17

def initialize(
  nodes: Registry.new(name: :nodes),
  dsl_keywords: Registry.new(name: :dsl_keywords),
  validators: OrderedRegistry.new(name: :validators),
  normalizers: OrderedRegistry.new(name: :normalizers),
  runtime_handlers: Registry.new(name: :runtime_handlers),
  diagnostics_contributors: OrderedRegistry.new(name: :diagnostics_contributors),
  effects: Registry.new(name: :effects),
  executors: Registry.new(name: :executors)
)
  @nodes = nodes
  @dsl_keywords = dsl_keywords
  @validators = validators
  @normalizers = normalizers
  @runtime_handlers = runtime_handlers
  @diagnostics_contributors = diagnostics_contributors
  @pack_manifests = []
  @effects = effects
  @executors = executors
  @finalized = false
end

Instance Attribute Details

#diagnostics_contributorsObject (readonly)

Returns the value of attribute diagnostics_contributors.



7
8
9
# File 'lib/igniter/contracts/assembly/kernel.rb', line 7

def diagnostics_contributors
  @diagnostics_contributors
end

#dsl_keywordsObject (readonly)

Returns the value of attribute dsl_keywords.



7
8
9
# File 'lib/igniter/contracts/assembly/kernel.rb', line 7

def dsl_keywords
  @dsl_keywords
end

#effectsObject (readonly)

Returns the value of attribute effects.



7
8
9
# File 'lib/igniter/contracts/assembly/kernel.rb', line 7

def effects
  @effects
end

#executorsObject (readonly)

Returns the value of attribute executors.



7
8
9
# File 'lib/igniter/contracts/assembly/kernel.rb', line 7

def executors
  @executors
end

#nodesObject (readonly)

Returns the value of attribute nodes.



7
8
9
# File 'lib/igniter/contracts/assembly/kernel.rb', line 7

def nodes
  @nodes
end

#normalizersObject (readonly)

Returns the value of attribute normalizers.



7
8
9
# File 'lib/igniter/contracts/assembly/kernel.rb', line 7

def normalizers
  @normalizers
end

#pack_manifestsObject (readonly)

Returns the value of attribute pack_manifests.



7
8
9
# File 'lib/igniter/contracts/assembly/kernel.rb', line 7

def pack_manifests
  @pack_manifests
end

#runtime_handlersObject (readonly)

Returns the value of attribute runtime_handlers.



7
8
9
# File 'lib/igniter/contracts/assembly/kernel.rb', line 7

def runtime_handlers
  @runtime_handlers
end

#validatorsObject (readonly)

Returns the value of attribute validators.



7
8
9
# File 'lib/igniter/contracts/assembly/kernel.rb', line 7

def validators
  @validators
end

Instance Method Details

#finalizeObject



58
59
60
61
62
63
64
# File 'lib/igniter/contracts/assembly/kernel.rb', line 58

def finalize
  validate_completeness!
  validate_hook_implementations!
  freeze_registries!
  @finalized = true
  Profile.build_from(self)
end

#finalized?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/igniter/contracts/assembly/kernel.rb', line 66

def finalized?
  @finalized
end

#install(pack, installing: []) ⇒ Object

Raises:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/igniter/contracts/assembly/kernel.rb', line 39

def install(pack, installing: [])
  raise FrozenKernelError, "kernel already finalized" if finalized?

  manifest = pack.respond_to?(:manifest) ? pack.manifest : nil
  pack_name = manifest&.name

  return self if pack_name && pack_installed?(pack_name)

  if pack_name && installing.include?(pack_name)
    cycle = (installing + [pack_name]).join(" -> ")
    raise CircularPackDependencyError, "circular pack dependency detected: #{cycle}"
  end

  install_required_packs(manifest, installing: [*installing, pack_name].compact) if manifest
  register_pack_manifest(pack, manifest: manifest)
  pack.install_into(self)
  self
end