Class: Sentiero::Fingerprint::Config
- Inherits:
-
Object
- Object
- Sentiero::Fingerprint::Config
- Defined in:
- lib/sentiero/fingerprint/config.rb
Overview
Registry of per-platform frame normalizers, reached as
Sentiero.configuration.fingerprint. ErrorsApp resolves an incoming
occurrence's optional "platform" tag against this registry to pick the
normalizer passed to Fingerprint.compute.
Instance Attribute Summary collapse
-
#default_platform ⇒ Object
Returns the value of attribute default_platform.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#register(name, callable) ⇒ Object
Registering an existing name overrides it, so operators may replace a built-in (e.g. swap out "ruby") as well as add new platforms.
-
#resolve(platform) ⇒ Object
Three-tier resolution (see design doc): a reporter that never learned about the "platform" field must keep grouping exactly as before (absent/blank -> default_platform's normalizer, tier 1), whereas a reporter that declares a platform we don't recognize should not have a foreign grammar mis-applied to it (unregistered -> generic, tier 3).
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 |
# File 'lib/sentiero/fingerprint/config.rb', line 12 def initialize @normalizers = {} @default_platform = "ruby" register("ruby", RUBY_NORMALIZER) register("crystal", CRYSTAL_NORMALIZER) register("generic", GENERIC_NORMALIZER) end |
Instance Attribute Details
#default_platform ⇒ Object
Returns the value of attribute default_platform.
10 11 12 |
# File 'lib/sentiero/fingerprint/config.rb', line 10 def default_platform @default_platform end |
Instance Method Details
#register(name, callable) ⇒ Object
Registering an existing name overrides it, so operators may replace a built-in (e.g. swap out "ruby") as well as add new platforms.
22 23 24 |
# File 'lib/sentiero/fingerprint/config.rb', line 22 def register(name, callable) @normalizers[name.to_s] = callable end |
#resolve(platform) ⇒ Object
Three-tier resolution (see design doc): a reporter that never learned about the "platform" field must keep grouping exactly as before (absent/blank -> default_platform's normalizer, tier 1), whereas a reporter that declares a platform we don't recognize should not have a foreign grammar mis-applied to it (unregistered -> generic, tier 3).
31 32 33 34 35 36 37 |
# File 'lib/sentiero/fingerprint/config.rb', line 31 def resolve(platform) if platform.nil? || platform.to_s.strip.empty? @normalizers.fetch(default_platform.to_s, RUBY_NORMALIZER) else @normalizers.fetch(platform.to_s, GENERIC_NORMALIZER) end end |