nxgreport 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/nxgreport.rb +365 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e8871ef7bb1a5b9761f45d3f9e6744a6d631937a5057c49c6adc3ed919e67c21
|
4
|
+
data.tar.gz: 5ed8bbb55a7bab68f372a736d72297df071c3059dc83947d95af050b4c9f3b4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c94075546b7ff7e02d0b8d918d85d28eefabfe843ce08115f9a941eb93f035ce4bedc906689489152c9053ee1e24189cc326ab910891c6262aea14949d7d850
|
7
|
+
data.tar.gz: 24ea61e93f5ce325c9c5d339784c4ee32d700c4dac98529965e19a566580e7f54f6035d12323f13a656e12a54aafa5477de4aaf4bf2e0a9acd2851638440ade5
|
data/lib/nxgreport.rb
ADDED
@@ -0,0 +1,365 @@
|
|
1
|
+
|
2
|
+
class NxgReport
|
3
|
+
|
4
|
+
attr_reader :nxg_report_path, :auto_open, :title
|
5
|
+
|
6
|
+
def setup(location: "./NxgReport.html", title: "Features Summary")
|
7
|
+
@nxg_report_path = location
|
8
|
+
@title = title
|
9
|
+
@auto_open = false
|
10
|
+
@features = Hash.new()
|
11
|
+
end
|
12
|
+
|
13
|
+
def open_upon_execution(value:true)
|
14
|
+
@auto_open = value
|
15
|
+
end
|
16
|
+
|
17
|
+
def log_test(feature_name, test_status)
|
18
|
+
test_pass = test_status.downcase.include?('pass')
|
19
|
+
if @features.key? feature_name
|
20
|
+
@features[feature_name][0]+=1
|
21
|
+
@features[feature_name][(test_pass) ? 1 : 2]+=1
|
22
|
+
else
|
23
|
+
@features[feature_name]=[0,0,0]
|
24
|
+
@features[feature_name][0]+=1
|
25
|
+
@features[feature_name][(test_pass) ? 1 : 2]+=1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def build()
|
30
|
+
write()
|
31
|
+
if @auto_open && report_success()
|
32
|
+
system("open #{@nxg_report_path}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Private methods
|
37
|
+
def log(message)
|
38
|
+
puts("🤖- #{message}")
|
39
|
+
end
|
40
|
+
|
41
|
+
def report_success()
|
42
|
+
return File.file?(@nxg_report_path)
|
43
|
+
end
|
44
|
+
|
45
|
+
def clean()
|
46
|
+
File.delete(@nxg_report_path) if File.file?(@nxg_report_path)
|
47
|
+
end
|
48
|
+
|
49
|
+
def htmlize(features)
|
50
|
+
html_content = ''
|
51
|
+
features.each do |name, metrics|
|
52
|
+
html_content += "\n<div class=\"module dark #{metrics[2] != 0 ? 'danger' : ''} \">
|
53
|
+
<div class=\"funcname\">
|
54
|
+
<h4>#{name}</h4>
|
55
|
+
</div>
|
56
|
+
<div class=\"total\">
|
57
|
+
<h6>Total</h6>
|
58
|
+
<h4>#{metrics[0]}</h4>
|
59
|
+
</div>
|
60
|
+
<div class=\"pass\">
|
61
|
+
<h6>Passed</h6>
|
62
|
+
<h4>#{metrics[1]}</h4>
|
63
|
+
</div>
|
64
|
+
<div class=\"fail\">
|
65
|
+
<h6>Failed</h6>
|
66
|
+
<h4>#{metrics[2]}</h4>
|
67
|
+
</div>
|
68
|
+
</div>"
|
69
|
+
end
|
70
|
+
return html_content
|
71
|
+
end
|
72
|
+
|
73
|
+
def write()
|
74
|
+
if @features.length == 0
|
75
|
+
log("No tests logged, cannot build empty report.")
|
76
|
+
return
|
77
|
+
end
|
78
|
+
clean()
|
79
|
+
template = File.new(@nxg_report_path, 'w')
|
80
|
+
template.puts("<html lang=\"en\">
|
81
|
+
<head>
|
82
|
+
<meta charset=\"UTF-8\" />
|
83
|
+
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />
|
84
|
+
<title id=\"meta-app-title\"></title>
|
85
|
+
<link
|
86
|
+
href=\"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap\"
|
87
|
+
rel=\"stylesheet\"
|
88
|
+
/>
|
89
|
+
<link
|
90
|
+
href=\"https://fonts.googleapis.com/icon?family=Material+Icons\"
|
91
|
+
rel=\"stylesheet\"
|
92
|
+
/>
|
93
|
+
<style>
|
94
|
+
:root {
|
95
|
+
--dark-bg: rgb(41, 40, 40);
|
96
|
+
--dark-primary: #050505;
|
97
|
+
--dark-font: rgb(201, 201, 201);
|
98
|
+
--dark-blue: rgb(0, 225, 255);
|
99
|
+
--dark-green: rgba(115, 255, 0, 0.89);
|
100
|
+
--dark-red: rgb(255, 0, 0);
|
101
|
+
|
102
|
+
--light-bg: rgb(226, 226, 226);
|
103
|
+
--light-primary: #fff;
|
104
|
+
--light-font: rgb(44, 44, 44);
|
105
|
+
--light-blue: rgb(1, 67, 165);
|
106
|
+
--light-green: rgb(14, 138, 2);
|
107
|
+
--light-red: rgb(255, 0, 0);
|
108
|
+
|
109
|
+
--font: \"Open Sans\", sans-serif;
|
110
|
+
--danger-bg: rgba(255, 0, 0, 0.185);
|
111
|
+
}
|
112
|
+
|
113
|
+
body {
|
114
|
+
font-family: var(--font);
|
115
|
+
margin: auto;
|
116
|
+
}
|
117
|
+
|
118
|
+
.wrapper {
|
119
|
+
display: grid;
|
120
|
+
grid-template-rows: auto 1fr;
|
121
|
+
height: 100vh;
|
122
|
+
width: 100vw;
|
123
|
+
}
|
124
|
+
|
125
|
+
.header {
|
126
|
+
display: grid;
|
127
|
+
grid-template-columns: 6fr 1fr;
|
128
|
+
text-align: center;
|
129
|
+
background: linear-gradient(to bottom right, #ff644e, #cb3018);
|
130
|
+
}
|
131
|
+
|
132
|
+
.mc {
|
133
|
+
display: grid;
|
134
|
+
grid-template-columns: 1fr 1fr 1fr;
|
135
|
+
grid-auto-rows: 70px;
|
136
|
+
grid-gap: 0.5em;
|
137
|
+
padding: 0.5em 2em;
|
138
|
+
padding-top: 2em;
|
139
|
+
}
|
140
|
+
|
141
|
+
.footer {
|
142
|
+
margin-bottom: 1em;
|
143
|
+
padding: 3em;
|
144
|
+
text-align: center;
|
145
|
+
font-size: 0.7rem;
|
146
|
+
font-weight: 600;
|
147
|
+
}
|
148
|
+
|
149
|
+
a {
|
150
|
+
cursor: pointer;
|
151
|
+
font-weight: 600;
|
152
|
+
}
|
153
|
+
|
154
|
+
.module {
|
155
|
+
display: grid;
|
156
|
+
place-items: center;
|
157
|
+
grid-template-columns: 3fr 1fr 1fr 1fr;
|
158
|
+
border-radius: 0.7rem;
|
159
|
+
padding: 10px 10px;
|
160
|
+
}
|
161
|
+
|
162
|
+
.button-wrapper {
|
163
|
+
place-items: center;
|
164
|
+
}
|
165
|
+
|
166
|
+
#theme-switch {
|
167
|
+
width: 5em;
|
168
|
+
height: 5em;
|
169
|
+
background-color: Transparent;
|
170
|
+
background-repeat: no-repeat;
|
171
|
+
border: none;
|
172
|
+
cursor: pointer;
|
173
|
+
overflow: hidden;
|
174
|
+
outline: none;
|
175
|
+
margin: 0;
|
176
|
+
position: relative;
|
177
|
+
top: 50%;
|
178
|
+
-ms-transform: translateY(-50%);
|
179
|
+
transform: translateY(-50%);
|
180
|
+
}
|
181
|
+
|
182
|
+
h2,
|
183
|
+
h3,
|
184
|
+
h4,
|
185
|
+
h5,
|
186
|
+
h6 {
|
187
|
+
text-align: center;
|
188
|
+
margin: auto;
|
189
|
+
}
|
190
|
+
|
191
|
+
.total,
|
192
|
+
.pass,
|
193
|
+
.fail {
|
194
|
+
display: grid;
|
195
|
+
width: 100%;
|
196
|
+
height: 100%;
|
197
|
+
place-items: center;
|
198
|
+
}
|
199
|
+
|
200
|
+
body.dark {
|
201
|
+
background-color: var(--dark-bg);
|
202
|
+
color: var(--dark-font);
|
203
|
+
}
|
204
|
+
|
205
|
+
body.dark > .wrapper > .footer {
|
206
|
+
color: var(--dark-font);
|
207
|
+
}
|
208
|
+
|
209
|
+
body.dark > .wrapper > .mc > .module {
|
210
|
+
background-color: var(--dark-primary);
|
211
|
+
color: var(--dark-font);
|
212
|
+
}
|
213
|
+
|
214
|
+
body.dark > .wrapper > .mc > .module > .total {
|
215
|
+
color: var(--dark-blue);
|
216
|
+
}
|
217
|
+
|
218
|
+
body.dark > .wrapper > .mc > .module > .pass {
|
219
|
+
color: var(--dark-green);
|
220
|
+
}
|
221
|
+
|
222
|
+
body.dark > .wrapper > .mc > .module > .fail {
|
223
|
+
color: var(--dark-red);
|
224
|
+
}
|
225
|
+
|
226
|
+
body.dark > .wrapper > .mc > .module.danger {
|
227
|
+
background-color: rgba(255, 0, 0, 0.185);
|
228
|
+
}
|
229
|
+
|
230
|
+
body.dark > .wrapper > .header {
|
231
|
+
color: var(--dark-primary);
|
232
|
+
}
|
233
|
+
|
234
|
+
body.dark > .wrapper > .footer > p > span > a {
|
235
|
+
color: var(--dark-font);
|
236
|
+
}
|
237
|
+
|
238
|
+
body.dark > .wrapper > .header > div > button > #theme-switch-icon {
|
239
|
+
color: var(--dark-primary);
|
240
|
+
}
|
241
|
+
|
242
|
+
body {
|
243
|
+
background-color: var(--light-bg);
|
244
|
+
color: var(--dark-font);
|
245
|
+
}
|
246
|
+
|
247
|
+
body > .wrapper > .footer {
|
248
|
+
color: var(--light-font);
|
249
|
+
}
|
250
|
+
|
251
|
+
body > .wrapper > .mc > .module {
|
252
|
+
background-color: var(--light-primary);
|
253
|
+
color: var(--light-font);
|
254
|
+
}
|
255
|
+
|
256
|
+
body > .wrapper > .mc > .module > .total {
|
257
|
+
color: var(--light-blue);
|
258
|
+
}
|
259
|
+
|
260
|
+
body > .wrapper > .mc > .module > .pass {
|
261
|
+
color: var(--light-green);
|
262
|
+
}
|
263
|
+
|
264
|
+
body > .wrapper > .mc > .module > .fail {
|
265
|
+
color: var(--light-red);
|
266
|
+
}
|
267
|
+
|
268
|
+
body > .wrapper > .mc > .module.danger {
|
269
|
+
background-color: var(--danger-bg);
|
270
|
+
}
|
271
|
+
|
272
|
+
body > .wrapper > .header {
|
273
|
+
color: var(--light-primary);
|
274
|
+
}
|
275
|
+
|
276
|
+
body > .wrapper > .footer > p > span > a {
|
277
|
+
color: var(--light-font);
|
278
|
+
}
|
279
|
+
|
280
|
+
body > .wrapper > .header > div > button > #theme-switch-icon {
|
281
|
+
color: var(--light-primary);
|
282
|
+
}
|
283
|
+
|
284
|
+
@media only screen and (max-width: 600px) {
|
285
|
+
h1 {
|
286
|
+
font-size: 24px;
|
287
|
+
}
|
288
|
+
|
289
|
+
.mc {
|
290
|
+
grid-template-columns: 1fr;
|
291
|
+
padding: 0.5em 0.5em;
|
292
|
+
padding-top: 1em;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
|
296
|
+
@media (min-width: 600px) and (max-width: 992px) {
|
297
|
+
.mc {
|
298
|
+
grid-template-columns: 1fr 1fr;
|
299
|
+
}
|
300
|
+
}
|
301
|
+
</style>
|
302
|
+
</head>
|
303
|
+
<body class=\"dark\" id=\"app\">
|
304
|
+
<div class=\"wrapper\">
|
305
|
+
<div class=\"header\">
|
306
|
+
<h1 id=\"app-title\"></h1>
|
307
|
+
<div class=\"button-wrapper\">
|
308
|
+
<button id=\"theme-switch\" onclick=\"handleThemeSwitch()\">
|
309
|
+
<i class=\"material-icons\" id=\"theme-switch-icon\">brightness_2</i>
|
310
|
+
</button>
|
311
|
+
</div>
|
312
|
+
</div>
|
313
|
+
<div class=\"mc\">
|
314
|
+
#{htmlize(@features)}
|
315
|
+
</div>
|
316
|
+
<div class=\"footer\">
|
317
|
+
<p>
|
318
|
+
Developed by
|
319
|
+
<span
|
320
|
+
><a
|
321
|
+
href=\"https://www.linkedin.com/in/balabharathijayaraman\"
|
322
|
+
rel=\"nofollow\"
|
323
|
+
target=\"_blank\"
|
324
|
+
>Balabharathi Jayaraman</a
|
325
|
+
></span
|
326
|
+
>
|
327
|
+
</p>
|
328
|
+
</div>
|
329
|
+
</div>
|
330
|
+
</body>
|
331
|
+
<script>
|
332
|
+
var appTitle = \"#{@title}\";
|
333
|
+
var theme = \"dark\";
|
334
|
+
|
335
|
+
window.onload = function () {
|
336
|
+
document.getElementById(
|
337
|
+
\"meta-app-title\"
|
338
|
+
).innerHTML = `Home | ${appTitle}`;
|
339
|
+
document.getElementById(\"app-title\").innerHTML = appTitle;
|
340
|
+
};
|
341
|
+
|
342
|
+
function handleThemeSwitch() {
|
343
|
+
if (theme === \"dark\") {
|
344
|
+
theme = \"light\";
|
345
|
+
document.getElementById(\"app\").classList.remove(\"dark\");
|
346
|
+
document.getElementById(\"theme-switch-icon\").innerHTML = \"wb_sunny\";
|
347
|
+
document.getElementById(\"theme-switch-icon\");
|
348
|
+
return;
|
349
|
+
}
|
350
|
+
if (theme === \"light\") {
|
351
|
+
theme = \"dark\";
|
352
|
+
document.getElementById(\"app\").classList.add(\"dark\");
|
353
|
+
document.getElementById(\"theme-switch-icon\").innerHTML = \"brightness_2\";
|
354
|
+
}
|
355
|
+
}
|
356
|
+
</script>
|
357
|
+
</html>
|
358
|
+
")
|
359
|
+
template.close()
|
360
|
+
end
|
361
|
+
|
362
|
+
private :log, :clean, :write, :htmlize, :report_success
|
363
|
+
end
|
364
|
+
|
365
|
+
$NxgReport = NxgReport.new()
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nxgreport
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Balabharathi Jayaraman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-09-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple light weighted gem to generate a beautiful emailable test report.
|
14
|
+
It displays a single view where tests (total, pass, fail) are grouped by functionality.
|
15
|
+
The result is a single static HTML file with an option to switch between dark &
|
16
|
+
light modes.
|
17
|
+
email: balabharathi.jayaraman@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/nxgreport.rb
|
23
|
+
homepage: https://rubygemspec.org/gems/nxgreport
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata:
|
27
|
+
homepage_uri: https://rubygemspec.org/gems/nxgreport
|
28
|
+
source_code_uri: https://github.com/balabharathijayaraman/nxgreport
|
29
|
+
changelog_uri: https://github.com/balabharathijayaraman/nxgreport/blob/master/CHANGELOG.md
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubygems_version: 3.0.3
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Next Gen Report
|
49
|
+
test_files: []
|