simplecov-material 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +286 -0
  3. data/.circleci/setup-rubygems.sh +3 -0
  4. data/.codeclimate.json +86 -0
  5. data/.eslintignore +1 -0
  6. data/.eslintrc.yml +25 -0
  7. data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  8. data/.github/ISSUE_TEMPLATE/feature-request.md +20 -0
  9. data/.github/ISSUE_TEMPLATE/question.md +10 -0
  10. data/.github/PULL_REQUEST_TEMPLATE.md +32 -0
  11. data/.gitignore +12 -0
  12. data/.rubocop.yml +884 -0
  13. data/.stylelintignore +1 -0
  14. data/.stylelintrc +48 -0
  15. data/CHANGELOG.md +13 -0
  16. data/CODE_OF_CONDUCT.md +74 -0
  17. data/CONTRIBUTING.md +132 -0
  18. data/Gemfile +19 -0
  19. data/LICENSE +21 -0
  20. data/README.md +84 -0
  21. data/Rakefile +12 -0
  22. data/bin/console +12 -0
  23. data/bin/publish +82 -0
  24. data/bin/setup +6 -0
  25. data/dist/app.js +8 -0
  26. data/dist/app.scss +11 -0
  27. data/dist/scripts/dialog.js +8 -0
  28. data/dist/scripts/forms.js +13 -0
  29. data/dist/scripts/list.js +8 -0
  30. data/dist/scripts/navigation.js +14 -0
  31. data/dist/scripts/ripple.js +18 -0
  32. data/dist/scripts/table.js +18 -0
  33. data/dist/scripts/timeago.js +3 -0
  34. data/dist/scripts/topbar.js +5 -0
  35. data/dist/styles/dialog.scss +191 -0
  36. data/dist/styles/main.scss +141 -0
  37. data/dist/styles/table.scss +136 -0
  38. data/lib/simplecov-material.rb +123 -0
  39. data/lib/simplecov-material/version.rb +9 -0
  40. data/package.json +66 -0
  41. data/public/application.css +11083 -0
  42. data/public/application.js +936 -0
  43. data/public/fonts/0509ab09c1b0d2200a4135803c91d6ce.woff2 +0 -0
  44. data/public/fonts/29b882f018fa6fe75fd338aaae6235b8.woff +0 -0
  45. data/public/fonts/96c476804d7a788cc1c05351b287ee41.eot +0 -0
  46. data/public/fonts/da4ea5cdfca6b3baab285741f5ccb59f.ttf +0 -0
  47. data/simplecov-material.gemspec +32 -0
  48. data/test/fixtures/app/controllers/sample_controller.rb +12 -0
  49. data/test/fixtures/app/models/user.rb +12 -0
  50. data/test/fixtures/sample.rb +12 -0
  51. data/test/simplecov-material/simplecov_material_test.rb +40 -0
  52. data/test/test_helper.rb +17 -0
  53. data/views/dialog.erb +51 -0
  54. data/views/group_page.erb +110 -0
  55. data/views/main.erb +90 -0
  56. data/webpack.config.js +81 -0
  57. data/yarn.lock +6973 -0
  58. metadata +127 -0
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "simplecov-material/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "simplecov-material"
9
+ spec.version = SimpleCov::Formatter::MaterialFormatter::VERSION
10
+ spec.authors = ["Christopher Pezza"]
11
+ spec.email = ["chiefpansancolt@gmail.com"]
12
+ spec.summary = "HTML Material Design View for Simplecov formatter"
13
+ spec.description = %q(HTML Material Design View of Simplecov as a formatter
14
+ that is clean, easy to read.)
15
+ spec.homepage = "https://github.com/chiefpansancolt/simplecov-material"
16
+ spec.license = "MIT"
17
+
18
+ spec.required_ruby_version = ">= 2.3.0"
19
+
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/chiefpansancolt/simplecov-material"
22
+ spec.metadata["changelog_uri"] = "https://github.com/chiefpansancolt/simplecov-material/blob/master/CHANGELOG.md"
23
+ spec.metadata["bug_tracker_uri"] = "https://github.com/chiefpansancolt/simplecov-material/issues"
24
+
25
+ spec.files = `git ls-files`.split("\n")
26
+ spec.bindir = "bin"
27
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
28
+ spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "simplecov", ">= 0.16.0"
32
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Foo class
4
+ class Foo
5
+ def initialize
6
+ @foo = "baz"
7
+ end
8
+
9
+ def bar
10
+ @foo
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Foo class
4
+ class Foo
5
+ def initialize
6
+ @foo = "baz"
7
+ end
8
+
9
+ def bar
10
+ @foo
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Foo class
4
+ class Foo
5
+ def initialize
6
+ @foo = "baz"
7
+ end
8
+
9
+ def bar
10
+ @foo
11
+ end
12
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+ require "simplecov"
5
+ require "simplecov-material"
6
+ require "simplecov-material/version"
7
+
8
+ class SimplecovMaterialTest < Minitest::Test
9
+ def test_defined
10
+ assert defined?(SimpleCov::Formatter::MaterialFormatter)
11
+ assert defined?(SimpleCov::Formatter::MaterialFormatter::VERSION)
12
+ end
13
+
14
+ def test_version
15
+ version = SimpleCov::Formatter::MaterialFormatter::VERSION
16
+
17
+ assert(!version.nil?)
18
+ end
19
+
20
+ def test_execution # rubocop:disable MethodLength
21
+ @original_result = {
22
+ source_fixture("sample.rb") => [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil],
23
+ source_fixture("app/models/user.rb") => [
24
+ nil, 1, 1, 1, nil, nil, 1, 0, nil, nil
25
+ ],
26
+ source_fixture("app/controllers/sample_controller.rb") => [
27
+ nil, 1, 1, 1, nil, nil, 0, 0, nil, nil
28
+ ]
29
+ }
30
+
31
+ @result = SimpleCov::Result.new(@original_result)
32
+ SimpleCov::Formatter::MaterialFormatter.new.format(@result)
33
+
34
+ assert(File.exist?("/#{SimpleCov.coverage_path}/index.html"))
35
+ end
36
+
37
+ def source_fixture(filename)
38
+ File.expand_path(File.join(File.dirname(__FILE__), "fixtures", filename))
39
+ end
40
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+
5
+ SimpleCov.start do
6
+ add_filter "/test/"
7
+ end
8
+
9
+ SimpleCov.formatters = [
10
+ SimpleCov::Formatter::MaterialFormatter
11
+ ]
12
+
13
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
14
+ require "minitest/autorun"
15
+ require "minitest/pride"
16
+ require "minitest/ci"
17
+ require "mocha/minitest"
@@ -0,0 +1,51 @@
1
+ <div class="mdc-dialog" role="alertdialog" aria-modal="true"
2
+ aria-labelledby="<%= shortened_filename(file) %>"
3
+ id="<%= shortened_filename(file) %>-dialog">
4
+ <div class="mdc-dialog__container">
5
+ <div class="mdc-dialog__surface">
6
+ <h2 class="mdc-dialog__title">
7
+ <%= shortened_filename file %>
8
+ <span class="parenthese">
9
+ <span class="<%= coverage_class(file.covered_percent) %>">
10
+ <%= file.covered_percent.round(2).to_s %>%
11
+ </span>
12
+ </span>
13
+ </h2>
14
+
15
+ <div class="mdc-dialog__content">
16
+ <pre>
17
+ <ol>
18
+ <% file.lines.each do |line| %>
19
+ <li class="<%= line.status %>" data-hits="<%= line.coverage ? line.coverage : '' %>"
20
+ data-linenumber="<%= line.number %>">
21
+ <% if line.covered? %><span class="hits"><%= line.coverage %></span><% end %>
22
+ <% if line.skipped? %><span class="hits">skipped</span><% end %>
23
+ <code class="ruby"><%= CGI.escapeHTML(line.src.chomp) %></code>
24
+ </li>
25
+ <% end %>
26
+ </ol>
27
+ </pre>
28
+ </div>
29
+
30
+ <footer class="mdc-dialog__actions">
31
+ <div class="text">
32
+ <b><%= file.lines_of_code %></b> Relevant Lines
33
+ |
34
+ <span class="green"><b>
35
+ <%= format_number(file.covered_lines.count) %>
36
+ </b></span> Lines Covered
37
+ |
38
+ <span class="red"><b>
39
+ <%= format_number(file.missed_lines.count) %>
40
+ </b></span> Lines Missed
41
+ </div>
42
+ <div class="buttons">
43
+ <button type="button" class="mdc-button mdc-button--raised mdc-dialog__button" data-mdc-dialog-action="close">
44
+ <span class="mdc-button__label">close</span>
45
+ </button>
46
+ </div>
47
+ </footer>
48
+ </div>
49
+ </div>
50
+ <div class="mdc-dialog__scrim"></div>
51
+ </div>
@@ -0,0 +1,110 @@
1
+ <div class="tab-groups" name="<%= title_id %>" style="<%= hide_show(title_id) %>">
2
+ <div class="mdc-layout-grid">
3
+ <div class="mdc-layout-grid__inner">
4
+ <div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-2">
5
+ <div class="mdc-card card-tile">
6
+ <p class="card-title">Covered</p>
7
+ <h4 class="card-data mdc-typography--headline4 <%= coverage_class(files.covered_percent) %>">
8
+ <%= files.covered_percent.round(2) %>%
9
+ </h4>
10
+ </div>
11
+ </div>
12
+ <div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-2">
13
+ <div class="mdc-card card-tile">
14
+ <p class="card-title">Hits/Line</p>
15
+ <h4 class="card-data mdc-typography--headline4 <%= strength_class(files.covered_strength) %>">
16
+ <%= files.covered_strength.round(2) %>
17
+ </h4>
18
+ </div>
19
+ </div>
20
+ <div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-2">
21
+ <div class="mdc-card card-tile">
22
+ <p class="card-title"># of Files</p>
23
+ <h4 class="card-data mdc-typography--headline4">
24
+ <%= format_number(files.length) %>
25
+ </h4>
26
+ </div>
27
+ </div>
28
+ <div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-2">
29
+ <div class="mdc-card card-tile">
30
+ <p class="card-title">Relevent Lines</p>
31
+ <h4 class="card-data mdc-typography--headline4">
32
+ <%= format_number(files.lines_of_code) %>
33
+ </h4>
34
+ </div>
35
+ </div>
36
+ <div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-2">
37
+ <div class="mdc-card card-tile">
38
+ <p class="card-title">Lines Covered</p>
39
+ <h4 class="card-data mdc-typography--headline4 green">
40
+ <%= format_number(files.covered_lines) %>
41
+ </h4>
42
+ </div>
43
+ </div>
44
+ <div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-2">
45
+ <div class="mdc-card card-tile">
46
+ <p class="card-title">Lines Missed</p>
47
+ <h4 class="card-data mdc-typography--headline4 red">
48
+ <%= format_number(files.missed_lines) %>
49
+ </h4>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ </div>
54
+
55
+ <div class="mdc-card mdc-card--outlined">
56
+ <div class="mdc-text-field mdc-text-field--with-trailing-icon">
57
+ <i class="material-icons mdc-text-field__icon">search</i>
58
+ <input type="search" class="mdc-text-field__input search-box" onkeyup="searchTable(this.id)" onsearch="searchTable(this.id)" id="<%= title_id %>">
59
+ <div class="mdc-line-ripple"></div>
60
+ <label for="text-field-hero-input" class="mdc-floating-label">Search</label>
61
+ </div>
62
+ <div class="mdc-text-field-helper-text mdc-text-field-helper-text--persistent" aria-hidden="false">
63
+ You can search based on File column.
64
+ </div>
65
+
66
+ <table class="table table-hover table-condensed" id="<%= title_id %>-table">
67
+ <thead>
68
+ <tr>
69
+ <th class="width-50">File</th>
70
+ <th class="width-9 center">% Covered</th>
71
+ <th class="width-5 center">Lines</th>
72
+ <th class="width-9 center">Relevant Lines</th>
73
+ <th class="width-9 center">Lines Covered</th>
74
+ <th class="width-9 center">Lines Missed</th>
75
+ <th class="width-9 center">Avg Hits/Line</th>
76
+ </tr>
77
+ </thead>
78
+ <tbody>
79
+ <% files.each do |source_file| %>
80
+ <tr class="clickable" name="<%= shortened_filename(source_file) %>"
81
+ onclick="openModal(this.attributes.name.value)">
82
+ <td class="width-50" title="<%= shortened_filename(source_file) %>">
83
+ <div class="overflow">
84
+ <%= shortened_filename(source_file) %>
85
+ </div>
86
+ </td>
87
+ <td class="width-9 <%= coverage_class(source_file.covered_percent) %>">
88
+ <%= source_file.covered_percent.round(2).to_s %>%
89
+ </td>
90
+ <td class="width-5 center">
91
+ <%= format_number(source_file.lines.count) %>
92
+ </td>
93
+ <td class="width-9 center">
94
+ <%= format_number(source_file.covered_lines.count + source_file.missed_lines.count) %>
95
+ </td>
96
+ <td class="width-9 center">
97
+ <%= format_number(source_file.covered_lines.count) %>
98
+ </td>
99
+ <td class="width-9 center">
100
+ <%= format_number(source_file.missed_lines.count) %>
101
+ </td>
102
+ <td class="width-9 center">
103
+ <%= format_number(source_file.covered_strength) %>
104
+ </td>
105
+ </tr>
106
+ <% end %>
107
+ </tbody>
108
+ </table>
109
+ </div>
110
+ </div>
@@ -0,0 +1,90 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <title>Code Coverage for <%= SimpleCov.project_name %></title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <link href="<%= assets_path('application.css') %>" media="screen, projection, print" rel="stylesheet" type="text/css"/>
8
+ </head>
9
+
10
+ <body class="mdc-typography">
11
+ <aside class="mdc-drawer">
12
+ <div class="mdc-drawer__header">
13
+ <h3 class="mdc-drawer__title">Code Coverage</h3>
14
+ <h6 class="mdc-drawer__subtitle">
15
+ Generated using <%= result.command_name %>
16
+ </h6>
17
+ </div>
18
+ <div class="mdc-drawer__content">
19
+ <nav class="mdc-list">
20
+ <a class="mdc-list-item mdc-list-item--activated" href="#" name="AllFiles" onclick="navigate(this.name)">
21
+ <i class="material-icons mdc-list-item__graphic" aria-hidden="true">view_list</i>
22
+ <span class="mdc-list-item__text">
23
+ All Files
24
+ <span class="parenthese">
25
+ <span class="<%= coverage_class(result.source_files.covered_percent) %>">
26
+ <%= result.source_files.covered_percent.round(2) %>%
27
+ </span>
28
+ </span>
29
+ </span>
30
+ </a>
31
+ <% result.groups.each do |name, files| %>
32
+ <a class="mdc-list-item" href="#" name="<%= remove_spaces(name) %>" onclick="navigate(this.name)">
33
+ <i class="material-icons mdc-list-item__graphic" aria-hidden="true">collections_bookmark</i>
34
+ <span class="mdc-list-item__text">
35
+ <%= name %>
36
+ <span class="parenthese">
37
+ <span class="<%= coverage_class(files.covered_percent) %>">
38
+ <%= files.covered_percent.round(2)%>%
39
+ </span>
40
+ </span>
41
+ </span>
42
+ </a>
43
+ <% end %>
44
+ </nav>
45
+ </div>
46
+ </aside>
47
+ <div class="mdc-drawer-app-content">
48
+ <header class="mdc-top-app-bar mdc-top-app-bar--fixed app-bar" id="app-bar">
49
+ <div class="mdc-top-app-bar__row">
50
+ <section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
51
+ <span class="mdc-top-app-bar__title">
52
+ <%= SimpleCov.project_name.split('-').map(&:capitalize).join(' ') %>
53
+ </span>
54
+ </section>
55
+ <section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end">
56
+ Generated&nbsp;
57
+ <abbr class="timeago" datetime="<%= result.created_at %>">
58
+ <%= result.created_at %>
59
+ </abbr>
60
+ </section>
61
+ </div>
62
+ </header>
63
+ <main class="main-content" id="main-content">
64
+ <div class="mdc-top-app-bar--fixed-adjust"></div>
65
+ <%= generate_group_page("All Files", result.source_files) %>
66
+
67
+ <% result.groups.each do |name, files| %>
68
+ <%= generate_group_page(name, files) %>
69
+ <% end %>
70
+ <div class="bottom-spacer"></div>
71
+ <section class="footer">
72
+ <div>
73
+ Generated by
74
+ <a href="https://github.com/colszowka/simplecov" target="_blank">Simplecov</a>
75
+ v<%= SimpleCov::VERSION %>
76
+ and
77
+ <a href="https://github.com/chiefpansancolt/simplecov-material" target="_blank">Simplecov Material</a>
78
+ v<%= SimpleCov::Formatter::MaterialFormatter::VERSION %>
79
+ using <%= result.command_name %>
80
+ </div>
81
+ </section>
82
+ </main>
83
+ </div>
84
+
85
+ <% result.source_files.each do |source_file| %>
86
+ <%= generate_dialog(source_file) %>
87
+ <% end %>
88
+ <script src="<%= assets_path('application.js') %>" type="text/javascript"></script>
89
+ </body>
90
+ </html>
@@ -0,0 +1,81 @@
1
+ const path = require('path');
2
+ const autoprefixer = require('autoprefixer');
3
+
4
+ module.exports = {
5
+ mode: 'development',
6
+ entry: {
7
+ application: ['./dist/app.scss', './dist/app.js'],
8
+ },
9
+ output: {
10
+ filename: '[name].js',
11
+ path: path.resolve(__dirname, 'public'),
12
+ libraryTarget: 'window',
13
+ },
14
+ module: {
15
+ rules: [
16
+ {
17
+ test: /\.scss$/,
18
+ use: [
19
+ {
20
+ loader: 'file-loader',
21
+ options: {
22
+ name: 'application.css',
23
+ },
24
+ },
25
+ {loader: 'extract-loader'},
26
+ {loader: 'css-loader'},
27
+ {loader: 'postcss-loader',
28
+ options: {
29
+ plugins: () => [autoprefixer()],
30
+ },
31
+ },
32
+ {
33
+ loader: 'sass-loader',
34
+ options: {
35
+ includePaths: ['./node_modules'],
36
+ },
37
+ },
38
+ ],
39
+ },
40
+ {
41
+ test: /\.(png|svg|jpg|gif)$/,
42
+ use: [
43
+ {
44
+ loader: 'file-loader',
45
+ options: {
46
+ publicPath: 'images',
47
+ outputPath: 'images',
48
+ },
49
+ },
50
+ ],
51
+ },
52
+ {
53
+ test: /\.(woff|woff2|eot|ttf|otf)$/,
54
+ use: [
55
+ {
56
+ loader: 'file-loader',
57
+ options: {
58
+ publicPath: 'fonts',
59
+ outputPath: 'fonts',
60
+ },
61
+ },
62
+ ],
63
+ },
64
+ {
65
+ test: /\.m?js$/,
66
+ include: [
67
+ path.resolve(__dirname, 'dist'),
68
+ ],
69
+ exclude: [
70
+ path.resolve(__dirname, 'node_modules'),
71
+ ],
72
+ enforce: 'pre',
73
+ enforce: 'post',
74
+ loader: 'babel-loader',
75
+ options: {
76
+ presets: ['@babel/preset-env'],
77
+ },
78
+ },
79
+ ],
80
+ },
81
+ };