path_coverage 0.3.0 → 0.5.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 (103) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +316 -177
  3. data/exe/path_coverage_report +4 -0
  4. data/lib/path_coverage/call_trace.rb +88 -0
  5. data/lib/path_coverage/calls.rb +49 -43
  6. data/lib/path_coverage/card_context.rb +104 -0
  7. data/lib/path_coverage/card_forks.rb +44 -0
  8. data/lib/path_coverage/card_gaps.rb +125 -0
  9. data/lib/path_coverage/card_scopes.rb +37 -0
  10. data/lib/path_coverage/card_tree.rb +199 -0
  11. data/lib/path_coverage/card_way_lists.rb +72 -0
  12. data/lib/path_coverage/card_ways.rb +196 -0
  13. data/lib/path_coverage/{html_syntax.rb → code_tokens.rb} +38 -25
  14. data/lib/path_coverage/condition.rb +14 -14
  15. data/lib/path_coverage/configuration.rb +7 -4
  16. data/lib/path_coverage/configuration_limits.rb +52 -0
  17. data/lib/path_coverage/configuration_paths.rb +7 -7
  18. data/lib/path_coverage/console_summary.rb +24 -22
  19. data/lib/path_coverage/{site.rb → decision.rb} +2 -2
  20. data/lib/path_coverage/decision_locations.rb +76 -0
  21. data/lib/path_coverage/{site_paths.rb → decision_paths.rb} +18 -8
  22. data/lib/path_coverage/{site_tree.rb → decision_tree.rb} +25 -16
  23. data/lib/path_coverage/fold_branches.rb +18 -0
  24. data/lib/path_coverage/fold_cells.rb +42 -0
  25. data/lib/path_coverage/fold_rows.rb +140 -0
  26. data/lib/path_coverage/gaps.rb +33 -15
  27. data/lib/path_coverage/json_reader.rb +54 -19
  28. data/lib/path_coverage/json_reports.rb +102 -0
  29. data/lib/path_coverage/json_writer.rb +31 -16
  30. data/lib/path_coverage/kernel.rb +56 -57
  31. data/lib/path_coverage/kinds/base.rb +16 -16
  32. data/lib/path_coverage/kinds/block.rb +16 -15
  33. data/lib/path_coverage/kinds/case.rb +14 -17
  34. data/lib/path_coverage/kinds/chain.rb +40 -11
  35. data/lib/path_coverage/kinds/choice.rb +7 -10
  36. data/lib/path_coverage/kinds/contains.rb +43 -33
  37. data/lib/path_coverage/kinds/safe.rb +44 -46
  38. data/lib/path_coverage/kinds/write.rb +6 -12
  39. data/lib/path_coverage/kinds.rb +2 -2
  40. data/lib/path_coverage/leaving.rb +44 -0
  41. data/lib/path_coverage/loop_forks.rb +57 -0
  42. data/lib/path_coverage/loop_nodes.rb +55 -0
  43. data/lib/path_coverage/manifest.rb +94 -59
  44. data/lib/path_coverage/manifest_blocks.rb +5 -26
  45. data/lib/path_coverage/manifest_case.rb +2 -2
  46. data/lib/path_coverage/manifest_chains.rb +8 -8
  47. data/lib/path_coverage/manifest_choices.rb +52 -29
  48. data/lib/path_coverage/manifest_disabled.rb +97 -0
  49. data/lib/path_coverage/manifest_folding.rb +66 -26
  50. data/lib/path_coverage/manifest_ignoring.rb +6 -6
  51. data/lib/path_coverage/manifest_writes.rb +11 -10
  52. data/lib/path_coverage/measured_by.rb +20 -0
  53. data/lib/path_coverage/merge.rb +7 -7
  54. data/lib/path_coverage/method_loops.rb +128 -0
  55. data/lib/path_coverage/method_statements.rb +147 -139
  56. data/lib/path_coverage/method_ways.rb +142 -0
  57. data/lib/path_coverage/paths_report.rb +16 -16
  58. data/lib/path_coverage/recorder.rb +57 -36
  59. data/lib/path_coverage/recorder_blocks.rb +17 -17
  60. data/lib/path_coverage/recorder_cases.rb +12 -11
  61. data/lib/path_coverage/recorder_chains.rb +12 -12
  62. data/lib/path_coverage/recorder_writes.rb +9 -9
  63. data/lib/path_coverage/render.rb +58 -51
  64. data/lib/path_coverage/result.rb +32 -31
  65. data/lib/path_coverage/rewriter.rb +39 -27
  66. data/lib/path_coverage/rewriter_nested.rb +13 -13
  67. data/lib/path_coverage/runs_report.rb +84 -0
  68. data/lib/path_coverage/source_lines.rb +16 -16
  69. data/lib/path_coverage/source_report.rb +100 -0
  70. data/lib/path_coverage/stable_leaves.rb +162 -0
  71. data/lib/path_coverage/statement_arms.rb +61 -27
  72. data/lib/path_coverage/summary.rb +4 -62
  73. data/lib/path_coverage/totals.rb +10 -8
  74. data/lib/path_coverage/version.rb +1 -1
  75. data/lib/path_coverage/walk.rb +106 -0
  76. data/lib/path_coverage/way_algebras.rb +127 -0
  77. data/lib/path_coverage/ways_report.rb +91 -0
  78. data/lib/path_coverage/ways_totals.rb +46 -0
  79. data/lib/path_coverage/within_methods.rb +184 -44
  80. metadata +36 -29
  81. data/lib/path_coverage/card.rb +0 -14
  82. data/lib/path_coverage/html/file.html +0 -33
  83. data/lib/path_coverage/html/index.html +0 -29
  84. data/lib/path_coverage/html/settings.js +0 -50
  85. data/lib/path_coverage/html/side.js +0 -470
  86. data/lib/path_coverage/html/sort.js +0 -34
  87. data/lib/path_coverage/html/style.css +0 -470
  88. data/lib/path_coverage/html/tabs.js +0 -15
  89. data/lib/path_coverage/html/theme.js +0 -27
  90. data/lib/path_coverage/html_branch.rb +0 -30
  91. data/lib/path_coverage/html_cards.rb +0 -111
  92. data/lib/path_coverage/html_cells.rb +0 -66
  93. data/lib/path_coverage/html_file.rb +0 -123
  94. data/lib/path_coverage/html_index.rb +0 -128
  95. data/lib/path_coverage/html_index_head.rb +0 -29
  96. data/lib/path_coverage/html_labels.rb +0 -23
  97. data/lib/path_coverage/html_methods.rb +0 -66
  98. data/lib/path_coverage/html_nav.rb +0 -67
  99. data/lib/path_coverage/html_report.rb +0 -131
  100. data/lib/path_coverage/html_statements.rb +0 -166
  101. data/lib/path_coverage/html_tabs.rb +0 -26
  102. data/lib/path_coverage/html_template.rb +0 -26
  103. data/lib/path_coverage/html_tree.rb +0 -131
@@ -1,470 +0,0 @@
1
- /* Blue (seen both ways) and orange (missing) stay distinct for
2
- red-green colour blindness; states also differ in form. */
3
- :root {
4
- --bg: #FBFBFC;
5
- --surface: #FFFFFF;
6
- --panel: #F2F4F7;
7
- --fg: #1C2230;
8
- --muted: #5B6577;
9
- --rule: #D5DAE2;
10
- --ok: #1F5FBF;
11
- --ok-tint: #E6EEFA;
12
- --bad: #B54708;
13
- --on-status: #FFFFFF;
14
- --link: #1F5FBF;
15
- --font-body: "Helvetica Neue", Arial, sans-serif;
16
- --font-code: Menlo, Consolas, "DejaVu Sans Mono", monospace;
17
- }
18
- /* Dark, unless the page's html element names light, as the theme
19
- button does when pressed; so a page draws dark before any script
20
- runs. */
21
- :root:not([data-theme="light"]) {
22
- --bg: #12151C; --surface: #181C25; --panel: #212633; --fg: #E4E8EF;
23
- --muted: #9AA4B5; --rule: #323949; --ok: #7FB0FF; --ok-tint: #1A2740;
24
- --bad: #F08A3C; --on-status: #12151C; --link: #7FB0FF;
25
- --syn-k: #C79BEA; --syn-s: #9CCB9E; --syn-c: #7F8A99;
26
- --syn-n: #E9A3C9; --syn-t: #AEB5F5; --syn-v: #7FCFC4; --syn-o: #E6D27A;
27
- color-scheme: dark;
28
- }
29
- /* Code's syntax colours, each muted so the orange, blue and green
30
- of coverage still stand out: keywords, strings, comments,
31
- numbers, constants, instance variables, and, in bold gold, the
32
- operators that decide a path, eg && and &. */
33
- :root {
34
- --syn-k: #7E3BA0; --syn-s: #3B7550; --syn-c: #77808F;
35
- --syn-n: #9E4A78; --syn-t: #4B52A0; --syn-v: #2A7570; --syn-o: #7A6600;
36
- }
37
- /* The same colours in the code and in a site's tree, its fold, and
38
- a card's rows, which quote the code. */
39
- :is(.src, .fold, .statements .prow) .k { color: var(--syn-k); }
40
- :is(.src, .fold, .statements .prow) .s { color: var(--syn-s); }
41
- :is(.src, .fold, .statements .prow) .c { color: var(--syn-c); font-style: italic; }
42
- :is(.src, .fold, .statements .prow) .n { color: var(--syn-n); }
43
- :is(.src, .fold, .statements .prow) .t { color: var(--syn-t); }
44
- :is(.src, .fold, .statements .prow) .v { color: var(--syn-v); }
45
- :is(.src, .fold, .statements .prow) .o { color: var(--syn-o); font-weight: 700; }
46
- /* Everything a site's tree or a method's grid draws has this one
47
- tint, in either mode; status is only ever the orange or blue of
48
- an edge. A lit line, on a path being shown, is yellow. */
49
- :root { --cond-tint: #E2F2D3; --lit: #FFE98A; }
50
- :root:not([data-theme="light"]) { --cond-tint: #26361A; --lit: #5A4A12; }
51
- /* --rail is the width of the column of trees and grids left of the
52
- code; dragging the divider changes it. */
53
- body { --rail: 560px; }
54
- body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 14px; }
55
- a { color: var(--link); }
56
- .page {
57
- max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px;
58
- padding: 0 max(16px, env(safe-area-inset-right, 0px)) 64px max(16px, env(safe-area-inset-left, 0px));
59
- }
60
- /* A file's page is wider, to hold its rail beside its code. */
61
- .page:has(.code) { max-width: 1800px; }
62
- h1 { margin: 0; font-size: 24px; font-weight: 600; }
63
- /* Every page's top line: the Path coverage title, a link back to
64
- the index on a file's page, then, on a file's page, its path. */
65
- .top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
66
- .title { margin: 0; font-size: 24px; font-weight: 600; }
67
- .title a { color: inherit; text-decoration: none; }
68
- .title a:hover { text-decoration: underline; }
69
- /* A file's path links back to its row on the index, which stops
70
- clear of the index's sticky header. */
71
- h1.path a { color: inherit; text-decoration: none; }
72
- h1.path a:hover { text-decoration: underline; }
73
- table.files tr[id] { scroll-margin-top: 72px; }
74
- .box { border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); overflow-x: auto; }
75
- table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
76
- th, td { padding: 10px 16px; text-align: left; }
77
- th { background: var(--panel); }
78
- td { border-top: 1px solid var(--rule); }
79
- td:first-child { font-family: var(--font-code); }
80
- /* The Total row frames the table's foot as the headings do its
81
- head, so it reads as a sum, not as one more file. */
82
- tfoot td { background: var(--panel); font-weight: 600; border-top: 1px solid var(--fg); }
83
- tfoot td:first-child { font-family: inherit; }
84
- /* The index page's tabs, one per group of files; the selected
85
- one framed as the table's headings are. */
86
- .tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
87
- .tabs [role="tab"] { font: inherit; font-size: 13px; padding: 6px 12px; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; }
88
- .tabs [role="tab"][aria-selected="true"] { background: var(--panel); color: var(--fg); border-color: var(--fg); font-weight: 600; }
89
- .tabs [role="tab"]:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
90
- .num, td:not(:first-child) { text-align: right; }
91
- /* A total's taken, / of and % sit close, so a row still reads
92
- 3 / 4 75%. The File column takes the table's spare width, so
93
- it never spreads them apart. These rules name the files table,
94
- so a path grid's taken cells are never matched. */
95
- table.files tr > :first-child { width: 100%; }
96
- table.files th, table.files td:not(:first-child) { white-space: nowrap; }
97
- table.files .taken { text-align: right; padding-left: 32px; padding-right: 4px; }
98
- table.files .of { text-align: left; padding-left: 0; padding-right: 6px; }
99
- table.files .percent { text-align: right; padding-left: 6px; }
100
- th button {
101
- font: 600 13px var(--font-body); color: var(--fg); background: none; border: 0;
102
- padding: 4px 0; cursor: pointer;
103
- }
104
- th button::after { content: " \2195"; color: var(--muted); }
105
- th[aria-sort="ascending"] button::after { content: " \25B2"; color: var(--fg); }
106
- th[aria-sort="descending"] button::after { content: " \25BC"; color: var(--fg); }
107
- th button:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
108
-
109
- /* A file's page: plain source; on lines holding a condition the
110
- line numbers are one button. Every number has the same box, so
111
- digits stay aligned whether or not they are on a button. */
112
- h1.path { font-family: var(--font-code); font-size: 18px; }
113
- /* The top line, and on a file's page its path and site lists,
114
- stick together as one header. */
115
- .head {
116
- position: sticky; top: 0; z-index: 5;
117
- display: flex; flex-direction: column; gap: 10px;
118
- margin: 0 -16px; padding: 12px 16px; background: var(--bg);
119
- border-bottom: 1px solid var(--rule);
120
- }
121
- /* The theme button, small, at the title bar's right end, showing
122
- the theme it switches to: a moon for dark, a sun for light. */
123
- .theme {
124
- margin-left: auto; width: 30px; height: 30px; padding: 0; font-size: 16px; line-height: 1;
125
- border: 1px solid var(--rule); border-radius: 6px; background: var(--surface);
126
- color: var(--fg); cursor: pointer;
127
- }
128
- .theme:hover { background: var(--panel); }
129
- .theme:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
130
- .jumps { display: flex; flex-direction: column; gap: 8px; }
131
- .jump-list { display: flex; gap: 6px; align-items: center; overflow-x: auto; white-space: nowrap; min-width: 0; }
132
- .jump-label { width: 64px; flex-shrink: 0; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
133
- a.jump {
134
- font: 600 12px/22px var(--font-code); padding: 0 9px; border-radius: 999px;
135
- text-decoration: none; border: 1px solid; font-variant-numeric: tabular-nums;
136
- }
137
- /* A site's jump wears the condition tint, edged in its status
138
- colour on the top and left only, as its line's button is. */
139
- a.jump[data-status] { background: var(--cond-tint); border-right-color: transparent; border-bottom-color: transparent; }
140
- a.jump[data-status="covered"] { color: var(--ok); border-top-color: var(--ok); border-left-color: var(--ok); }
141
- a.jump[data-status="gaps"] { color: var(--bad); border-top-color: var(--bad); border-left-color: var(--bad); }
142
- a.jump:focus-visible, .nav a:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
143
- /* The code sits right of the rail of cards. The rail's column is
144
- always there, --rail wide, and the divider in the gap after it
145
- drags to change that. */
146
- .box:has(> .code) {
147
- position: relative; isolation: isolate; border: 0; background: none; border-radius: 0;
148
- display: grid; column-gap: 12px; grid-template-columns: var(--rail) minmax(0, 1fr);
149
- }
150
- .box > .rail { grid-column: 1; grid-row: 1; }
151
- .box > .code { grid-column: 2; grid-row: 1; }
152
- /* The source pane's border and background start after the rail,
153
- the gap and the nav column, so the arrows sit outside the pane
154
- yet scroll with their line. */
155
- .box:has(> .code)::before {
156
- content: ""; position: absolute; inset: 0 0 0 calc(var(--rail) + 38px); z-index: -1;
157
- border: 1px solid var(--rule); border-radius: 8px;
158
- background: var(--surface); pointer-events: none;
159
- }
160
- /* The previous-gap arrow sits above the next, each half a line
161
- tall, keeping the gutter narrow. */
162
- .nav { display: flex; flex-direction: column; justify-content: center; width: 26px; flex-shrink: 0; }
163
- .nav a { width: 22px; text-align: center; line-height: 14px; font-size: 12px; color: var(--bad); text-decoration: none; }
164
- /* A covered card's arrows, between the covered cards' lines, are
165
- blue, as their numbers are. */
166
- .nav a[data-status="covered"] { color: var(--ok); }
167
- .nav a:hover { color: var(--fg); }
168
- .nav a[data-prev]::before { content: "\25B2"; }
169
- .nav a[data-next]::before { content: "\25BC"; }
170
- /* Every row is as wide as the longest line (or the pane, if
171
- wider), so a method's band, and a lit line, reach past the code
172
- when it scrolls sideways. */
173
- .code {
174
- font-family: var(--font-code); font-size: 13px; line-height: 32px; padding: 10px 0;
175
- position: relative; isolation: isolate; min-width: 0; overflow-x: auto;
176
- display: grid; grid-template-columns: minmax(max-content, 1fr); align-content: start;
177
- }
178
- .line, .block { display: flex; align-items: flex-start; }
179
- /* A loose site's whole block, its lines' code included, opens its
180
- top card. */
181
- .block { cursor: pointer; border-radius: 6px; }
182
- .block:hover { filter: brightness(0.97); }
183
- .line:has(.lineno) { cursor: default; }
184
- .srcs { display: flex; flex-direction: column; }
185
- .block .srcs { flex: 1; }
186
- .src { white-space: pre; }
187
- /* A lit line's background spans the code pane's full width. */
188
- .line .src { flex: 1; }
189
- /* Each line's code is as tall as its row, even an empty line's, so
190
- a method's stripe runs unbroken from row to row. */
191
- .line > .src, .block > .srcs { align-self: stretch; }
192
- .srcs > .src:last-child { flex-grow: 1; }
193
- /* scroll-margin-top clears the sticky header when a link jumps to
194
- a line. */
195
- .lineno {
196
- display: block; width: 52px; padding-right: 20px; text-align: right;
197
- color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0;
198
- scroll-margin-top: 190px;
199
- }
200
- /* A loose site's button, its 9px right margin included, takes the
201
- 72px a plain number takes, so its lines' code starts where every
202
- other line's does. Its 63px includes its borders, so at any zoom,
203
- where a border is rounded to whole screen pixels, its width
204
- holds. */
205
- button.lnum {
206
- position: relative; display: flex; flex-direction: column; flex-shrink: 0;
207
- box-sizing: border-box; width: 63px;
208
- margin: 4px 9px 4px 0; padding: 0;
209
- border: 1px solid transparent; border-radius: 6px; cursor: pointer;
210
- font: 600 13px/24px var(--font-code); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
211
- }
212
- /* A loose site's top card opens in the left rail: a closed button
213
- points left, where its card will open; an open one has no arrow,
214
- as a click leaves it open. */
215
- button.lnum::before {
216
- content: "\25C2"; position: absolute; left: 7px; top: 4px;
217
- font-size: 11px; line-height: 24px;
218
- }
219
- button.lnum[aria-expanded="true"]::before { content: none; }
220
- /* With a site count the count and the triangle share the
221
- button's height, one 11px line each. */
222
- button.lnum:has(.site-count)::before { top: 12px; line-height: 11px; }
223
- /* On a button over two or more lines the triangle sits at the
224
- very bottom. */
225
- button.lnum:has(.lineno + .lineno)::before { top: auto; bottom: 2px; line-height: 11px; }
226
- .site-count {
227
- position: absolute; left: 7px; top: 1px;
228
- font-size: 9px; line-height: 11px; font-weight: 700;
229
- }
230
- button.lnum .lineno { width: 50px; padding-right: 11px; color: inherit; line-height: 32px; margin: -4px 0; }
231
- /* A site's button wears the condition tint, edged in its
232
- status colour on the top and left only. */
233
- button.lnum[data-status] { box-shadow: none; background: var(--cond-tint); border-right-color: transparent; border-bottom-color: transparent; }
234
- button.lnum[data-status="covered"] { color: var(--ok); border-top-color: var(--ok); border-left-color: var(--ok); }
235
- button.lnum[data-status="gaps"] { color: var(--bad); border-top-color: var(--bad); border-left-color: var(--bad); }
236
- button.lnum:hover { filter: brightness(1.1); }
237
- button.lnum:focus-visible { outline: 3px solid var(--link); outline-offset: 1px; }
238
- /* An open loose site has its button's status edges, top and left,
239
- doubled to 2px. A jump to it opens its card, so its button has
240
- no outline of the jump to it. */
241
- button.lnum[aria-expanded="true"][data-status="gaps"] { box-shadow: inset 1px 1px 0 var(--bad); }
242
- button.lnum[aria-expanded="true"][data-status="covered"] { box-shadow: inset 1px 1px 0 var(--ok); }
243
- button.lnum:has(.lineno:target) { outline: none; }
244
- /* While a card is open, no button keeps a focus outline. */
245
- body[data-open] button.lnum:focus-visible { outline: none; }
246
- .rail { position: relative; min-width: 0; }
247
- /* Each row lays its branch and label out at their own width, the
248
- label pushing its cells to the row's right edge, so a site's
249
- cells line up in columns however long or deep its labels. */
250
- .row { display: flex; align-items: center; gap: 8px; }
251
- .row > :is(.text, .arm, .operator) { margin-right: auto; padding-right: 8px; }
252
- /* An explicit width, not just a flex basis, so a row's natural
253
- width counts each cell as 26px, not as its one letter. */
254
- .row > :is(.cell, .count) { flex: none; width: 26px; }
255
- /* A thin rule under each site's counts row, across the tree's
256
- full width through its 16px side padding. */
257
- .site > .row:first-child {
258
- border-bottom: 1px solid var(--rule); margin: 0 -16px 6px; padding: 0 16px 4px;
259
- }
260
- .operator { font-weight: 600; }
261
- .row .arm { white-space: pre; font-weight: 600; }
262
- /* An if's then names its arm, quoting no code, so is italic. */
263
- .row .arm[data-named] { font-style: italic; }
264
- .branch { white-space: pre; color: var(--muted); margin-right: -16px; }
265
- .row .text { white-space: pre; }
266
- /* A branch's cell, of the kind its data-bx names, drawn a whole
267
- row tall so branches join from row to row: v a vertical line,
268
- t a vertical with a stub right, l the top half of a vertical
269
- with a stub right, h a horizontal, s nothing. */
270
- .bx { display: inline-block; width: 1ch; height: 30px; vertical-align: top; --stroke: linear-gradient(currentColor, currentColor); }
271
- .bx[data-bx="v"] { background: var(--stroke) 50% 0 / 1px 100% no-repeat; }
272
- .bx[data-bx="t"] { background: var(--stroke) 50% 0 / 1px 100% no-repeat, var(--stroke) 100% 50% / 50% 1px no-repeat; }
273
- .bx[data-bx="l"] { background: var(--stroke) 50% 0 / 1px 50% no-repeat, var(--stroke) 100% 50% / 50% 1px no-repeat; }
274
- .bx[data-bx="h"] { background: var(--stroke) 0 50% / 100% 1px no-repeat; }
275
- /* Each path heads its column with a snake, a vertical ~ standing
276
- for the path below it, then 0, orange, for a path never taken,
277
- or *, blue, for one taken, its count on hover; a leaf's T or F
278
- on that path sits in a chip, as in a path grid, and a blank
279
- means the path never reached it. */
280
- .row .count { text-align: center; font-variant-numeric: tabular-nums; color: var(--ok); font-weight: 600; }
281
- .row .count::before { content: "\2240"; }
282
- .row .count.never { color: var(--bad); }
283
- .row .cell { text-align: center; }
284
- .row .cell:is(:not(:empty), [data-mark]) {
285
- align-self: center; line-height: 22px; border-radius: 3px;
286
- background: var(--surface); color: var(--fg); font: 600 12px var(--font-code);
287
- }
288
- /* A cell's mark, drawn in place of a letter: a tick for a path
289
- that took an arm or called its operand, a disc for a &.
290
- receiver not nil, an empty set for one nil. */
291
- .row .cell[data-mark="taken"]::before { content: "\2713"; }
292
- .row .cell[data-mark="present"]::before { content: "\25CF"; }
293
- .row .cell[data-mark="absent"]::before { content: "\2205"; }
294
- /* Hovering a cell with hover text, eg a path's count or a &.
295
- receiver's mark, shows that text in a chip above it. */
296
- .row [data-hover] { position: relative; cursor: default; }
297
- .row [data-hover]:hover::after {
298
- content: attr(data-hover); position: absolute; bottom: 100%; left: 50%;
299
- transform: translateX(-50%); z-index: 4; padding: 0 7px; border-radius: 4px;
300
- white-space: nowrap; font: 700 11px/20px var(--font-body); background: var(--fg); color: var(--bg);
301
- }
302
-
303
- /* The divider: the gap between the rail and the code, a line down
304
- its middle that darkens as it is hovered or dragged. */
305
- .divider {
306
- position: absolute; top: 0; bottom: 0; left: var(--rail); width: 12px;
307
- cursor: col-resize; z-index: 4; touch-action: none;
308
- }
309
- .divider::after {
310
- content: ""; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px;
311
- background: var(--rule);
312
- }
313
- .divider:hover::after, .divider.dragging::after { background: var(--link); }
314
- body.dragging { cursor: col-resize; user-select: none; }
315
-
316
- /* Within each method, each line of a method has a stripe in the
317
- method's status colour, just left of its def's d, from its def
318
- line to its last; its def line also has a band of the one tint,
319
- from its def to the end of its text. Both are backgrounds of the
320
- lines' code, placed in characters (side.js gives each line its
321
- def's column), so the code's own layout keeps them aligned. Open,
322
- a method's stripe thickens. */
323
- /* Within each method, a method's body is folded under its def line
324
- until its def's number opens it, so the page starts as a list of
325
- def lines. */
326
- .method-folded { display: none; }
327
- /* The open method's def line, shifted down by side.js to stay just
328
- below the sticky header, covers the body lines passing under it. */
329
- .def-stuck {
330
- position: relative; z-index: 3; background: var(--surface);
331
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
332
- }
333
- .src.in-method {
334
- --method-colour: var(--bad); --stripe: 2px;
335
- --at: calc(var(--def-col) * 1ch - 4px);
336
- background-image: linear-gradient(var(--method-colour), var(--method-colour));
337
- background-size: var(--stripe) 100%;
338
- background-position: var(--at) 0;
339
- background-repeat: no-repeat;
340
- }
341
- .src.in-method[data-method-status="covered"] { --method-colour: var(--ok); }
342
- .src.in-method.method-open { --stripe: 3px; }
343
- /* A def line's band stops 1px short of its line's bottom, so the
344
- bands of def lines one after another, eg one-line methods, stay
345
- apart. Its stripe runs the full height, on into its body, but on
346
- its method's last line, where it too stops 1px short, so the
347
- stripes of methods one after another stay apart as well. */
348
- .src.def-line {
349
- --band: calc((var(--def-end) - var(--def-col)) * 1ch + 8px) calc(100% - 1px);
350
- background-image:
351
- linear-gradient(var(--method-colour), var(--method-colour)),
352
- linear-gradient(var(--cond-tint), var(--cond-tint));
353
- background-size: var(--stripe) 100%, var(--band);
354
- background-position: var(--at) 0, var(--at) 0;
355
- }
356
- .src.in-method.method-end { background-size: var(--stripe) calc(100% - 1px); }
357
- .src.def-line.method-end { background-size: var(--stripe) calc(100% - 1px), var(--band); }
358
- /* A card floats in the rail, level with its first line (its top
359
- set by side.js), framed by a border, rounded corners and a
360
- shadow, its rows 16px in from its sides. */
361
- .rail .pathgrid {
362
- position: absolute; left: 0; right: 0; z-index: 2; overflow-x: auto; overflow-y: hidden;
363
- background: var(--cond-tint); font: 600 12px var(--font-code);
364
- border: 1px solid var(--rule); border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
365
- }
366
- .prow { position: absolute; left: 16px; display: flex; gap: 2px; white-space: nowrap; }
367
- /* A statement card's rows flow down it, 10px above the first and
368
- below the last, so a fold open under a row pushes the rows after
369
- it down. */
370
- .statements { padding: 10px 0; }
371
- .statements .prow { position: static; padding: 0 16px; margin-bottom: 2px; }
372
- /* A site's fold draws the site's tree in the code's font, its
373
- rows as tall as the card's. Open, it takes its row's
374
- place right of the row's arrow and line:col, 88px in (the card's
375
- 16px padding, the arrow's 16px, the label's 52px and two 2px
376
- gaps): its first row, the site's operator and its count on each
377
- path, stands where the row's top and counts were, which hide,
378
- and its other rows are indented as far, so they stay aligned
379
- with the operator. The rows it reveals, below its first row
380
- (24px and 2px padding), are tinted a shade off the card,
381
- toward the text colour, so in either theme they stand out as
382
- opened, with no rule needed above or below them. Lying over
383
- its row, it takes no click itself, so one on the row's arrow
384
- or line:col beneath reaches the row and folds it back; its
385
- tree's rows take theirs. */
386
- .fold {
387
- position: relative; margin: -26px 0 6px; padding: 0 16px 4px 88px;
388
- font: 400 13px var(--font-code); line-height: 24px; color: var(--fg);
389
- pointer-events: none;
390
- background: linear-gradient(transparent 26px,
391
- color-mix(in srgb, var(--cond-tint), var(--fg) 6%) 26px);
392
- }
393
- .fold:last-child { margin-bottom: 0; }
394
- .fold .site { pointer-events: auto; }
395
- .fold .bx { height: 24px; }
396
- .fold .site > .row:first-child {
397
- border-bottom: 0; margin: 0 0 4px; padding: 0 0 2px; cursor: pointer;
398
- }
399
- .statements .prow.site:has(> .fold-arrow[aria-expanded="true"]) > .pcell { visibility: hidden; }
400
- /* A site row's arrow, left of its line:col, points down while its
401
- fold is shut and up while it is open; every other row's label
402
- is indented by the arrow's width and the gap after it, so the
403
- labels line up. */
404
- .fold-arrow {
405
- flex: none; width: 16px; padding: 0; border: none; background: none;
406
- font: inherit; font-size: 10px; line-height: 24px; color: var(--muted); cursor: pointer;
407
- }
408
- .fold-arrow::before { content: "\25BC"; }
409
- .fold-arrow[aria-expanded="true"]::before { content: "\25B2"; }
410
- .prow.site:hover .fold-arrow, .fold-arrow[aria-expanded="true"] { color: var(--link); }
411
- .fold-arrow:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
412
- .statements .prow > .plabel:first-child { margin-left: 18px; }
413
- /* A grid's line labels sit at its left padding, as a tree's labels
414
- do, their fixed width keeping the cells in columns. */
415
- .plabel { width: 48px; flex-shrink: 0; text-align: left; padding-right: 8px; color: var(--muted); line-height: 24px; }
416
- .pcell { width: 24px; flex-shrink: 0; text-align: center; line-height: 24px; border-radius: 3px; }
417
- /* A statement card's cells hold words, eg return, not T or F. Its
418
- line:col labels are narrow, so each row's top follows close
419
- after, left aligned, its paths and taken at the card's right
420
- edge; the title row's name is as wide as it needs. */
421
- .statements .pcell { width: 72px; cursor: default; }
422
- .statements .plabel { width: 44px; padding-right: 8px; overflow: visible; }
423
- .statements .prow.calls .plabel { width: auto; }
424
- .statements .plabel + .pcell { flex: 1; min-width: 56px; text-align: left; }
425
- .statements .prow.site, .statements .prow.site .pcell { cursor: pointer; }
426
- .statements .prow.site:hover .pcell, .statements .prow.site:hover .plabel { color: var(--link); }
427
- .statements .prow.columns .plabel, .statements .prow.columns .pcell { color: var(--muted); }
428
- /* A card's paths not taken are orange and those taken blue, as a
429
- status always is; its column titles are too, as their key. None
430
- not taken, 0, is no gap, so is blue. */
431
- .statements .pcell.not-taken { color: var(--bad); }
432
- .statements .pcell.was-taken,
433
- .statements .pcell.not-taken.none { color: var(--ok); }
434
- .prow.calls .plabel { color: var(--fg); }
435
- /* Hovering a card's row lights its line in the code; hovering a
436
- fold's row marks the characters of its operand. */
437
- .src.lit { background: var(--cond-tint); }
438
- mark.chars { background: var(--lit); color: inherit; border-radius: 3px; box-shadow: 0 0 0 2px var(--lit); }
439
- .fold .row[data-at] { cursor: default; }
440
- .fold .row[data-at]:hover { background: rgba(255, 255, 255, 0.08); }
441
-
442
- /* A row of jumps with none keeps its height, though hidden, so the
443
- sticky header, and the code below it, never move. */
444
- .jump-list[data-empty] { visibility: hidden; }
445
- /* The number of each method's def line wears a loose site's
446
- button's look: the one tint, edged on the top and left in its
447
- status colour, orange for gaps and blue for covered, with an
448
- arrow pointing left while its card is closed, and none while it
449
- is open. Its 63px and its 9px right margin take the 72px a plain
450
- number takes, as a loose site's button does, so its line's code
451
- starts where every other line's does and its digits end where
452
- theirs do. */
453
- .lineno.mdef {
454
- position: relative; box-sizing: border-box; width: 63px; padding-right: 11px;
455
- margin: 4px 9px 4px 0; line-height: 24px; cursor: pointer;
456
- font: 600 13px/24px var(--font-code); border: 1px solid transparent;
457
- border-radius: 6px; background: var(--cond-tint);
458
- --mdef-status: var(--bad); color: var(--mdef-status);
459
- border-top-color: var(--mdef-status); border-left-color: var(--mdef-status);
460
- }
461
- .lineno.mdef[data-status="covered"] { --mdef-status: var(--ok); }
462
- .lineno.mdef::before {
463
- content: "\25C2"; position: absolute; left: 7px; top: 0; font-size: 11px;
464
- }
465
- .lineno.mdef[aria-expanded="true"]::before { content: none; }
466
- .lineno.mdef[aria-expanded="true"] { box-shadow: inset 1px 1px 0 var(--mdef-status); }
467
- .lineno.mdef:hover { filter: brightness(1.1); }
468
- /* A line's gap arrows sit in the middle of its row, level with its
469
- number, however tall its row is. */
470
- .nav { align-self: stretch; }
@@ -1,15 +0,0 @@
1
- // Switches the index page's tabs: a click on a tab selects it and
2
- // shows the table it controls, hiding every other tab's table.
3
- (function () {
4
- var tabs = Array.from(document.querySelectorAll('[role="tab"]'));
5
- tabs.forEach(function (tab) {
6
- tab.addEventListener('click', function () {
7
- tabs.forEach(function (other) {
8
- var selected = other === tab;
9
- other.setAttribute('aria-selected', selected ? 'true' : 'false');
10
- var table = document.getElementById(other.getAttribute('aria-controls'));
11
- table.hidden = !selected;
12
- });
13
- });
14
- });
15
- })();
@@ -1,27 +0,0 @@
1
- // Switches the page between light and dark as the title bar's theme
2
- // button is pressed: the page's html element names the theme, and
3
- // the page's CSS draws it. The theme is a setting, carried from page
4
- // to page as settings.js has it; a page with none opens dark.
5
- (function () {
6
- var settings = window.pathCoverageSettings;
7
- var button = document.querySelector('button.theme');
8
- if (!button) { return; }
9
-
10
- // Names theme on the html element, labels the button with the
11
- // theme it switches to, and makes every link carry theme.
12
- function show(theme) {
13
- document.documentElement.setAttribute('data-theme', theme);
14
- var other = theme === 'dark' ? 'light' : 'dark';
15
- button.textContent = theme === 'dark' ? '☀' : '☾';
16
- button.setAttribute('aria-label', 'Switch to ' + other);
17
- button.title = 'Switch to ' + other;
18
- settings.carry('theme', theme);
19
- }
20
-
21
- show(settings.given('theme', ['light', 'dark']) || 'dark');
22
- button.addEventListener('click', function () {
23
- var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
24
- show(theme);
25
- settings.keep('theme', theme);
26
- });
27
- })();
@@ -1,30 +0,0 @@
1
- module PathCoverage
2
- # The branches of a site's tree on a file's page, joining each
3
- # operand's row to its operator's. A branch is a string of
4
- # kinds, one letter per cell: t a tee, l an ell, v a bar, h a
5
- # dash, s a space. CSS draws each kind as lines a whole row
6
- # tall, so a branch joins the rows above and below it.
7
- module HtmlBranch
8
- # The branch to an operand with more after it.
9
- TEE = 'ths'.freeze
10
- # The branch to the last operand.
11
- ELL = 'lhs'.freeze
12
- # The indent under an operand with more after it, its bar
13
- # running on down to them.
14
- BAR = 'vss'.freeze
15
- # The indent under the last operand.
16
- GAP = 'sss'.freeze
17
-
18
- # Example: ths gives a tee, a dash and a space cell.
19
- # The cell drawing branch: a cell of each of its kinds,
20
- # hidden from screen readers, as the rows' order already
21
- # says how they nest.
22
- def self.cell(branch)
23
- cells = branch.chars.map do |kind|
24
- %(<span class="bx" data-bx="#{kind}"></span>)
25
- end
26
- attrs = 'class="branch" data-branch="" aria-hidden="true"'
27
- %(<span #{attrs}>#{cells.join}</span>)
28
- end
29
- end
30
- end
@@ -1,111 +0,0 @@
1
- require_relative 'card'
2
- require_relative 'html_statements'
3
- require_relative 'html_tree'
4
- require_relative 'method_statements'
5
- require_relative 'site_tree'
6
-
7
- module PathCoverage
8
- # The cards of one file's page, as Card gives them, in the rail
9
- # beside its code: a card for each of its methods, and one for
10
- # each span of its lines holding sites at the top level; each
11
- # site's row with its tree folded under it. It relies on
12
- # HtmlReport.located to place each tree's rows in the source.
13
- module HtmlCards
14
- # The cards of each method of the file at path, parsed as
15
- # Manifest.parse gives it; site_paths as Result#paths gives
16
- # them, reached as Recorder#reached does.
17
- def self.methods(path, parsed, (site_paths, reached))
18
- source, sites = parsed.values_at(:source, :sites)
19
- names = MethodStatements.names(source, path, sites)
20
- lasts = MethodStatements.lasts(source, path, sites)
21
- tree = ->(at) { fold(source, sites, site_paths, at) }
22
- MethodStatements.of(source, path, sites).map do |site, rows|
23
- taken = MethodStatements.taken(rows, site_paths, reached)
24
- named = [names[site], lasts[site]]
25
- method_card(site, named, rows, taken, &tree)
26
- end
27
- end
28
-
29
- # The Card of the def at site named name, ending on line last,
30
- # its rows' taken as taken gives them.
31
- def self.method_card(site, (name, last), rows, taken, &)
32
- html = HtmlStatements.card(site, name, rows, taken, last, &)
33
- first, column = site.split(':').last(2).map { Integer(_1) }
34
- status = HtmlStatements.status(rows, taken)
35
- Card.new(first:, last:, column:, status:, top: false,
36
- sites: nil, html:)
37
- end
38
-
39
- # A top card for each span of lines holding sites at the top
40
- # level of the file at path, outside every def, as each
41
- # span's lines share one button: a row per site in it. lines
42
- # are as SourceLines.of gives them.
43
- def self.tops(path, parsed, lines, site_paths)
44
- source, sites = parsed.values_at(:source, :sites)
45
- tree = ->(at) { fold(source, sites, site_paths, at) }
46
- scopes = scopes(source)
47
- spans(path, parsed, lines).map do |span, rows|
48
- top(path, span, rows, site_paths, scopes[span.begin], &tree)
49
- end
50
- end
51
-
52
- # The top card of the span of lines of the file at path,
53
- # holding rows, titled scope.
54
- def self.top(path, span, rows, site_paths, scope, &)
55
- taken = MethodStatements.taken(rows, site_paths)
56
- site = "#{path}:#{span.begin}:0"
57
- html = HtmlStatements.top_card(site, scope, rows, taken,
58
- span.end, &)
59
- Card.new(first: span.begin, last: span.end, column: 0,
60
- status: HtmlStatements.status(rows, taken), top: true,
61
- sites: rows.size, html:)
62
- end
63
-
64
- # A lambda giving the scope of a line of source, as scope
65
- # gives it, its modules and classes found once.
66
- def self.scopes(source)
67
- holders = holders_in(Prism.parse(source).value)
68
- ->(line) { scope(holders, line) }
69
- end
70
-
71
- # Example: line 2, inside module Shop on lines 1 to 9, gives
72
- # Shop.
73
- # The name of the innermost of holders, modules and classes,
74
- # whose lines hold line, a top card's scope, as a def is a
75
- # method card's; file for a line in none.
76
- def self.scope(holders, line)
77
- holding = holders.select do |node|
78
- location = node.location
79
- (location.start_line..location.end_line).cover?(line)
80
- end
81
- holding.empty? ? 'file' : holding.last.name.to_s
82
- end
83
-
84
- # The kinds of node that are a top card's scope.
85
- HOLDERS = [Prism::ModuleNode, Prism::ClassNode].freeze
86
-
87
- # Every module and class node in the tree at node, each
88
- # before those nested in it.
89
- def self.holders_in(node)
90
- own = HOLDERS.include?(node.class) ? [node] : []
91
- own + node.compact_child_nodes.flat_map { holders_in(_1) }
92
- end
93
-
94
- # { span => its top-level rows } of the file at path, each
95
- # row under the span its line is in.
96
- def self.spans(path, parsed, lines)
97
- source, sites = parsed.values_at(:source, :sites)
98
- rows = MethodStatements.top_rows(source, path, sites)
99
- rows.group_by { lines[_1.line - 1][:span] }
100
- end
101
-
102
- # The rows of site's tree, as a file's page draws them, for
103
- # its row's fold in a card.
104
- def self.fold(source, sites, site_paths, site)
105
- condition = sites.fetch(site)
106
- tree = SiteTree.of(source, condition, site_paths.fetch(site))
107
- located = HtmlReport.located(source, condition, tree)
108
- HtmlTree.site_rows(located).join
109
- end
110
- end
111
- end