Module: HowIs
- Defined in:
- lib/how_is.rb,
lib/how_is/report.rb,
lib/how_is/sources.rb,
lib/how_is/version.rb,
lib/how_is/frontmatter.rb,
lib/how_is/sources/github.rb,
lib/how_is/sources/github_helpers.rb
Defined Under Namespace
Modules: CLI, Frontmatter, Sources Classes: Report
Constant Summary collapse
- DEFAULT_REPORT_FILE =
"report.html"
- VERSION =
"20.0.0"
Class Method Summary collapse
-
.can_export_to?(file) ⇒ Boolean
Returns whether or not the specified
file
can be exported to. -
.from_config(config, date) ⇒ Object
Generates a series of report files based on a config Hash.
-
.from_hash(data) ⇒ HowIs
Given report data as a hash, create a new HowIs object (for generating other reports).
-
.from_json(json) ⇒ HowIs
Given a JSON report, create a new HowIs object (for generating other reports).
- .github ⇒ Object
- .new(repository, date) ⇒ Object
-
.supported_formats ⇒ Array<String>
Returns a list of possible export formats.
- .template(filename) ⇒ Object
Class Method Details
.can_export_to?(file) ⇒ Boolean
Returns whether or not the specified file
can be exported to.
92 93 94 95 |
# File 'lib/how_is.rb', line 92 def self.can_export_to?(file) # TODO: Check if the file is writable? supported_formats.include?(file.split(".").last) end |
.from_config(config, date) ⇒ Object
Generates a series of report files based on a config Hash.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/how_is.rb', line 52 def self.from_config(config, date) report = Report.new(config["repository"], date) report_data = (config["repository"], date) generated_reports = config["reports"].map { |format, report_config| # Sometimes report_data has unused keys, which generates a warning, but # we're okay with it, so we wrap it with silence_warnings {}. filename = silence_warnings { report_config["filename"] % report_data } file = File.join(report_config["directory"], filename) report_export = report.send("to_#{format}", report_config["frontmatter"]) [file, report_export] } generated_reports.to_h end |
.from_hash(data) ⇒ HowIs
Given report data as a hash, create a new HowIs object (for generating other reports).
39 40 41 42 43 |
# File 'lib/how_is.rb', line 39 def self.from_hash(data) analysis = HowIs::Analysis.from_hash(data) new(analysis.repository, analysis) end |
.from_json(json) ⇒ HowIs
Given a JSON report, create a new HowIs object (for generating other reports).
28 29 30 |
# File 'lib/how_is.rb', line 28 def self.from_json(json) from_hash(JSON.parse(json)) end |
.github ⇒ Object
14 15 16 17 18 19 |
# File 'lib/how_is.rb', line 14 def self.github @@github ||= Github.new(auto_pagination: true) do |config| config.basic_auth = ENV["HOWIS_BASIC_AUTH"] if ENV["HOWIS_BASIC_AUTH"] end end |
.new(repository, date) ⇒ Object
10 11 12 |
# File 'lib/how_is.rb', line 10 def self.new(repository, date) Report.new(repository, date) end |
.supported_formats ⇒ Array<String>
Returns a list of possible export formats.
75 76 77 |
# File 'lib/how_is.rb', line 75 def self.supported_formats ["html", "json"] end |
.template(filename) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/how_is.rb', line 79 def self.template(filename) dir = File.("./how_is/templates/", __dir__) path = File.join(dir, filename) open(path).read end |