Class: I18n::Coverage::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/coverage/reporter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReporter

Returns a new instance of Reporter.



11
12
13
14
# File 'lib/i18n/coverage/reporter.rb', line 11

def initialize
  @existing_keys = KeyLister.list_keys
  @stored_keys = KeyLogger.stored_keys
end

Class Method Details

.reportObject



7
8
9
# File 'lib/i18n/coverage/reporter.rb', line 7

def self.report
  Reporter.new.report
end

Instance Method Details

#hash_reportObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/i18n/coverage/reporter.rb', line 20

def hash_report
  used_keys = @existing_keys - unused_keys
  percentage_used = (used_keys.count.to_f / @existing_keys.count) * 100

  {
    key_count: @existing_keys.count,
    used_key_count: used_keys.count,
    percentage_used: percentage_used,
    unused_keys: unused_keys.to_a
  }
end

#reportObject



16
17
18
# File 'lib/i18n/coverage/reporter.rb', line 16

def report
  I18n::Coverage.config.printer.print(hash_report)
end