Module: Necropsy::DefinitionIdentity
- Defined in:
- lib/necropsy/definition_identity.rb,
lib/necropsy/definition_identity/canonical_digest.rb
Defined Under Namespace
Classes: CanonicalDigest, CanonicalizationError, CycleError, LimitExceeded, UnsupportedTypeError
Constant Summary
collapse
- VERSION =
1
- PREFIX =
"def:v#{VERSION}".freeze
- EXCLUDED_KEYS =
%i[node_id location flags].freeze
Class Method Summary
collapse
Class Method Details
.body_digest(node, **limits) ⇒ Object
14
15
16
|
# File 'lib/necropsy/definition_identity.rb', line 14
def body_digest(node, **limits)
CanonicalDigest.new(**limits).hexdigest(node)
end
|
.definition_id(kind:, symbol_id:, relative_path:, body_digest:, ordinal:) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/necropsy/definition_identity.rb', line 18
def definition_id(kind:, symbol_id:, relative_path:, body_digest:, ordinal:)
ordinal = Integer(ordinal)
raise ArgumentError, 'definition ordinal must be positive' unless ordinal.positive?
payload = [kind.to_s, symbol_id.to_s, relative_path.to_s, body_digest.to_s, ordinal]
"#{PREFIX}:#{CanonicalDigest.new.hexdigest_payload(payload)}"
end
|
.file_root_id(relative_path:) ⇒ Object
26
27
28
29
|
# File 'lib/necropsy/definition_identity.rb', line 26
def file_root_id(relative_path:)
payload = ['file_root', relative_path.to_s]
"#{PREFIX}:#{CanonicalDigest.new.hexdigest_payload(payload)}"
end
|