-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy path_stats.scss
66 lines (57 loc) · 1.73 KB
/
_stats.scss
1
2
3
4
5
6
7
8
9
10
11
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
@use 'sass:map';
@use 'utilities';
// Stats Count
// -----------
/// Global stats count of how many modules, tests, and assertions are found
/// @access private
/// @group private-context
/// @type Map<String: Number>
$stats: (
'modules': 0,
'tests': 0,
'assertions': 0,
);
// Update stats count
// ------------------
/// Add to a stats count type count by 1
/// @param {String} $type - The stats type to add to
/// @access private
/// @group private-context
@mixin update-stats-count($type) {
$update: (
$type: 1,
);
$stats: utilities.map-increment($stats, $update) !global;
}
// Stats Message
// -------------
/// Stats message
/// @access private
/// @group private-message
/// @param {Bool} $linebreak [false] -
/// Return message either as a single line or in multiple lines
/// @param {Map} $stats [$stats] -
/// Map that contains the stats counts for modules, tests, and assertions found
/// @return {String} - Stats count message
@function stats-message($linebreak: false, $stats: $stats) {
// Get Results
$modules: map.get($stats, 'modules');
$tests: map.get($stats, 'tests');
$assertions: map.get($stats, 'assertions');
// Pluralize Labels
$modules-label: if($modules == 1, 'Module', 'Modules');
$tests-label: if($tests == 1, 'Test', 'Tests');
$assertions-label: if($assertions == 1, 'Assertion', 'Assertions');
// Combine Results with Labels
$modules: '#{$modules} #{$modules-label}';
$tests: '#{$tests} #{$tests-label}';
$assertions: '#{$assertions} #{$assertions-label}';
// Linebreaks
@if $linebreak {
$message: ('Stats:', '- #{$modules}', '- #{$tests}', '- #{$assertions}');
@return $message;
}
// No Linebreaks
$message: '#{$modules}, #{$tests}, #{$assertions}';
@return $message;
}