spoom 1.1.11 → 1.1.13

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.
@@ -7,50 +7,52 @@ module Spoom
7
7
  module Coverage
8
8
  module D3
9
9
  class CircleMap < Base
10
- extend T::Sig
10
+ class << self
11
+ extend T::Sig
11
12
 
12
- sig { returns(String) }
13
- def self.header_style
14
- <<~CSS
15
- .node {
16
- cursor: pointer;
17
- }
13
+ sig { returns(String) }
14
+ def header_style
15
+ <<~CSS
16
+ .node {
17
+ cursor: pointer;
18
+ }
18
19
 
19
- .node:hover {
20
- stroke: #333;
21
- stroke-width: 1px;
22
- }
20
+ .node:hover {
21
+ stroke: #333;
22
+ stroke-width: 1px;
23
+ }
23
24
 
24
- .label.dir {
25
- fill: #333;
26
- }
25
+ .label.dir {
26
+ fill: #333;
27
+ }
27
28
 
28
- .label.file {
29
- font: 12px Arial, sans-serif;
30
- }
29
+ .label.file {
30
+ font: 12px Arial, sans-serif;
31
+ }
31
32
 
32
- .node.root, .node.file {
33
- pointer-events: none;
34
- }
35
- CSS
36
- end
33
+ .node.root, .node.file {
34
+ pointer-events: none;
35
+ }
36
+ CSS
37
+ end
37
38
 
38
- sig { returns(String) }
39
- def self.header_script
40
- <<~JS
41
- function treeHeight(root, height = 0) {
42
- height += 1;
43
- if (root.children && root.children.length > 0)
44
- return Math.max(...root.children.map(child => treeHeight(child, height)));
45
- else
46
- return height;
47
- }
39
+ sig { returns(String) }
40
+ def header_script
41
+ <<~JS
42
+ function treeHeight(root, height = 0) {
43
+ height += 1;
44
+ if (root.children && root.children.length > 0)
45
+ return Math.max(...root.children.map(child => treeHeight(child, height)));
46
+ else
47
+ return height;
48
+ }
48
49
 
49
- function tooltipMap(d) {
50
- moveTooltip(d)
51
- .html("<b>" + d.data.name + "</b>")
52
- }
53
- JS
50
+ function tooltipMap(d) {
51
+ moveTooltip(d)
52
+ .html("<b>" + d.data.name + "</b>")
53
+ }
54
+ JS
55
+ end
54
56
  end
55
57
 
56
58
  sig { override.returns(String) }
@@ -159,6 +161,7 @@ module Spoom
159
161
  if node.children.empty?
160
162
  return { name: node.name, strictness: tree_node_strictness(node) }
161
163
  end
164
+
162
165
  {
163
166
  name: node.name,
164
167
  children: node.children.values.map { |n| tree_node_to_json(n) },
@@ -18,34 +18,38 @@ module Spoom
18
18
  @title = title
19
19
  end
20
20
 
21
- sig { returns(String) }
22
- def self.header_style
23
- <<~CSS
24
- .pie .title {
25
- font: 18px Arial, sans-serif;
26
- font-weight: bold;
27
- fill: #212529;
28
- text-anchor: middle;
29
- pointer-events: none;
30
- }
21
+ class << self
22
+ extend T::Sig
31
23
 
32
- .pie .arc {
33
- stroke: #fff;
34
- stroke-width: 2px;
35
- }
36
- CSS
37
- end
24
+ sig { returns(String) }
25
+ def header_style
26
+ <<~CSS
27
+ .pie .title {
28
+ font: 18px Arial, sans-serif;
29
+ font-weight: bold;
30
+ fill: #212529;
31
+ text-anchor: middle;
32
+ pointer-events: none;
33
+ }
38
34
 
39
- sig { returns(String) }
40
- def self.header_script
41
- <<~JS
42
- function tooltipPie(d, title, kind, sum) {
43
- moveTooltip(d)
44
- .html("<b>" + title + "</b><br><br>"
45
- + "<b>" + d.data.value + "</b> " + kind + "<br>"
46
- + "<b>" + toPercent(d.data.value, sum) + "</b>%")
47
- }
48
- JS
35
+ .pie .arc {
36
+ stroke: #fff;
37
+ stroke-width: 2px;
38
+ }
39
+ CSS
40
+ end
41
+
42
+ sig { returns(String) }
43
+ def header_script
44
+ <<~JS
45
+ function tooltipPie(d, title, kind, sum) {
46
+ moveTooltip(d)
47
+ .html("<b>" + title + "</b><br><br>"
48
+ + "<b>" + d.data.value + "</b> " + kind + "<br>"
49
+ + "<b>" + toPercent(d.data.value, sum) + "</b>%")
50
+ }
51
+ JS
52
+ end
49
53
  end
50
54
 
51
55
  sig { override.returns(String) }
@@ -121,14 +125,14 @@ module Spoom
121
125
 
122
126
  sig { params(id: String, title: String, snapshot: Snapshot).void }
123
127
  def initialize(id, title, snapshot)
124
- super(id, title, snapshot.sigils.select { |_k, v| v })
128
+ super(id, title, snapshot.sigils_excluding_rbis.select { |_k, v| v })
125
129
  end
126
130
 
127
131
  sig { override.returns(String) }
128
132
  def tooltip
129
133
  <<~JS
130
134
  function tooltip_#{id}(d) {
131
- tooltipPie(d, "typed: " + d.data.key, "files", sum_#{id});
135
+ tooltipPie(d, "typed: " + d.data.key, "files excluding RBIs", sum_#{id});
132
136
  }
133
137
  JS
134
138
  end
@@ -157,14 +161,21 @@ module Spoom
157
161
 
158
162
  sig { params(id: String, title: String, snapshot: Snapshot).void }
159
163
  def initialize(id, title, snapshot)
160
- super(id, title, { true: snapshot.methods_with_sig, false: snapshot.methods_without_sig })
164
+ super(
165
+ id,
166
+ title,
167
+ { true: snapshot.methods_with_sig_excluding_rbis, false: snapshot.methods_without_sig_excluding_rbis }
168
+ )
161
169
  end
162
170
 
163
171
  sig { override.returns(String) }
164
172
  def tooltip
165
173
  <<~JS
166
174
  function tooltip_#{id}(d) {
167
- tooltipPie(d, (d.data.key == "true" ? " with" : " without") + " a signature", "methods", sum_#{id})
175
+ tooltipPie(
176
+ d,
177
+ (d.data.key == "true" ? " with" : " without") + " a signature", "methods excluding RBIs", sum_#{id}
178
+ )
168
179
  }
169
180
  JS
170
181
  end
@@ -18,79 +18,83 @@ module Spoom
18
18
  @keys = keys
19
19
  end
20
20
 
21
- sig { returns(String) }
22
- def self.header_style
23
- <<~CSS
24
- .domain {
25
- stroke: transparent;
26
- }
21
+ class << self
22
+ extend T::Sig
27
23
 
28
- .grid line {
29
- stroke: #ccc;
30
- }
24
+ sig { returns(String) }
25
+ def header_style
26
+ <<~CSS
27
+ .domain {
28
+ stroke: transparent;
29
+ }
31
30
 
32
- .axis text {
33
- font: 12px Arial, sans-serif;
34
- fill: #333;
35
- text-anchor: right;
36
- pointer-events: none;
37
- }
31
+ .grid line {
32
+ stroke: #ccc;
33
+ }
38
34
 
39
- .area {
40
- fill-opacity: 0.5;
41
- }
35
+ .axis text {
36
+ font: 12px Arial, sans-serif;
37
+ fill: #333;
38
+ text-anchor: right;
39
+ pointer-events: none;
40
+ }
42
41
 
43
- .line {
44
- stroke-width: 2;
45
- fill: transparent;
46
- }
42
+ .area {
43
+ fill-opacity: 0.5;
44
+ }
47
45
 
48
- .dot {
49
- r: 2;
50
- fill: #888;
51
- }
46
+ .line {
47
+ stroke-width: 2;
48
+ fill: transparent;
49
+ }
52
50
 
53
- .inverted .grid line {
54
- stroke: #777;
55
- }
51
+ .dot {
52
+ r: 2;
53
+ fill: #888;
54
+ }
56
55
 
57
- .inverted .area {
58
- fill-opacity: 0.9;
59
- }
56
+ .inverted .grid line {
57
+ stroke: #777;
58
+ }
60
59
 
61
- .inverted .axis text {
62
- fill: #fff;
63
- }
60
+ .inverted .area {
61
+ fill-opacity: 0.9;
62
+ }
64
63
 
65
- .inverted .axis line {
66
- stroke: #fff;
67
- }
64
+ .inverted .axis text {
65
+ fill: #fff;
66
+ }
68
67
 
69
- .inverted .dot {
70
- fill: #fff;
71
- }
72
- CSS
73
- end
68
+ .inverted .axis line {
69
+ stroke: #fff;
70
+ }
74
71
 
75
- sig { returns(String) }
76
- def self.header_script
77
- <<~JS
78
- var parseVersion = function(version) {
79
- if (!version) {
80
- return null;
72
+ .inverted .dot {
73
+ fill: #fff;
81
74
  }
82
- return parseFloat(version.replaceAll("0.", ""));
83
- }
75
+ CSS
76
+ end
84
77
 
85
- function tooltipTimeline(d, kind) {
86
- moveTooltip(d)
87
- .html("commit <b>" + d.data.commit + "</b><br>"
88
- + d3.timeFormat("%y/%m/%d")(parseDate(d.data.timestamp)) + "<br><br>"
89
- + "<b>typed: " + d.key + "</b><br><br>"
90
- + "<b>" + (d.data.values[d.key] ? d.data.values[d.key] : 0) + "</b> " + kind +"<br>"
91
- + "<b>" + toPercent(d.data.values[d.key] ? d.data.values[d.key] : 0, d.data.total) + "%")
92
- }
93
- JS
78
+ sig { returns(String) }
79
+ def header_script
80
+ <<~JS
81
+ var parseVersion = function(version) {
82
+ if (!version) {
83
+ return null;
84
+ }
85
+ return parseFloat(version.replaceAll("0.", ""));
86
+ }
87
+
88
+ function tooltipTimeline(d, kind) {
89
+ moveTooltip(d)
90
+ .html("commit <b>" + d.data.commit + "</b><br>"
91
+ + d3.timeFormat("%y/%m/%d")(parseDate(d.data.timestamp)) + "<br><br>"
92
+ + "<b>typed: " + d.key + "</b><br><br>"
93
+ + "<b>" + (d.data.values[d.key] ? d.data.values[d.key] : 0) + "</b> " + kind +"<br>"
94
+ + "<b>" + toPercent(d.data.values[d.key] ? d.data.values[d.key] : 0, d.data.total) + "%")
95
+ }
96
+ JS
97
+ end
94
98
  end
95
99
 
96
100
  sig { override.returns(String) }
@@ -264,13 +268,13 @@ module Spoom
264
268
  d3.min(data_#{id}, (d) => parseVersion(d.runtime))]) - 0.01",
265
269
  max: "d3.max([d3.max(data_#{id}, (d) => parseVersion(d.static)),
266
270
  d3.max(data_#{id}, (d) => parseVersion(d.runtime))]) + 0.01",
267
- ticks: 'ticks(8)'
271
+ ticks: "ticks(8)",
268
272
  )}
269
- #{line(y: 'parseVersion(d.runtime)', color: '#e83e8c', curve: 'curveStepAfter')}
270
- #{line(y: 'parseVersion(d.static)', color: '#007bff', curve: 'curveStepAfter')}
271
- #{points(y: 'parseVersion(d.static)')}
273
+ #{line(y: "parseVersion(d.runtime)", color: "#e83e8c", curve: "curveStepAfter")}
274
+ #{line(y: "parseVersion(d.static)", color: "#007bff", curve: "curveStepAfter")}
275
+ #{points(y: "parseVersion(d.static)")}
272
276
  #{x_ticks}
273
- #{y_ticks(ticks: 'ticks(4)', format: "'v0.' + d.toFixed(2)", padding: 50)}
277
+ #{y_ticks(ticks: "ticks(4)", format: "'v0.' + d.toFixed(2)", padding: 50)}
274
278
  JS
275
279
  end
276
280
  end
@@ -308,15 +312,15 @@ module Spoom
308
312
  <<~JS
309
313
  #{x_scale}
310
314
  #{y_scale(
311
- min: '0',
315
+ min: "0",
312
316
  max: "d3.max(data_#{id}, (d) => d.runtime)",
313
- ticks: 'ticks(10)'
317
+ ticks: "ticks(10)",
314
318
  )}
315
- #{area(y: 'd.runtime')}
316
- #{line(y: 'd.runtime')}
317
- #{points(y: 'd.runtime')}
319
+ #{area(y: "d.runtime")}
320
+ #{line(y: "d.runtime")}
321
+ #{points(y: "d.runtime")}
318
322
  #{x_ticks}
319
- #{y_ticks(ticks: 'ticks(5)', format: 'd.toFixed(2) + "s"', padding: 40)}
323
+ #{y_ticks(ticks: "ticks(5)", format: 'd.toFixed(2) + "s"', padding: 40)}
320
324
  .call(g => g.selectAll(".tick:first-of-type text").remove())
321
325
  JS
322
326
  end
@@ -373,15 +377,15 @@ module Spoom
373
377
  def plot
374
378
  <<~JS
375
379
  #{x_scale}
376
- #{y_scale(min: '0', max: '100', ticks: 'tickValues([0, 25, 50, 75, 100])')}
377
- #{line(y: 'd.data.timestamp')}
380
+ #{y_scale(min: "0", max: "100", ticks: "tickValues([0, 25, 50, 75, 100])")}
381
+ #{line(y: "d.data.timestamp")}
378
382
  #{x_ticks}
379
- #{y_ticks(ticks: 'tickValues([25, 50, 75])', format: "d + '%'", padding: 30)}
383
+ #{y_ticks(ticks: "tickValues([25, 50, 75])", format: "d + '%'", padding: 30)}
380
384
  JS
381
385
  end
382
386
 
383
387
  sig { override.params(y: String, color: String, curve: String).returns(String) }
384
- def line(y:, color: 'strictnessColor(d.key)', curve: 'curveCatmullRom.alpha(1)')
388
+ def line(y:, color: "strictnessColor(d.key)", curve: "curveCatmullRom.alpha(1)")
385
389
  <<~JS
386
390
  var area_#{id} = d3.area()
387
391
  .x((d) => xScale_#{id}(parseDate(#{y})))
@@ -424,8 +428,8 @@ module Spoom
424
428
  {
425
429
  timestamp: snapshot.commit_timestamp,
426
430
  commit: snapshot.commit_sha,
427
- total: snapshot.files,
428
- values: snapshot.sigils,
431
+ total: snapshot.files - snapshot.rbi_files,
432
+ values: snapshot.sigils_excluding_rbis,
429
433
  }
430
434
  end
431
435
  super(id, data, keys)
@@ -435,7 +439,7 @@ module Spoom
435
439
  def tooltip
436
440
  <<~JS
437
441
  function tooltip_#{id}(d) {
438
- tooltipTimeline(d, "files");
442
+ tooltipTimeline(d, "files excluding RBIs");
439
443
  }
440
444
  JS
441
445
  end
@@ -446,7 +450,7 @@ module Spoom
446
450
 
447
451
  sig { params(id: String, snapshots: T::Array[Snapshot]).void }
448
452
  def initialize(id, snapshots)
449
- keys = ['false', 'true']
453
+ keys = ["false", "true"]
450
454
  data = snapshots.map do |snapshot|
451
455
  {
452
456
  timestamp: snapshot.commit_timestamp,
@@ -473,13 +477,16 @@ module Spoom
473
477
 
474
478
  sig { params(id: String, snapshots: T::Array[Snapshot]).void }
475
479
  def initialize(id, snapshots)
476
- keys = ['false', 'true']
480
+ keys = ["false", "true"]
477
481
  data = snapshots.map do |snapshot|
478
482
  {
479
483
  timestamp: snapshot.commit_timestamp,
480
484
  commit: snapshot.commit_sha,
481
- total: snapshot.methods_with_sig + snapshot.methods_without_sig,
482
- values: { true: snapshot.methods_with_sig, false: snapshot.methods_without_sig },
485
+ total: snapshot.methods_with_sig_excluding_rbis + snapshot.methods_without_sig_excluding_rbis,
486
+ values: {
487
+ true: snapshot.methods_with_sig_excluding_rbis,
488
+ false: snapshot.methods_without_sig_excluding_rbis,
489
+ },
483
490
  }
484
491
  end
485
492
  super(id, data, keys)
@@ -489,7 +496,7 @@ module Spoom
489
496
  def tooltip
490
497
  <<~JS
491
498
  function tooltip_#{id}(d) {
492
- tooltipTimeline(d, "methods");
499
+ tooltipTimeline(d, "methods excluding RBIs");
493
500
  }
494
501
  JS
495
502
  end
@@ -500,7 +507,7 @@ module Spoom
500
507
 
501
508
  sig { params(id: String, snapshots: T::Array[Snapshot]).void }
502
509
  def initialize(id, snapshots)
503
- keys = ['rbis', 'files']
510
+ keys = ["rbis", "files"]
504
511
  data = snapshots.map do |snapshot|
505
512
  {
506
513
  timestamp: snapshot.commit_timestamp,
@@ -567,7 +574,7 @@ module Spoom
567
574
  end
568
575
 
569
576
  sig { override.params(y: String, color: String, curve: String).returns(String) }
570
- def line(y:, color: 'strictnessColor(d.key)', curve: 'curveCatmullRom.alpha(1)')
577
+ def line(y:, color: "strictnessColor(d.key)", curve: "curveCatmullRom.alpha(1)")
571
578
  <<~JS
572
579
  var area_#{id} = d3.area()
573
580
  .x((d) => xScale_#{id}(parseDate(#{y})))
@@ -610,10 +617,10 @@ module Spoom
610
617
  def plot
611
618
  <<~JS
612
619
  #{x_scale}
613
- #{y_scale(min: '0', max: "d3.max(data_#{id}, (d) => d.total + 10)", ticks: 'tickValues([0, 25, 50, 75, 100])')}
614
- #{line(y: 'd.data.timestamp', color: "d.key == 'rbis' ? '#8673ff' : '#007bff'")}
620
+ #{y_scale(min: "0", max: "d3.max(data_#{id}, (d) => d.total + 10)", ticks: "tickValues([0, 25, 50, 75, 100])")}
621
+ #{line(y: "d.data.timestamp", color: "d.key == 'rbis' ? '#8673ff' : '#007bff'")}
615
622
  #{x_ticks}
616
- #{y_ticks(ticks: 'tickValues([25, 50, 75])', format: 'd', padding: 20)}
623
+ #{y_ticks(ticks: "tickValues([25, 50, 75])", format: "d", padding: 20)}
617
624
  JS
618
625
  end
619
626
  end
@@ -8,94 +8,96 @@ require_relative "d3/timeline"
8
8
  module Spoom
9
9
  module Coverage
10
10
  module D3
11
- extend T::Sig
12
-
13
11
  COLOR_IGNORE = "#999"
14
12
  COLOR_FALSE = "#db4437"
15
13
  COLOR_TRUE = "#0f9d58"
16
14
  COLOR_STRICT = "#0a7340"
17
15
  COLOR_STRONG = "#064828"
18
16
 
19
- sig { returns(String) }
20
- def self.header_style
21
- <<~CSS
22
- svg {
23
- width: 100%;
24
- height: 100%;
25
- }
17
+ class << self
18
+ extend T::Sig
26
19
 
27
- .tooltip {
28
- font: 12px Arial, sans-serif;
29
- color: #fff;
30
- text-align: center;
31
- background: rgba(0, 0, 0, 0.6);
32
- padding: 5px;
33
- border: 0px;
34
- border-radius: 4px;
35
- position: absolute;
36
- top: 0;
37
- left: 0;
38
- opacity: 0;
39
- }
20
+ sig { returns(String) }
21
+ def header_style
22
+ <<~CSS
23
+ svg {
24
+ width: 100%;
25
+ height: 100%;
26
+ }
40
27
 
41
- .label {
42
- font: 14px Arial, sans-serif;
43
- font-weight: bold;
44
- fill: #fff;
45
- text-anchor: middle;
46
- pointer-events: none;
47
- }
28
+ .tooltip {
29
+ font: 12px Arial, sans-serif;
30
+ color: #fff;
31
+ text-align: center;
32
+ background: rgba(0, 0, 0, 0.6);
33
+ padding: 5px;
34
+ border: 0px;
35
+ border-radius: 4px;
36
+ position: absolute;
37
+ top: 0;
38
+ left: 0;
39
+ opacity: 0;
40
+ }
48
41
 
49
- .label .small {
50
- font-size: 10px;
51
- }
42
+ .label {
43
+ font: 14px Arial, sans-serif;
44
+ font-weight: bold;
45
+ fill: #fff;
46
+ text-anchor: middle;
47
+ pointer-events: none;
48
+ }
52
49
 
53
- #{Pie.header_style}
54
- #{CircleMap.header_style}
55
- #{Timeline.header_style}
56
- CSS
57
- end
50
+ .label .small {
51
+ font-size: 10px;
52
+ }
53
+
54
+ #{Pie.header_style}
55
+ #{CircleMap.header_style}
56
+ #{Timeline.header_style}
57
+ CSS
58
+ end
58
59
 
59
- sig { params(palette: ColorPalette).returns(String) }
60
- def self.header_script(palette)
61
- <<~JS
62
- var parseDate = d3.timeParse("%s");
60
+ sig { params(palette: ColorPalette).returns(String) }
61
+ def header_script(palette)
62
+ <<~JS
63
+ var parseDate = d3.timeParse("%s");
63
64
 
64
- function strictnessColor(strictness) {
65
- switch(strictness) {
66
- case "ignore":
67
- return "#{palette.ignore}";
68
- case "false":
69
- return "#{palette.false}";
70
- case "true":
71
- return "#{palette.true}";
72
- case "strict":
73
- return "#{palette.strict}";
74
- case "strong":
75
- return "#{palette.strong}";
65
+ function strictnessColor(strictness) {
66
+ switch(strictness) {
67
+ case "ignore":
68
+ return "#{palette.ignore}";
69
+ case "false":
70
+ return "#{palette.false}";
71
+ case "true":
72
+ return "#{palette.true}";
73
+ case "strict":
74
+ return "#{palette.strict}";
75
+ case "strong":
76
+ return "#{palette.strong}";
77
+ }
78
+ return "#{palette.false}";
76
79
  }
77
- return "#{palette.false}";
78
- }
79
80
 
80
- function toPercent(value, sum) {
81
- return value ? Math.round(value * 100 / sum) : 0;
82
- }
81
+ function toPercent(value, sum) {
82
+ return value ? Math.round(value * 100 / sum) : 0;
83
+ }
83
84
 
84
- var tooltip = d3.select("body")
85
- .append("div")
85
+ var tooltip = d3.select("body")
86
86
  .append("div")
87
- .attr("class", "tooltip");
87
+ .append("div")
88
+ .attr("class", "tooltip");
88
89
 
89
- function moveTooltip(d) {
90
- return tooltip
91
- .style("left", (d3.event.pageX + 20) + "px")
92
- .style("top", (d3.event.pageY) + "px")
93
- }
90
+ function moveTooltip(d) {
91
+ return tooltip
92
+ .style("left", (d3.event.pageX + 20) + "px")
93
+ .style("top", (d3.event.pageY) + "px")
94
+ }
94
95
 
95
- #{Pie.header_script}
96
- #{CircleMap.header_script}
97
- #{Timeline.header_script}
98
- JS
96
+ #{Pie.header_script}
97
+ #{CircleMap.header_script}
98
+ #{Timeline.header_script}
99
+ JS
100
+ end
99
101
  end
100
102
 
101
103
  class ColorPalette < T::Struct