Class: HowIs::BaseReport
- Inherits:
-
Struct
- Object
- Struct
- HowIs::BaseReport
- Defined in:
- lib/how_is/report/base_report.rb,
lib/how_is/report/base_report.rb
Overview
Subclasses of BaseReport represent complete reports.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#analysis ⇒ Object
Returns the value of attribute analysis.
Instance Method Summary collapse
-
#export ⇒ Object
Exports the report as a String.
-
#export_file(_file) ⇒ Object
Exports a report to a file.
-
#format ⇒ Symbol
Returns the format of report this class generates.
- #generate_report_text! ⇒ Object
-
#header(_content) ⇒ Object
Appends a header to the report.
-
#horizontal_bar_graph(_data) ⇒ Object
Appends a horizontal bar graph to the report.
-
#link(_content, _url) ⇒ Object
Appends a link to the report.
-
#text(_content) ⇒ Object
Appends a line of text to the report.
-
#title(_content) ⇒ Object
Appends a title to the report.
- #to_h ⇒ Object (also: #to_hash)
- #to_json ⇒ Object
-
#unordered_list(_arr) ⇒ Object
Appends an unordered list to the report.
Instance Attribute Details
#analysis ⇒ Object
Returns the value of attribute analysis
6 7 8 |
# File 'lib/how_is/report/base_report.rb', line 6 def analysis @analysis end |
Instance Method Details
#export ⇒ Object
Exports the report as a String.
93 94 95 |
# File 'lib/how_is/report/base_report.rb', line 93 def export raise NotImplementedError end |
#export_file(_file) ⇒ Object
Exports a report to a file.
NOTE: May be removed in the future.
101 102 103 |
# File 'lib/how_is/report/base_report.rb', line 101 def export_file(_file) raise NotImplementedError end |
#format ⇒ Symbol
Returns the format of report this class generates.
51 52 53 |
# File 'lib/how_is/report/base_report.rb', line 51 def format raise NotImplementedError end |
#generate_report_text! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/how_is/report/base_report.rb', line 11 def generate_report_text! # title, text, header, horizontal_bar_graph, etc, # append to @r, which is returned at the end of the function. title "How is #{analysis.repository}?" # DateTime#new_offset(0) sets the timezone to UTC. I think it does this # without changing anything besides the timezone, but who knows, 'cause # new_offset is entirely undocumented! (Even though it's used in the # DateTime documentation!) # # TODO: Stop pretending everyone who runs how_is is in UTC. text "Monthly report, ending on #{DateTime.now.new_offset(0).strftime('%B %e, %Y')}." text analysis.pulse header "Pull Requests" issue_or_pr_summary "pull", "pull request" header "Issues" issue_or_pr_summary "issue", "issue" header "Issues Per Label" issues_per_label = analysis.issues_with_label.to_a.sort_by { |(_, v)| v["total"].to_i }.reverse issues_per_label.map! do |label, hash| [label, hash["total"], hash["link"]] end issues_per_label << ["(No label)", analysis.issues_with_no_label["total"], nil] issues_per_label # See comment at beginning of function. @r end |
#header(_content) ⇒ Object
Appends a header to the report.
63 64 65 |
# File 'lib/how_is/report/base_report.rb', line 63 def header(_content) raise NotImplementedError end |
#horizontal_bar_graph(_data) ⇒ Object
Appends a horizontal bar graph to the report.
87 88 89 |
# File 'lib/how_is/report/base_report.rb', line 87 def (_data) raise NotImplementedError end |
#link(_content, _url) ⇒ Object
Appends a link to the report.
75 76 77 |
# File 'lib/how_is/report/base_report.rb', line 75 def link(_content, _url) raise NotImplementedError end |
#text(_content) ⇒ Object
Appends a line of text to the report.
69 70 71 |
# File 'lib/how_is/report/base_report.rb', line 69 def text(_content) raise NotImplementedError end |
#title(_content) ⇒ Object
Appends a title to the report.
57 58 59 |
# File 'lib/how_is/report/base_report.rb', line 57 def title(_content) raise NotImplementedError end |
#to_h ⇒ Object Also known as: to_hash
105 106 107 |
# File 'lib/how_is/report/base_report.rb', line 105 def to_h analysis.to_h end |
#to_json ⇒ Object
110 111 112 |
# File 'lib/how_is/report/base_report.rb', line 110 def to_json JSON.pretty_generate(to_h) end |
#unordered_list(_arr) ⇒ Object
Appends an unordered list to the report.
81 82 83 |
# File 'lib/how_is/report/base_report.rb', line 81 def unordered_list(_arr) raise NotImplementedError end |