Sha256: 545e2c1d7ec0bed56c6c0619242404b1e94de6e2b98a4138b969566346a9f8f3
Contents?: true
Size: 950 Bytes
Versions: 1
Compression:
Stored size: 950 Bytes
Contents
require 'i18n/coverage/key_lister' require 'i18n/coverage/key_logger' module I18n module Coverage class Reporter def self.report Reporter.new.report end def initialize @existing_keys = KeyLister.list_keys @stored_keys = KeyLogger.stored_keys end def report I18n::Coverage.config.printer.print(hash_report) end 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 private def unused_keys @unused_keys ||= @existing_keys.reject do |key| @stored_keys.any? { |stored_key| key.start_with?(stored_key.to_s) } end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
i18n-coverage-0.2.0 | lib/i18n/coverage/reporter.rb |