Class: Igniter::Extensions::Contracts::Debug::ProfileSnapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/igniter/extensions/contracts/debug/profile_snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile:) ⇒ ProfileSnapshot

Returns a new instance of ProfileSnapshot.



12
13
14
15
# File 'lib/igniter/extensions/contracts/debug/profile_snapshot.rb', line 12

def initialize(profile:)
  @profile = profile
  freeze
end

Instance Attribute Details

#profileObject (readonly)

Returns the value of attribute profile.



10
11
12
# File 'lib/igniter/extensions/contracts/debug/profile_snapshot.rb', line 10

def profile
  @profile
end

Instance Method Details

#pack_namesObject



17
18
19
# File 'lib/igniter/extensions/contracts/debug/profile_snapshot.rb', line 17

def pack_names
  profile.pack_names.sort
end

#packsObject



21
22
23
# File 'lib/igniter/extensions/contracts/debug/profile_snapshot.rb', line 21

def packs
  profile.pack_manifests.map { |manifest| PackSnapshot.new(manifest) }
end

#registry_keysObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/igniter/extensions/contracts/debug/profile_snapshot.rb', line 25

def registry_keys
  {
    node_kinds: profile.nodes.keys.sort,
    dsl_keywords: profile.dsl_keywords.keys.sort,
    validators: profile.validators.map(&:key).sort,
    normalizers: profile.normalizers.map(&:key).sort,
    runtime_handlers: profile.runtime_handlers.keys.sort,
    diagnostics_contributors: profile.diagnostics_contributors.map(&:key).sort,
    effects: profile.effects.keys.sort,
    executors: profile.executors.keys.sort
  }
end

#to_hObject



38
39
40
41
42
43
44
45
# File 'lib/igniter/extensions/contracts/debug/profile_snapshot.rb', line 38

def to_h
  {
    fingerprint: profile.fingerprint,
    pack_names: pack_names,
    registry_keys: registry_keys,
    packs: packs.map(&:to_h)
  }
end