lib/how_is.rb in how_is-18.0.4 vs lib/how_is.rb in how_is-18.0.5
- old
+ new
@@ -1,21 +1,24 @@
# frozen_string_literal: true
-require 'how_is/version'
-require 'contracts'
-require 'cacert'
+require "how_is/version"
+require "contracts"
+require "cacert"
Cacert.set_in_env
C = Contracts
+# HowIs control class used from the CLI tool.
+#
+# Generates an analysis and has methods to build reports from it.
class HowIs
include Contracts::Core
- require 'how_is/fetcher'
- require 'how_is/analyzer'
- require 'how_is/report'
+ require "how_is/fetcher"
+ require "how_is/analyzer"
+ require "how_is/report"
DEFAULT_FORMAT = :html
##
# Generate a HowIs instance, so you can generate reports.
@@ -77,22 +80,22 @@
#
# @return [Array<String>] An array of the types of reports you can
# generate.
def self.supported_formats
report_constants = HowIs.constants.grep(/.Report/) - [:BaseReport]
- report_constants.map { |x| x.to_s.split('Report').first.downcase }
+ report_constants.map { |x| x.to_s.split("Report").first.downcase }
end
##
# Returns whether or not the specified +file+ can be exported to.
#
# @param file [String] A filename.
# @return [Boolean] +true+ if HowIs can export to the file, +false+
# if it can't.
def self.can_export_to?(file)
# TODO: Check if the file is writable?
- supported_formats.include?(file.split('.').last)
+ supported_formats.include?(file.split(".").last)
end
# Generate an analysis.
# TODO: This may make more sense as Analysis.new().
# TODO: Nothing overrides +fetcher+ and +analyzer+. Remove ability to do so.
@@ -145,31 +148,31 @@
def self.from_config(config,
github: nil,
report_class: nil)
report_class ||= HowIs::Report
- date = Date.strptime(Time.now.to_i.to_s, '%s')
- friendly_date = date.strftime('%B %d, %y')
+ date = Date.strptime(Time.now.to_i.to_s, "%s")
+ friendly_date = date.strftime("%B %d, %y")
- analysis = HowIs.generate_analysis(repository: config['repository'], github: github)
+ analysis = HowIs.generate_analysis(repository: config["repository"], github: github)
report_data = {
- repository: config['repository'],
+ repository: config["repository"],
date: date,
friendly_date: friendly_date,
}
generated_reports = {}
- config['reports'].map do |format, report_config|
+ config["reports"].map do |format, report_config|
# Sometimes report_data has unused keys, which generates a warning, but
# we're okay with it.
- filename = silence_warnings { report_config['filename'] % report_data }
- file = File.join(report_config['directory'], filename)
+ filename = silence_warnings { report_config["filename"] % report_data }
+ file = File.join(report_config["directory"], filename)
report = report_class.export(analysis, format)
- result = build_report(report_config['frontmatter'], report_data, report)
+ result = build_report(report_config["frontmatter"], report_data, report)
generated_reports[file] = result
result
end