Class: HowIs::Report
- Inherits:
-
Object
- Object
- HowIs::Report
- Defined in:
- lib/how_is/report.rb
Instance Method Summary collapse
-
#initialize(repository, end_date) ⇒ Report
constructor
A new instance of Report.
- #to_h(frontmatter_data = nil) ⇒ Object
- #to_html(frontmatter = nil) ⇒ Object
- #to_html_partial(frontmatter = nil) ⇒ Object
- #to_json(frontmatter = nil) ⇒ Object
Constructor Details
#initialize(repository, end_date) ⇒ Report
Returns a new instance of Report.
11 12 13 14 15 16 17 18 19 |
# File 'lib/how_is/report.rb', line 11 def initialize(repository, end_date) @repository = repository @end_date = end_date @gh_contributions = HowIs::Sources::Github::Contributions.new(repository, end_date) @gh_issues = HowIs::Sources::Github::Issues.new(repository, end_date) @gh_pulls = HowIs::Sources::Github::Pulls.new(repository, end_date) @travis = HowIs::Sources::Travis.new(repository, end_date) end |
Instance Method Details
#to_h(frontmatter_data = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/how_is/report.rb', line 21 def to_h(frontmatter_data = nil) @report_hash ||= { title: "How is #{@repository}?", repository: @repository, contributions_summary: @gh_contributions.to_html, issues_summary: @gh_issues.to_html, pulls_summary: @gh_pulls.to_html, issues_per_label: @gh_issues.issues_per_label_html, issues: @gh_issues.to_a, pulls: @gh_issues.to_a, number_of_issues: @gh_issues.to_a.length, number_of_pulls: @gh_pulls.to_a.length, average_issue_age: @gh_issues.average_age, average_pull_age: @gh_pulls.average_age, oldest_issue_link: @gh_issues.oldest[:link], oldest_issue_date: @gh_issues.oldest[:creation_date], newest_issue_link: @gh_issues.newest[:link], newest_issue_date: @gh_issues.newest[:creation_date], oldest_pull_link: @gh_pulls.oldest[:link], oldest_pull_date: @gh_pulls.oldest[:creation_date], travis_builds: @travis.builds.to_h, } frontmatter = if frontmatter_data HowIs::Frontmatter.generate(frontmatter_data, @report_hash) else "" end @report_hash.merge(frontmatter: frontmatter) end |
#to_html(frontmatter = nil) ⇒ Object
68 69 70 71 72 |
# File 'lib/how_is/report.rb', line 68 def to_html(frontmatter = nil) template_data = to_h(frontmatter).merge({report: to_html_partial}) Kernel.format(HowIs.template("report.html_template"), template_data) end |
#to_html_partial(frontmatter = nil) ⇒ Object
62 63 64 65 66 |
# File 'lib/how_is/report.rb', line 62 def to_html_partial(frontmatter = nil) template_data = to_h(frontmatter) Kernel.format(HowIs.template("report_partial.html_template"), template_data) end |
#to_json(frontmatter = nil) ⇒ Object
74 75 76 |
# File 'lib/how_is/report.rb', line 74 def to_json(frontmatter = nil) frontmatter.to_s + JSON.pretty_generate(to_h) end |