Class: Couve::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/couve/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(coverage) ⇒ Parser

Returns a new instance of Parser.



4
5
6
7
8
# File 'lib/couve/parser.rb', line 4

def initialize(coverage)
  @coverage = JSON.parse(coverage, symbolize_names: true)
  @coverage[:source_files].reject! { |file| file[:covered_percent] == 100 }
  @coverage[:source_files].sort_by! { |file| file[:covered_percent] }
end

Instance Method Details

#to_htmlObject



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
# File 'lib/couve/parser.rb', line 10

def to_html
  "    <html>\n      <body>\n        <div class=\"container mt-5\">\n          <h1 class=\"display-5\">\n            Coverage problems\n          </h1>\n\n          <table class=\"table table-hover mt-5\">\n            <thead>\n              <tr>\n                <th class=\"col-1 text-end\">Coverage</th>\n                <th class=\"col-8\">File</th>\n                <th class=\"col-3\">Not covered lines</th>\n              </tr>\n            </thead>\n            \#{body}\n          </table>\n        </div>\n\n        <link href=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC\" crossorigin=\"anonymous\">\n        <script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js\" integrity=\"sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM\" crossorigin=\"anonymous\"></script>\n      </body>\n    </html>\n  HTML\nend\n"