Class: I18n::Coverage::Printers::FilePrinter
- Inherits:
-
Object
- Object
- I18n::Coverage::Printers::FilePrinter
- Defined in:
- lib/i18n/coverage/printers/file_printer.rb
Constant Summary collapse
- REPORT_PATH =
'coverage/i18n.json'.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(report) ⇒ FilePrinter
constructor
A new instance of FilePrinter.
- #print ⇒ Object
- #print_message ⇒ Object
- #write_report ⇒ Object
Constructor Details
#initialize(report) ⇒ FilePrinter
Returns a new instance of FilePrinter.
11 12 13 |
# File 'lib/i18n/coverage/printers/file_printer.rb', line 11 def initialize(report) @report = report end |
Class Method Details
.print(report) ⇒ Object
7 8 9 |
# File 'lib/i18n/coverage/printers/file_printer.rb', line 7 def self.print(report) new(report).print end |
Instance Method Details
#print ⇒ Object
15 16 17 18 |
# File 'lib/i18n/coverage/printers/file_printer.rb', line 15 def print write_report end |
#print_message ⇒ Object
25 26 27 28 29 |
# File 'lib/i18n/coverage/printers/file_printer.rb', line 25 def puts "Coverage report generated for I18n to #{REPORT_PATH}. " \ "#{@report[:used_key_count]} / #{@report[:key_count]} keys " \ "(#{@report[:percentage_used].round(2)}%) covered." end |
#write_report ⇒ Object
20 21 22 23 |
# File 'lib/i18n/coverage/printers/file_printer.rb', line 20 def write_report FileUtils.mkdir_p(File.dirname(REPORT_PATH)) File.write(REPORT_PATH, JSON.pretty_generate(@report)) end |