deep-cover 0.1.16 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +3 -8
- data/.travis.yml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile +3 -1
- data/README.md +9 -4
- data/Rakefile +6 -3
- data/deep_cover.gemspec +2 -2
- data/lib/deep_cover.rb +10 -0
- data/lib/deep_cover/analyser.rb +1 -2
- data/lib/deep_cover/analyser/base.rb +32 -0
- data/lib/deep_cover/analyser/branch.rb +19 -4
- data/lib/deep_cover/analyser/node.rb +52 -0
- data/lib/deep_cover/analyser/per_char.rb +18 -1
- data/lib/deep_cover/analyser/stats.rb +54 -0
- data/lib/deep_cover/backports.rb +1 -0
- data/lib/deep_cover/base.rb +17 -1
- data/lib/deep_cover/builtin_takeover.rb +5 -0
- data/lib/deep_cover/cli/deep_cover.rb +2 -1
- data/lib/deep_cover/cli/instrumented_clone_reporter.rb +12 -10
- data/lib/deep_cover/config.rb +22 -8
- data/lib/deep_cover/core_ext/coverage_replacement.rb +22 -18
- data/lib/deep_cover/coverage.rb +3 -203
- data/lib/deep_cover/coverage/analysis.rb +36 -0
- data/lib/deep_cover/coverage/base.rb +91 -0
- data/lib/deep_cover/coverage/istanbul.rb +34 -0
- data/lib/deep_cover/coverage/persistence.rb +93 -0
- data/lib/deep_cover/covered_code.rb +12 -22
- data/lib/deep_cover/custom_requirer.rb +6 -2
- data/lib/deep_cover/node/base.rb +1 -1
- data/lib/deep_cover/node/case.rb +13 -2
- data/lib/deep_cover/node/exceptions.rb +2 -2
- data/lib/deep_cover/node/if.rb +21 -2
- data/lib/deep_cover/node/mixin/flow_accounting.rb +1 -0
- data/lib/deep_cover/node/send.rb +9 -2
- data/lib/deep_cover/node/short_circuit.rb +10 -0
- data/lib/deep_cover/parser_ext/range.rb +4 -4
- data/lib/deep_cover/reporter/html.rb +15 -0
- data/lib/deep_cover/reporter/html/base.rb +14 -0
- data/lib/deep_cover/reporter/html/index.rb +78 -0
- data/lib/deep_cover/reporter/html/site.rb +78 -0
- data/lib/deep_cover/reporter/html/source.rb +136 -0
- data/lib/deep_cover/reporter/html/template/assets/32px.png +0 -0
- data/lib/deep_cover/reporter/html/template/assets/40px.png +0 -0
- data/lib/deep_cover/reporter/html/template/assets/deep_cover.css.sass +338 -0
- data/lib/deep_cover/reporter/html/template/assets/jquery-3.2.1.min.js +4 -0
- data/lib/deep_cover/reporter/html/template/assets/jquery-3.2.1.min.map +1 -0
- data/lib/deep_cover/reporter/html/template/assets/jstree.css +1108 -0
- data/lib/deep_cover/reporter/html/template/assets/jstree.js +8424 -0
- data/lib/deep_cover/reporter/html/template/assets/jstreetable.js +1069 -0
- data/lib/deep_cover/reporter/html/template/assets/throbber.gif +0 -0
- data/lib/deep_cover/reporter/html/template/index.html.erb +75 -0
- data/lib/deep_cover/reporter/html/template/source.html.erb +35 -0
- data/lib/deep_cover/reporter/html/tree.rb +55 -0
- data/lib/deep_cover/tools/content_tag.rb +11 -0
- data/lib/deep_cover/tools/covered.rb +9 -0
- data/lib/deep_cover/tools/merge.rb +16 -0
- data/lib/deep_cover/tools/render_template.rb +13 -0
- data/lib/deep_cover/tools/transform_keys.rb +9 -0
- data/lib/deep_cover/version.rb +1 -1
- metadata +33 -7
- data/lib/deep_cover/analyser/ignore_uncovered.rb +0 -21
- data/lib/deep_cover/analyser/optionally_covered.rb +0 -19
Binary file
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<script src="assets/jquery-3.2.1.min.js"></script>
|
5
|
+
<script src="assets/jstree.js"></script>
|
6
|
+
<script src="assets/jstreetable.js"></script>
|
7
|
+
<script src="https://use.fontawesome.com/81e98abb93.js"></script>
|
8
|
+
<link href="assets/jstree.css" rel="stylesheet">
|
9
|
+
<link href="assets/deep_cover.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script>
|
12
|
+
window.DeepCover = {
|
13
|
+
index: <%= stats_to_data.to_json %>,
|
14
|
+
columns: <%= columns.to_json %>
|
15
|
+
};
|
16
|
+
var numColumns = {
|
17
|
+
width: 100,
|
18
|
+
sort: function(a, b) {
|
19
|
+
return (a.executed + a.ignored > b.executed + b.ignored ? 1 : -1);
|
20
|
+
},
|
21
|
+
format: function(stats) {
|
22
|
+
var ok = stats.executed + stats.ignored;
|
23
|
+
return '' + ok + '/' + (ok + stats.not_executed);
|
24
|
+
}
|
25
|
+
};
|
26
|
+
var percentColumns = {
|
27
|
+
width: 60,
|
28
|
+
format: function(percent) {
|
29
|
+
var decile = Math.floor(percent / 10);
|
30
|
+
return '<span class="percent-' + decile + '0">' + percent + '</span>';
|
31
|
+
}
|
32
|
+
}
|
33
|
+
for(var i = 1; i < DeepCover.columns.length;) {
|
34
|
+
$.extend(DeepCover.columns[i++], numColumns);
|
35
|
+
$.extend(DeepCover.columns[i++], percentColumns);
|
36
|
+
}
|
37
|
+
</script>
|
38
|
+
|
39
|
+
<script>
|
40
|
+
$(function() {
|
41
|
+
$(".tree").jstree({
|
42
|
+
plugins: ["table","sort"],
|
43
|
+
core: {
|
44
|
+
data: DeepCover.index
|
45
|
+
},
|
46
|
+
// configure tree table
|
47
|
+
table: {
|
48
|
+
columns: DeepCover.columns,
|
49
|
+
resizable: true,
|
50
|
+
width: "100%",
|
51
|
+
height: "100%"
|
52
|
+
}
|
53
|
+
});
|
54
|
+
});
|
55
|
+
</script>
|
56
|
+
</head>
|
57
|
+
<body class="index">
|
58
|
+
<header>
|
59
|
+
<div class="content">
|
60
|
+
<div class="info"><span class="deep-cover"><span class="deep">Deep</span>Cover</span>
|
61
|
+
<span class="version">v<%= DeepCover::VERSION %></span>
|
62
|
+
</div>
|
63
|
+
</div>
|
64
|
+
</header>
|
65
|
+
<main>
|
66
|
+
<div class="tree"></div>
|
67
|
+
</main>
|
68
|
+
<footer>
|
69
|
+
<div class="details">
|
70
|
+
<span class="date"><%= Time.now %></span>
|
71
|
+
<span class="setup"><%= setup %></span>
|
72
|
+
</div>
|
73
|
+
</footer>
|
74
|
+
</body>
|
75
|
+
</html>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<base href="<%= root_path %>"/>
|
5
|
+
<script src="assets/jquery-3.2.1.min.js"></script>
|
6
|
+
<script src="https://use.fontawesome.com/81e98abb93.js"></script>
|
7
|
+
<link rel="stylesheet" href="assets/deep_cover.css" type="text/css"/>
|
8
|
+
</head>
|
9
|
+
<body class="source">
|
10
|
+
<div class="overlay">
|
11
|
+
<div class="center">
|
12
|
+
<div class="stats"><%= stats %></div>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
<header>
|
16
|
+
<div class="content">
|
17
|
+
<div class="info"><span class="deep-cover"><span class="deep">Deep</span>Cover</span>
|
18
|
+
<span class="version">v<%= DeepCover::VERSION %></span>
|
19
|
+
</div>
|
20
|
+
<div class="nav">
|
21
|
+
<a href="index.html" aria-label="Home"><i class="fa fa-home" aria-hidden="true"></i></a>
|
22
|
+
<span class="path"><%= covered_code.name %><span>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</header>
|
26
|
+
<main class="source"><%= format_source %></main>
|
27
|
+
<script>
|
28
|
+
$(function() {
|
29
|
+
$('.stats .branch').click(function() {
|
30
|
+
$('body').toggleClass('show-forks')
|
31
|
+
});
|
32
|
+
});
|
33
|
+
</script>
|
34
|
+
</body>
|
35
|
+
</html>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DeepCover
|
4
|
+
module Reporter
|
5
|
+
# Utility functions to deal with trees
|
6
|
+
module HTML::Tree
|
7
|
+
def paths_to_tree(paths)
|
8
|
+
twigs = paths.map do |path|
|
9
|
+
partials = path_to_partial_paths(path)
|
10
|
+
list_to_twig(partials)
|
11
|
+
end
|
12
|
+
tree = deep_merge(twigs)
|
13
|
+
simplify(tree)
|
14
|
+
end
|
15
|
+
|
16
|
+
# 'some/example/path' => %w[some example path]
|
17
|
+
def path_to_partial_paths(path)
|
18
|
+
path.to_s.split('/')
|
19
|
+
end
|
20
|
+
|
21
|
+
# A twig is a tree with only single branches
|
22
|
+
# [a, b, c] =>
|
23
|
+
# {a: {b: {c: {} } } }
|
24
|
+
def list_to_twig(items)
|
25
|
+
result = {}
|
26
|
+
items.inject(result) do |parent, value|
|
27
|
+
parent[value] = {}
|
28
|
+
end
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
# [{a: {b: {c: {} } } }
|
33
|
+
# {a: {b: {d: {} } } }]
|
34
|
+
# => {a: {b: {c: {}, d: {} }}}
|
35
|
+
def deep_merge(trees)
|
36
|
+
trees.inject do |result, h|
|
37
|
+
result.merge(h) { |k, val, val_b| deep_merge([val, val_b]) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# {a: {b: {c: {}, d: {} }}}
|
42
|
+
# => {a/b: {c: {}, d: {} }}
|
43
|
+
def simplify(tree)
|
44
|
+
tree.map do |key, sub_tree|
|
45
|
+
sub_tree = simplify(sub_tree)
|
46
|
+
if sub_tree.size == 1
|
47
|
+
key2, sub_tree = sub_tree.first
|
48
|
+
key = "#{key}/#{key2}"
|
49
|
+
end
|
50
|
+
[key, sub_tree]
|
51
|
+
end.to_h
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DeepCover
|
4
|
+
module Tools::ContentTag
|
5
|
+
# Poor man's content_tag. No HTML escaping included
|
6
|
+
def content_tag(tag, content, **options)
|
7
|
+
attrs = options.map { |kind, value| %{ #{kind}="#{value}"} }.join
|
8
|
+
"<#{tag}#{attrs}>#{content}</#{tag}>"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DeepCover
|
4
|
+
module Tools::Merge
|
5
|
+
def merge(*hashes)
|
6
|
+
if hashes.last.is_a?(Symbol)
|
7
|
+
oper = hashes.pop
|
8
|
+
merge(*hashes) { |a, b| a.public_send(oper, b) }
|
9
|
+
elsif !block_given?
|
10
|
+
merge(*hashes, &:last)
|
11
|
+
else
|
12
|
+
hashes.inject { |result, h| result.merge(h) { |key, a, b| yield [a, b] } }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DeepCover
|
4
|
+
module Tools::RenderTemplate
|
5
|
+
def render_template(template, bound_object)
|
6
|
+
require 'erb'
|
7
|
+
caller_path = Pathname.new(caller(1..1).first.partition(/\.rb:\d/).first).dirname
|
8
|
+
template = caller_path.join("template/#{template}.html.erb").read
|
9
|
+
erb = ERB.new(template)
|
10
|
+
erb.result(bound_object.instance_eval { binding })
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/deep_cover/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deep-cover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-André Lafortune
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parser
|
@@ -171,14 +171,14 @@ dependencies:
|
|
171
171
|
requirements:
|
172
172
|
- - "~>"
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version: '
|
174
|
+
version: '12.0'
|
175
175
|
type: :development
|
176
176
|
prerelease: false
|
177
177
|
version_requirements: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
179
|
- - "~>"
|
180
180
|
- !ruby/object:Gem::Version
|
181
|
-
version: '
|
181
|
+
version: '12.0'
|
182
182
|
- !ruby/object:Gem::Dependency
|
183
183
|
name: rspec
|
184
184
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,6 +221,7 @@ files:
|
|
221
221
|
- ".rspec_all"
|
222
222
|
- ".rubocop.yml"
|
223
223
|
- ".travis.yml"
|
224
|
+
- CHANGELOG.md
|
224
225
|
- CODE_OF_CONDUCT.md
|
225
226
|
- CONTRIBUTING.md
|
226
227
|
- Gemfile
|
@@ -244,12 +245,11 @@ files:
|
|
244
245
|
- lib/deep_cover/analyser/branch.rb
|
245
246
|
- lib/deep_cover/analyser/covered_code_source.rb
|
246
247
|
- lib/deep_cover/analyser/function.rb
|
247
|
-
- lib/deep_cover/analyser/ignore_uncovered.rb
|
248
248
|
- lib/deep_cover/analyser/node.rb
|
249
|
-
- lib/deep_cover/analyser/optionally_covered.rb
|
250
249
|
- lib/deep_cover/analyser/per_char.rb
|
251
250
|
- lib/deep_cover/analyser/per_line.rb
|
252
251
|
- lib/deep_cover/analyser/statement.rb
|
252
|
+
- lib/deep_cover/analyser/stats.rb
|
253
253
|
- lib/deep_cover/analyser/subset.rb
|
254
254
|
- lib/deep_cover/auto_run.rb
|
255
255
|
- lib/deep_cover/autoload_tracker.rb
|
@@ -265,6 +265,10 @@ files:
|
|
265
265
|
- lib/deep_cover/core_ext/load_overrides.rb
|
266
266
|
- lib/deep_cover/core_ext/require_overrides.rb
|
267
267
|
- lib/deep_cover/coverage.rb
|
268
|
+
- lib/deep_cover/coverage/analysis.rb
|
269
|
+
- lib/deep_cover/coverage/base.rb
|
270
|
+
- lib/deep_cover/coverage/istanbul.rb
|
271
|
+
- lib/deep_cover/coverage/persistence.rb
|
268
272
|
- lib/deep_cover/covered_code.rb
|
269
273
|
- lib/deep_cover/custom_requirer.rb
|
270
274
|
- lib/deep_cover/memoize.rb
|
@@ -307,25 +311,47 @@ files:
|
|
307
311
|
- lib/deep_cover/parser_ext/range.rb
|
308
312
|
- lib/deep_cover/problem_with_diagnostic.rb
|
309
313
|
- lib/deep_cover/reporter.rb
|
314
|
+
- lib/deep_cover/reporter/html.rb
|
315
|
+
- lib/deep_cover/reporter/html/base.rb
|
316
|
+
- lib/deep_cover/reporter/html/index.rb
|
317
|
+
- lib/deep_cover/reporter/html/site.rb
|
318
|
+
- lib/deep_cover/reporter/html/source.rb
|
319
|
+
- lib/deep_cover/reporter/html/template/assets/32px.png
|
320
|
+
- lib/deep_cover/reporter/html/template/assets/40px.png
|
321
|
+
- lib/deep_cover/reporter/html/template/assets/deep_cover.css.sass
|
322
|
+
- lib/deep_cover/reporter/html/template/assets/jquery-3.2.1.min.js
|
323
|
+
- lib/deep_cover/reporter/html/template/assets/jquery-3.2.1.min.map
|
324
|
+
- lib/deep_cover/reporter/html/template/assets/jstree.css
|
325
|
+
- lib/deep_cover/reporter/html/template/assets/jstree.js
|
326
|
+
- lib/deep_cover/reporter/html/template/assets/jstreetable.js
|
327
|
+
- lib/deep_cover/reporter/html/template/assets/throbber.gif
|
328
|
+
- lib/deep_cover/reporter/html/template/index.html.erb
|
329
|
+
- lib/deep_cover/reporter/html/template/source.html.erb
|
330
|
+
- lib/deep_cover/reporter/html/tree.rb
|
310
331
|
- lib/deep_cover/reporter/istanbul.rb
|
311
332
|
- lib/deep_cover/tools.rb
|
312
333
|
- lib/deep_cover/tools/builtin_coverage.rb
|
313
334
|
- lib/deep_cover/tools/camelize.rb
|
335
|
+
- lib/deep_cover/tools/content_tag.rb
|
336
|
+
- lib/deep_cover/tools/covered.rb
|
314
337
|
- lib/deep_cover/tools/dasherize.rb
|
315
338
|
- lib/deep_cover/tools/dump_covered_code.rb
|
316
339
|
- lib/deep_cover/tools/execute_sample.rb
|
317
340
|
- lib/deep_cover/tools/format.rb
|
318
341
|
- lib/deep_cover/tools/format_char_cover.rb
|
319
342
|
- lib/deep_cover/tools/format_generated_code.rb
|
343
|
+
- lib/deep_cover/tools/merge.rb
|
320
344
|
- lib/deep_cover/tools/number_lines.rb
|
321
345
|
- lib/deep_cover/tools/our_coverage.rb
|
322
346
|
- lib/deep_cover/tools/profiling.rb
|
347
|
+
- lib/deep_cover/tools/render_template.rb
|
323
348
|
- lib/deep_cover/tools/require_relative_dir.rb
|
324
349
|
- lib/deep_cover/tools/silence_warnings.rb
|
325
350
|
- lib/deep_cover/tools/slice.rb
|
351
|
+
- lib/deep_cover/tools/transform_keys.rb
|
326
352
|
- lib/deep_cover/tools/truncate_backtrace.rb
|
327
353
|
- lib/deep_cover/version.rb
|
328
|
-
homepage:
|
354
|
+
homepage: https://github.com/deep-cover/deep-cover
|
329
355
|
licenses:
|
330
356
|
- MIT
|
331
357
|
metadata: {}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeepCover
|
4
|
-
module Analyser::IgnoreUncovered
|
5
|
-
def initialize(source, ignore_uncovered: [], **options)
|
6
|
-
super
|
7
|
-
@allow_filters = Array(ignore_uncovered)
|
8
|
-
.map { |kind| :"is_#{kind}?" }
|
9
|
-
.select { |name| respond_to?(name) }
|
10
|
-
.map { |name| method(name) } # So was tempted to write `.map(&method(:method))`!
|
11
|
-
end
|
12
|
-
|
13
|
-
def node_runs(node)
|
14
|
-
runs = super
|
15
|
-
if runs == 0 && @allow_filters.any? { |f| f[node] }
|
16
|
-
runs = nil
|
17
|
-
end
|
18
|
-
runs
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeepCover
|
4
|
-
module Analyser::OptionallyCovered
|
5
|
-
def optionally_covered
|
6
|
-
@optionally_covered ||= Analyser
|
7
|
-
.constants.map { |c| Analyser.const_get(c) }
|
8
|
-
.select { |klass| klass < Analyser }
|
9
|
-
.flat_map do |klass|
|
10
|
-
klass.instance_methods(false).map do |method|
|
11
|
-
method =~ /^is_(.*)\?$/
|
12
|
-
Regexp.last_match(1)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
.compact
|
16
|
-
.map(&:to_sym)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|