Class: InertiaI18n::HealthChecker
- Inherits:
-
Object
- Object
- InertiaI18n::HealthChecker
- Defined in:
- lib/inertia_i18n/health_checker.rb
Instance Attribute Summary collapse
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
-
#locales ⇒ Object
readonly
Returns the value of attribute locales.
-
#scan_results ⇒ Object
readonly
Returns the value of attribute scan_results.
Instance Method Summary collapse
- #check!(checks: [:missing, :unused, :unsync]) ⇒ Object
- #healthy? ⇒ Boolean
-
#initialize ⇒ HealthChecker
constructor
A new instance of HealthChecker.
- #summary ⇒ Object
Constructor Details
#initialize ⇒ HealthChecker
Returns a new instance of HealthChecker.
7 8 9 10 11 12 |
# File 'lib/inertia_i18n/health_checker.rb', line 7 def initialize @config = InertiaI18n.configuration @locales = LocaleLoader.load_all @scan_results = Scanner.new.scan @issues = {missing: [], unused: [], unsync: []} end |
Instance Attribute Details
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
5 6 7 |
# File 'lib/inertia_i18n/health_checker.rb', line 5 def issues @issues end |
#locales ⇒ Object (readonly)
Returns the value of attribute locales.
5 6 7 |
# File 'lib/inertia_i18n/health_checker.rb', line 5 def locales @locales end |
#scan_results ⇒ Object (readonly)
Returns the value of attribute scan_results.
5 6 7 |
# File 'lib/inertia_i18n/health_checker.rb', line 5 def scan_results @scan_results end |
Instance Method Details
#check!(checks: [:missing, :unused, :unsync]) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/inertia_i18n/health_checker.rb', line 14 def check!(checks: [:missing, :unused, :unsync]) check_missing_keys if checks.include?(:missing) check_unused_keys if checks.include?(:unused) check_locale_sync if checks.include?(:unsync) self end |
#healthy? ⇒ Boolean
21 22 23 |
# File 'lib/inertia_i18n/health_checker.rb', line 21 def healthy? @issues.values.all?(&:empty?) end |
#summary ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/inertia_i18n/health_checker.rb', line 25 def summary { total_errors: @issues.values.flatten.count { |i| i[:severity] == :error }, total_warnings: @issues.values.flatten.count { |i| i[:severity] == :warning }, missing_count: @issues[:missing].size, unused_count: @issues[:unused].size, unsync_count: @issues[:unsync].size, healthy: healthy? } end |