lib/how_is/report.rb in how_is-18.0.4 vs lib/how_is/report.rb in how_is-18.0.5
- old
+ new
@@ -1,25 +1,28 @@
# frozen_string_literal: true
-require 'date'
+require "date"
require "pathname"
class HowIs
+ # Raised when attempting to export to an unsupported format
class UnsupportedExportFormat < StandardError
def initialize(format)
super("Unsupported export format: #{format}")
end
end
+ # Report control class with class methods to make reports for an analysis
+ # or to save reports in files, or otherwise interact with the files.
class Report
- require 'how_is/report/json'
- require 'how_is/report/html'
+ require "how_is/report/json"
+ require "how_is/report/html"
##
# Export a report to a file.
def self.export_file(analysis, file)
- format = file.split('.').last
+ format = file.split(".").last
report = get_report_class(format).new(analysis)
report.export_file(file)
end
@@ -35,11 +38,11 @@
# Saves given Report in given file.
#
# @param file [String,Pathname] Name of file to write to
# @param report [Report] Report to store
def self.save_report(file, report)
- File.open(file, 'w') do |f|
+ File.open(file, "w") do |f|
f.write report
end
end
##
@@ -47,10 +50,10 @@
#
# @param file [String] Filename of a report
#
# @return [String] Report format inferred from file name
def self.infer_format(file)
- Pathname(file).extname.delete('.')
+ Pathname(file).extname.delete(".")
end
##
# Exports given +report+ to the format suitable for given +file+.
#