Class: Ghrt::ReviewerComments
- Inherits:
-
Object
- Object
- Ghrt::ReviewerComments
- Defined in:
- lib/ghrt/reviewer_comments.rb
Class Method Summary collapse
-
.normalise_diff_hunk(hunk) ⇒ Object
Make hunks 6 lines long and remove headers.
-
.to_html(repo, pull_request, since, verbose) ⇒ Object
rubocop:disable Metrics/MethodLength.
Class Method Details
.normalise_diff_hunk(hunk) ⇒ Object
Make hunks 6 lines long and remove headers
47 48 49 50 51 |
# File 'lib/ghrt/reviewer_comments.rb', line 47 def self.normalise_diff_hunk(hunk) return hunk.lines.to_a[1..-1].join if hunk.lines.count <= 6 hunk.lines.to_a[(hunk.lines.count - 6)..-1].join end |
.to_html(repo, pull_request, since, verbose) ⇒ Object
rubocop:disable Metrics/MethodLength
8 9 10 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/ghrt/reviewer_comments.rb', line 8 def self.to_html(repo, pull_request, since, verbose) user_comments = Github.new(repo, verbose).review_comments(pull_request, since) # TODO: this really should be re-written using ERB or somesuch html = <<~HTML <html> <head> <title>PR #{pull_request}</title> <link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootswatch/4.2.1/darkly/bootstrap.min.css'/> <script src="https://rawgit.com/google/code-prettify/master/loader/run_prettify.js?autoload=true&skin=doxy&lang=css"></script> </head> <body> <div class="container"> <h2>#{user_comments.count} Comments#{since ? "Since #{since}" : nil}</h2> HTML user_comments.each_with_index do |comment, index| html += <<~HTML <div class="row" ondblclick="this.classList.add('collapse')"> <div class="col-xl-12 mb-2"> <a target="_blank" href='#{comment['html_url']}'><h3>##{index + 1} - #{comment['path']}:#{comment['original_position']}</h3></a> <div class="pl-3"> <pre class="prettyprint"><code>#{normalise_diff_hunk(comment['diff_hunk'])}</code></pre> <div class="text-muted" style="font-size: 1.1em">#{Kramdown::Document.new(comment['body']).to_html}</div> </div> </div> </div> HTML end html += <<~HTML </div> </body> </html> HTML end |