Class: HowIs::BaseReport

Inherits:
Struct
  • Object
show all
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

HtmlReport, JsonReport

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#analysisObject

Returns the value of attribute analysis

Returns:

  • (Object)

    the current value of analysis



6
7
8
# File 'lib/how_is/report/base_report.rb', line 6

def analysis
  @analysis
end

Instance Method Details

#exportObject

Exports the report as a String.

Raises:

  • (NotImplementedError)


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.

Raises:

  • (NotImplementedError)


101
102
103
# File 'lib/how_is/report/base_report.rb', line 101

def export_file(_file)
  raise NotImplementedError
end

#formatSymbol

Returns the format of report this class generates.

Returns:

  • (Symbol)

    A lowercase symbol denoting the report format.

Raises:

  • (NotImplementedError)


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]
  horizontal_bar_graph issues_per_label

  # See comment at beginning of function.
  @r
end

#header(_content) ⇒ Object

Appends a header to the report.

Raises:

  • (NotImplementedError)


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.

Raises:

  • (NotImplementedError)


87
88
89
# File 'lib/how_is/report/base_report.rb', line 87

def horizontal_bar_graph(_data)
  raise NotImplementedError
end

Appends a link to the report.

Raises:

  • (NotImplementedError)


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.

Raises:

  • (NotImplementedError)


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.

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/how_is/report/base_report.rb', line 57

def title(_content)
  raise NotImplementedError
end

#to_hObject 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_jsonObject



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.

Raises:

  • (NotImplementedError)


81
82
83
# File 'lib/how_is/report/base_report.rb', line 81

def unordered_list(_arr)
  raise NotImplementedError
end