simplecov-html 0.3.2 → 0.13.1
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +108 -0
- data/LICENSE +1 -1
- data/README.md +30 -0
- data/Rakefile +44 -30
- data/lib/simplecov-html/version.rb +9 -0
- data/lib/simplecov-html.rb +160 -103
- data/public/DataTables-1.10.20/images/sort_asc.png +0 -0
- data/public/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
- data/public/DataTables-1.10.20/images/sort_both.png +0 -0
- data/public/DataTables-1.10.20/images/sort_desc.png +0 -0
- data/public/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
- data/public/application.css +1 -0
- data/public/application.js +7 -0
- data/public/colorbox/border.png +0 -0
- data/public/colorbox/controls.png +0 -0
- data/public/colorbox/loading.gif +0 -0
- data/public/colorbox/loading_background.png +0 -0
- data/public/favicon_green.png +0 -0
- data/public/favicon_red.png +0 -0
- data/public/favicon_yellow.png +0 -0
- data/views/covered_percent.erb +3 -0
- data/views/file_list.erb +74 -32
- data/views/layout.erb +13 -15
- data/views/source_file.erb +56 -32
- metadata +64 -133
- data/.gitignore +0 -24
- data/README.rdoc +0 -26
- data/VERSION +0 -1
- data/assets/app.js +0 -48
- data/assets/fancybox/blank.gif +0 -0
- data/assets/fancybox/fancy_close.png +0 -0
- data/assets/fancybox/fancy_loading.png +0 -0
- data/assets/fancybox/fancy_nav_left.png +0 -0
- data/assets/fancybox/fancy_nav_right.png +0 -0
- data/assets/fancybox/fancy_shadow_e.png +0 -0
- data/assets/fancybox/fancy_shadow_n.png +0 -0
- data/assets/fancybox/fancy_shadow_ne.png +0 -0
- data/assets/fancybox/fancy_shadow_nw.png +0 -0
- data/assets/fancybox/fancy_shadow_s.png +0 -0
- data/assets/fancybox/fancy_shadow_se.png +0 -0
- data/assets/fancybox/fancy_shadow_sw.png +0 -0
- data/assets/fancybox/fancy_shadow_w.png +0 -0
- data/assets/fancybox/fancy_title_left.png +0 -0
- data/assets/fancybox/fancy_title_main.png +0 -0
- data/assets/fancybox/fancy_title_over.png +0 -0
- data/assets/fancybox/fancy_title_right.png +0 -0
- data/assets/fancybox/fancybox-x.png +0 -0
- data/assets/fancybox/fancybox-y.png +0 -0
- data/assets/fancybox/fancybox.png +0 -0
- data/assets/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/assets/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/assets/jquery-1.4.2.min.js +0 -155
- data/assets/jquery.dataTables.min.js +0 -152
- data/assets/jquery.timeago.js +0 -141
- data/assets/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/assets/stylesheet.css +0 -341
- data/simplecov-html.gemspec +0 -103
- data/test/helper.rb +0 -10
- data/test/test_simple_cov-html.rb +0 -7
- /data/{assets/smoothness → public}/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- /data/{assets/smoothness → public}/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- /data/{assets/smoothness → public}/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- /data/{assets/smoothness → public}/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- /data/{assets/smoothness → public}/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- /data/{assets/smoothness → public}/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- /data/{assets/smoothness → public}/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- /data/{assets/smoothness → public}/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- /data/{assets/smoothness → public}/images/ui-icons_222222_256x240.png +0 -0
- /data/{assets/smoothness → public}/images/ui-icons_2e83ff_256x240.png +0 -0
- /data/{assets/smoothness → public}/images/ui-icons_454545_256x240.png +0 -0
- /data/{assets/smoothness → public}/images/ui-icons_888888_256x240.png +0 -0
- /data/{assets/smoothness → public}/images/ui-icons_cd0a0a_256x240.png +0 -0
- /data/{assets → public}/loading.gif +0 -0
- /data/{assets → public}/magnify.png +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a569e518b4658566f6c74bde026cf0b489b16ff7b9f541fbeae4bf44754fa6d7
|
4
|
+
data.tar.gz: a67d0c6e72883aaed402a3d5a6e315b1536a7d4f6ceb968ef8d8d2378701299a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 00ffcd1b0f918e85bf88073dfe4df938e972575c8efec45195b376349b24775cad6ee0b7310fae8af910a8c9e45f9e2c55e554dbc2ff8458f6da6674f2d98637
|
7
|
+
data.tar.gz: bf5324db14d60e9f9a6c53569a5cd0effd8814b8e7d5ac5160416b12e1bcf05e2c839b5c51742a1c614f1370c353d7161f8ad9f286afa8028d2585302ab03981
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
0.13.1 (2024-09-09)
|
2
|
+
==================
|
3
|
+
|
4
|
+
## Misc
|
5
|
+
* Drop base64 dependency. See [#144](https://github.com/simplecov-ruby/simplecov-html/pull/144) (thanks [@Earlopain](https://github.com/Earlopain)).
|
6
|
+
|
7
|
+
0.13.0 (2024-09-08)
|
8
|
+
==================
|
9
|
+
|
10
|
+
## Enhancements
|
11
|
+
* Cache erb templates when generating report. See [#114](https://github.com/simplecov-ruby/simplecov-html/pull/114) (thanks [@fatkodima](https://github.com/fatkodima)).
|
12
|
+
* Print branch coverage with line coverage. See [#103](https://github.com/simplecov-ruby/simplecov-html/pull/103) (thanks [@jeremyevans](https://github.com/jeremyevans)).
|
13
|
+
* Add line number anchors. Thanks [@jantman](https://github.com/jantman) for the proposal [#49](https://github.com/simplecov-ruby/simplecov-html/issues/49) and [@nishidayuya](https://github.com/nishidayuya) for the patch [#106](https://github.com/simplecov-ruby/simplecov-html/pull/106)!
|
14
|
+
* Add inline assets option. See [#107](https://github.com/simplecov-ruby/simplecov-html/pull/107) (thanks [@frankh](https://github.com/frankh)).
|
15
|
+
* Make close button look better. See [#140](https://github.com/simplecov-ruby/simplecov-html/pull/140) (thanks [@anthony0030](https://github.com/anthony0030)).
|
16
|
+
* Avoid "permission denied" errors by removing the destination before copying assets [#135](https://github.com/simplecov-ruby/simplecov-html/pull/135) (thanks [@tomeon](https://github.com/tomeon)).
|
17
|
+
* Improve clarity of line and branch coverage format. See [#125](https://github.com/simplecov-ruby/simplecov-html/pull/125) (thanks [@joshuapinter](https://github.com/joshuapinter)).
|
18
|
+
|
19
|
+
## Bugfixes
|
20
|
+
* Avoid loading favicon.png that does not exist. See [#123](https://github.com/simplecov-ruby/simplecov-html/pull/123) (thanks [@yyamanoi1222](https://github.com/yyamanoi1222)).
|
21
|
+
|
22
|
+
## Misc
|
23
|
+
* Reduced gem size by not including development-only files.
|
24
|
+
* Bundle jQuery 3.7.1. See [#108](https://github.com/simplecov-ruby/simplecov-html/issues/108) (thanks [@jgarland79](https://github.com/jgarland79) for reporting the issue).
|
25
|
+
|
26
|
+
0.12.3 (2020-09-23)
|
27
|
+
==================
|
28
|
+
|
29
|
+
## Bugfixes
|
30
|
+
* Relax ruby version requirement to work with Ruby 3.0 (next version, current `ruby-head`). Thanks [@byroot](https://github.com/byroot).
|
31
|
+
|
32
|
+
0.12.2 (2020-02-27)
|
33
|
+
==================
|
34
|
+
|
35
|
+
## Bugfixes
|
36
|
+
* Refreshing the page while a source file is open works again. Thanks [@HansBug](https://github.com/HansBug) for the report [#94](https://github.com/simplecov-ruby/simplecov-html/issues/94) and [@Tietew](https://github.com/Tietew) for the fix!
|
37
|
+
|
38
|
+
0.12.1 (2020-02-23)
|
39
|
+
==================
|
40
|
+
|
41
|
+
Bugfix release to fix huge bugs that sadly test suit and maintainters didn't catch.
|
42
|
+
|
43
|
+
## Bugfixes
|
44
|
+
* Disable pagination and with it all files on 2nd page+ being broken/not able to open
|
45
|
+
* Fix display of non ASCII characters, for this you have to upgrade to simplecov 0.18.3 though (it's handled in there)
|
46
|
+
|
47
|
+
0.12.0 (2020-02-12)
|
48
|
+
==================
|
49
|
+
|
50
|
+
This release is basically a collection of long standing PRs finally merged.
|
51
|
+
Yes it looks different, no it's not a redesign - just a side effect of lots of dependency updates to improve CSP compatibility.
|
52
|
+
|
53
|
+
## Enhancements
|
54
|
+
* The HTML should now be servable with CSP settings of `default-src 'none'; script-src 'self'; img-src 'self'; style-src 'self';`
|
55
|
+
* File list is horizontally scrollable if the space doesn't suffice
|
56
|
+
* numbers are now right aligned and displayed with the same number of decimals for easier comparison and reading.
|
57
|
+
|
58
|
+
## Bugfixes
|
59
|
+
* Make sorting icons appear again
|
60
|
+
* close link tag which could cause problems when parsing as xhtml/xml
|
61
|
+
* make sure encoding errors won't crash the formatter
|
62
|
+
* When viewing a short source file while you have a big file list you will no longer be able to scroll on after the source file has ended
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
0.11.0 (2020-01-28)
|
67
|
+
=======
|
68
|
+
|
69
|
+
This release goes together with simplecov 0.18 to bring branch coverage support to you. Please also check the notes of the beta releases.
|
70
|
+
|
71
|
+
## Enhancements
|
72
|
+
* Display total branch coverage percentage in the overview (if branch coverage enabled)
|
73
|
+
|
74
|
+
0.11.0.beta2 (2020-01-19)
|
75
|
+
=======
|
76
|
+
|
77
|
+
## Enhancements
|
78
|
+
* changed display of branch coverage to be `branch_type: hit_count` which should be more expressive and more intuitive
|
79
|
+
* Cached lookup of whether we're doing branch coverage or not (should be faster)
|
80
|
+
|
81
|
+
## Bugfixes
|
82
|
+
* Fixed sorting of percent column (regression in previous release)
|
83
|
+
|
84
|
+
0.11.0.beta1 (2020-01-05)
|
85
|
+
========
|
86
|
+
|
87
|
+
Changes ruby support to 2.4+, adds branch coverage support. Meant to be used with simplecov 0.18
|
88
|
+
|
89
|
+
## Breaking Changes
|
90
|
+
* Drops support for EOL'ed ruby versions, new support is ~> 2.4
|
91
|
+
|
92
|
+
## Enhancements
|
93
|
+
* Support/display of branch coverage from simplecov 0.18.0.beta1, little badges saying `hit_count, positive_or_negative` will appear next to lines if branch coverage is activated. `0, +` means positive branch was never hit, `2, -` means negative branch was hit twice
|
94
|
+
* Encoding compatibility errors are now caught and printed out
|
95
|
+
|
96
|
+
0.10.2 (2017-08-14)
|
97
|
+
========
|
98
|
+
|
99
|
+
## Bugfixes
|
100
|
+
|
101
|
+
* Allow usage with frozen-string-literal-enabled. See [#56](https://github.com/simplecov-ruby/simplecov-html/pull/56) (thanks @pat)
|
102
|
+
|
103
|
+
0.10.1 (2017-05-17)
|
104
|
+
========
|
105
|
+
|
106
|
+
## Bugfixes
|
107
|
+
|
108
|
+
* circumvent a regression that happens in the new JRuby 9.1.9.0 release. See [#53](https://github.com/simplecov-ruby/simplecov-html/pull/53) thanks @koic
|
data/LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
Default HTML formatter for SimpleCov
|
2
|
+
====================================
|
3
|
+
|
4
|
+
***Note: To learn more about SimpleCov, check out the main repo at https://github.com/simplecov-ruby/simplecov***
|
5
|
+
|
6
|
+
Generates a nice HTML report of your SimpleCov ruby code coverage results on Ruby 2.4+ using client-side Javascript
|
7
|
+
quite extensively.
|
8
|
+
|
9
|
+
|
10
|
+
Note on Patches/Pull Requests
|
11
|
+
-----------------------------
|
12
|
+
|
13
|
+
The formatter itself has no actual tests. Instead, it is tested in the cucumber features of simplecov itself. If you
|
14
|
+
modify the formatter, please make sure the simplecov test suites still pass by doing the following:
|
15
|
+
|
16
|
+
* Clone simplecov into the parent directory of your simplecov-html checkout
|
17
|
+
* `cd` there, run `bundle`
|
18
|
+
* You should end up with all dev dependencies installed and simplecov-html being used from your disk
|
19
|
+
* Run the tests (units and features)
|
20
|
+
|
21
|
+
Please remember to add tests if you add functionality.
|
22
|
+
|
23
|
+
**Important:** If you modify the JS/CSS assets, you'll have to precompile them using `rake assets:compile` - otherwise,
|
24
|
+
your changes will not be included in your coverage reports.
|
25
|
+
|
26
|
+
|
27
|
+
Copyright
|
28
|
+
---------
|
29
|
+
|
30
|
+
Copyright (c) 2010-2013 Christoph Olszowka. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,41 +1,55 @@
|
|
1
|
-
|
2
|
-
require 'rake'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
gem.homepage = "http://github.com/colszowka/simplecov-html"
|
12
|
-
gem.authors = ["Christoph Olszowka"]
|
13
|
-
gem.add_dependency "simplecov", "~> 0.3.0"
|
14
|
-
gem.add_development_dependency "shoulda", "= 2.10.3"
|
15
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
-
end
|
17
|
-
Jeweler::GemcutterTasks.new
|
18
|
-
rescue LoadError
|
19
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
3
|
+
require "bundler"
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
# See https://github.com/simplecov-ruby/simplecov/issues/171
|
7
|
+
desc "Set permissions on all files so they are compatible with both user-local and system-wide installs"
|
8
|
+
task :fix_permissions do
|
9
|
+
system 'bash -c "find . -type f -exec chmod 644 {} \; && find . -type d -exec chmod 755 {} \;"'
|
20
10
|
end
|
11
|
+
# Enforce proper permissions on each build
|
12
|
+
Rake::Task[:build].prerequisites.unshift :fix_permissions
|
21
13
|
|
22
|
-
require
|
14
|
+
require "rake/testtask"
|
23
15
|
Rake::TestTask.new(:test) do |test|
|
24
|
-
test.libs <<
|
25
|
-
test.pattern =
|
16
|
+
test.libs << "lib" << "test"
|
17
|
+
test.pattern = "test/**/test_*.rb"
|
26
18
|
test.verbose = true
|
27
19
|
end
|
28
20
|
|
29
|
-
|
21
|
+
begin
|
22
|
+
require "rubocop/rake_task"
|
23
|
+
RuboCop::RakeTask.new
|
24
|
+
rescue LoadError
|
25
|
+
task :rubocop do
|
26
|
+
warn "Rubocop is disabled"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
task default: [:test, :rubocop]
|
30
31
|
|
31
|
-
|
32
|
+
namespace :assets do
|
33
|
+
desc "Compiles all assets"
|
34
|
+
task :compile do
|
35
|
+
puts "Compiling assets"
|
36
|
+
require "sprockets"
|
37
|
+
require "sprockets/sass_processor"
|
32
38
|
|
33
|
-
|
34
|
-
|
35
|
-
|
39
|
+
Sprockets.register_processor("text/css") do |input|
|
40
|
+
{data: input[:data].gsub(/(?<!-|_)url\(['"]?(.+?)['"]?\)/) { "asset-data-url(\"#{Regexp.last_match(1)}\")" }}
|
41
|
+
end
|
36
42
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
Sprockets.register_processor "text/css", Sprockets::ScssProcessor
|
44
|
+
|
45
|
+
assets = Sprockets::Environment.new do |env|
|
46
|
+
env.append_path "assets/javascripts"
|
47
|
+
env.append_path "assets/stylesheets"
|
48
|
+
env.append_path "public"
|
49
|
+
env.js_compressor = :uglify
|
50
|
+
env.css_compressor = :scss
|
51
|
+
end
|
52
|
+
assets["application.js"].write_to("public/application.js")
|
53
|
+
assets["application.css"].write_to("public/application.css")
|
54
|
+
end
|
41
55
|
end
|
data/lib/simplecov-html.rb
CHANGED
@@ -1,109 +1,166 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "erb"
|
4
|
+
require "cgi"
|
5
|
+
require "fileutils"
|
6
|
+
require "digest/sha1"
|
7
|
+
require "time"
|
8
|
+
|
9
|
+
# Ensure we are using a compatible version of SimpleCov
|
10
|
+
major, minor, patch = SimpleCov::VERSION.scan(/\d+/).first(3).map(&:to_i)
|
11
|
+
if major < 0 || minor < 9 || patch < 0
|
12
|
+
raise "The version of SimpleCov you are using is too old. " \
|
13
|
+
"Please update with `gem install simplecov` or `bundle update simplecov`"
|
10
14
|
end
|
11
15
|
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
16
|
+
module SimpleCov
|
17
|
+
module Formatter
|
18
|
+
class HTMLFormatter
|
19
|
+
def initialize
|
20
|
+
@branchable_result = SimpleCov.branch_coverage?
|
21
|
+
@templates = {}
|
22
|
+
@inline_assets = !ENV["SIMPLECOV_INLINE_ASSETS"].nil?
|
23
|
+
@public_assets_dir = File.join(File.dirname(__FILE__), "../public/")
|
24
|
+
end
|
25
|
+
|
26
|
+
def format(result)
|
27
|
+
unless @inline_assets
|
28
|
+
Dir[File.join(@public_assets_dir, "*")].each do |path|
|
29
|
+
FileUtils.cp_r(path, asset_output_path, remove_destination: true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
File.open(File.join(output_path, "index.html"), "wb") do |file|
|
34
|
+
file.puts template("layout").result(binding)
|
35
|
+
end
|
36
|
+
puts output_message(result)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def branchable_result?
|
42
|
+
# cached in initialize because we truly look it up a whole bunch of times
|
43
|
+
# and it's easier to cache here then in SimpleCov because there we might
|
44
|
+
# still enable/disable branch coverage criterion
|
45
|
+
@branchable_result
|
46
|
+
end
|
47
|
+
|
48
|
+
def line_status?(source_file, line)
|
49
|
+
if branchable_result? && source_file.line_with_missed_branch?(line.number)
|
50
|
+
"missed-branch"
|
51
|
+
else
|
52
|
+
line.status
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def output_message(result)
|
57
|
+
output = "Coverage report generated for #{result.command_name} to #{output_path}."
|
58
|
+
output += "\nLine Coverage: #{result.covered_percent.round(2)}% (#{result.covered_lines} / #{result.total_lines})"
|
59
|
+
output += "\nBranch Coverage: #{result.coverage_statistics[:branch].percent.round(2)}% (#{result.covered_branches} / #{result.total_branches})" if branchable_result?
|
60
|
+
output
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns the an erb instance for the template of given name
|
64
|
+
def template(name)
|
65
|
+
@templates[name] ||= ERB.new(File.read(File.join(File.dirname(__FILE__), "../views/", "#{name}.erb")))
|
66
|
+
end
|
67
|
+
|
68
|
+
def output_path
|
69
|
+
SimpleCov.coverage_path
|
70
|
+
end
|
71
|
+
|
72
|
+
def asset_output_path
|
73
|
+
return @asset_output_path if defined?(@asset_output_path) && @asset_output_path
|
74
|
+
|
75
|
+
@asset_output_path = File.join(output_path, "assets", SimpleCov::Formatter::HTMLFormatter::VERSION)
|
76
|
+
FileUtils.mkdir_p(@asset_output_path)
|
77
|
+
@asset_output_path
|
78
|
+
end
|
79
|
+
|
80
|
+
def assets_path(name)
|
81
|
+
return asset_inline(name) if @inline_assets
|
82
|
+
|
83
|
+
File.join("./assets", SimpleCov::Formatter::HTMLFormatter::VERSION, name)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Only have a few content types, just hardcode them
|
87
|
+
CONTENT_TYPES = {
|
88
|
+
".js" => "text/javascript",
|
89
|
+
".png" => "image/png",
|
90
|
+
".gif" => "image/gif",
|
91
|
+
".css" => "text/css",
|
92
|
+
}.freeze
|
93
|
+
|
94
|
+
def asset_inline(name)
|
95
|
+
path = File.join(@public_assets_dir, name)
|
96
|
+
# Equivalent to `Base64.strict_encode64(File.read(path))` but without depending on Base64
|
97
|
+
base64_content = [File.read(path)].pack("m0")
|
98
|
+
|
99
|
+
content_type = CONTENT_TYPES[File.extname(name)]
|
100
|
+
|
101
|
+
"data:#{content_type};base64,#{base64_content}"
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns the html for the given source_file
|
105
|
+
def formatted_source_file(source_file)
|
106
|
+
template("source_file").result(binding)
|
107
|
+
rescue Encoding::CompatibilityError => e
|
108
|
+
puts "Encoding problems with file #{source_file.filename}. Simplecov/ERB can't handle non ASCII characters in filenames. Error: #{e.message}."
|
109
|
+
end
|
110
|
+
|
111
|
+
# Returns a table containing the given source files
|
112
|
+
def formatted_file_list(title, source_files)
|
113
|
+
title_id = title.gsub(/^[^a-zA-Z]+/, "").gsub(/[^a-zA-Z0-9\-_]/, "")
|
114
|
+
# Silence a warning by using the following variable to assign to itself:
|
115
|
+
# "warning: possibly useless use of a variable in void context"
|
116
|
+
# The variable is used by ERB via binding.
|
117
|
+
title_id = title_id # rubocop:disable Lint/SelfAssignment
|
118
|
+
template("file_list").result(binding)
|
119
|
+
end
|
120
|
+
|
121
|
+
def covered_percent(percent)
|
122
|
+
template("covered_percent").result(binding)
|
123
|
+
end
|
124
|
+
|
125
|
+
def coverage_css_class(covered_percent)
|
126
|
+
if covered_percent > 90
|
127
|
+
"green"
|
128
|
+
elsif covered_percent > 80
|
129
|
+
"yellow"
|
130
|
+
else
|
131
|
+
"red"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def strength_css_class(covered_strength)
|
136
|
+
if covered_strength > 1
|
137
|
+
"green"
|
138
|
+
elsif covered_strength == 1
|
139
|
+
"yellow"
|
140
|
+
else
|
141
|
+
"red"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# Return a (kind of) unique id for the source file given. Uses SHA1 on path for the id
|
146
|
+
def id(source_file)
|
147
|
+
Digest::SHA1.hexdigest(source_file.filename)
|
148
|
+
end
|
149
|
+
|
150
|
+
def timeago(time)
|
151
|
+
"<abbr class=\"timeago\" title=\"#{time.iso8601}\">#{time.iso8601}</abbr>"
|
152
|
+
end
|
153
|
+
|
154
|
+
def shortened_filename(source_file)
|
155
|
+
source_file.filename.sub(SimpleCov.root, ".").gsub(/^\.\//, "")
|
156
|
+
end
|
157
|
+
|
158
|
+
def link_to_source_file(source_file)
|
159
|
+
%(<a href="##{id source_file}" class="src_link" title="#{shortened_filename source_file}">#{shortened_filename source_file}</a>)
|
160
|
+
end
|
87
161
|
end
|
88
162
|
end
|
89
|
-
|
90
|
-
# Return a (kind of) unique id for the source file given. Uses SHA1 on path for the id
|
91
|
-
def id(source_file)
|
92
|
-
Digest::SHA1.hexdigest(source_file.filename)
|
93
|
-
end
|
94
|
-
|
95
|
-
def timeago(time)
|
96
|
-
"<abbr class=\"timeago\" title=\"#{time.iso8601}\">#{time.iso8601}</abbr>"
|
97
|
-
end
|
98
|
-
|
99
|
-
def shortened_filename(source_file)
|
100
|
-
source_file.filename.gsub(SimpleCov.root, '.')
|
101
|
-
end
|
102
|
-
|
103
|
-
def link_to_source_file(source_file)
|
104
|
-
%Q(<a href="##{id source_file}" class="src_link" title="#{shortened_filename source_file}">#{shortened_filename source_file}</a>)
|
105
|
-
end
|
106
163
|
end
|
107
164
|
|
108
|
-
|
109
|
-
|
165
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
|
166
|
+
require "simplecov-html/version"
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|