nxgreport 0.7.0 → 0.11.1
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.
- checksums.yaml +4 -4
- data/lib/nxgreport.rb +3 -547
- data/lib/nxgreport/nxgcore.rb +217 -0
- data/lib/nxgreport/nxgcss.rb +323 -0
- data/lib/nxgreport/nxghtml.rb +196 -0
- data/lib/nxgreport/nxgjs.rb +233 -0
- data/lib/nxgreport/version.rb +3 -0
- metadata +43 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecd1ef355ed3e0f7b44b537362897089a908f186d99597f58d9b1067c6a8bc6e
|
4
|
+
data.tar.gz: 06c1251a9c70f668fa9341d0755c56f12a30866003c0d216ac46518a22fc86ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4ba5de6a50f78a563694fa659f6b93d65024736745340a31a53b5cdf8cfcb59e8274479e8f301752c3bfa1173134768567657cfd1cc4f4238911596b46e9c2f
|
7
|
+
data.tar.gz: 0bed8ff0e73a5d7af8ef00526f2b53e9b9a76256f3536bb3a3dca375101ef14cd2d276756f38f61f0a28d60fd1b234bc6a8e5e79b124b08390997ee3c56b47a2
|
data/lib/nxgreport.rb
CHANGED
@@ -1,549 +1,5 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require "nxgreport/version"
|
3
|
+
require 'nxgreport/nxgcore.rb'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
def setup(location: "./NxgReport.html", title: "Features Summary")
|
6
|
-
@nxg_report_path = location.empty? ? "./NxgReport.html" : location
|
7
|
-
folder_check()
|
8
|
-
@title = title
|
9
|
-
@title_color = ''
|
10
|
-
@execution_configuration = Hash.new()
|
11
|
-
@auto_open = false
|
12
|
-
@features = Hash.new()
|
13
|
-
end
|
14
|
-
|
15
|
-
def open_upon_execution(value:true)
|
16
|
-
@auto_open = value
|
17
|
-
end
|
18
|
-
|
19
|
-
def set_envrionment(name: "")
|
20
|
-
if name.empty?()
|
21
|
-
return
|
22
|
-
end
|
23
|
-
@execution_configuration[:environment] = name
|
24
|
-
end
|
25
|
-
|
26
|
-
def set_app_version(no: "")
|
27
|
-
if no.empty?()
|
28
|
-
return
|
29
|
-
end
|
30
|
-
version_no = no.downcase.gsub("app", "").gsub("version", "").strip
|
31
|
-
@execution_configuration[:app_version] = "App Version #{version_no}"
|
32
|
-
end
|
33
|
-
|
34
|
-
def set_release(name: "")
|
35
|
-
if name.empty?()
|
36
|
-
return
|
37
|
-
end
|
38
|
-
@execution_configuration[:release_name] = name
|
39
|
-
end
|
40
|
-
|
41
|
-
def set_os(name: "")
|
42
|
-
if name.empty?()
|
43
|
-
return
|
44
|
-
end
|
45
|
-
@execution_configuration[:os] = name
|
46
|
-
end
|
47
|
-
|
48
|
-
def set_device(name: "")
|
49
|
-
if name.empty?()
|
50
|
-
return
|
51
|
-
end
|
52
|
-
@execution_configuration[:device] = name
|
53
|
-
end
|
54
|
-
|
55
|
-
def set_execution(date: "")
|
56
|
-
if date.empty?()
|
57
|
-
return
|
58
|
-
end
|
59
|
-
@execution_configuration[:execution_date] = date
|
60
|
-
end
|
61
|
-
|
62
|
-
def log_test(feature_name: "", test_status: "")
|
63
|
-
if feature_name.nil?() || feature_name.strip.empty?()
|
64
|
-
log("Feature name cannot be empty.")
|
65
|
-
return
|
66
|
-
end
|
67
|
-
|
68
|
-
if test_status.nil?() || test_status.strip.empty?()
|
69
|
-
log("Test status cannot be empty.")
|
70
|
-
return
|
71
|
-
end
|
72
|
-
|
73
|
-
test_pass = test_status.downcase.include?('pass')
|
74
|
-
name = feature_name.strip()
|
75
|
-
|
76
|
-
if @features.key? name
|
77
|
-
@features[name][0]+=1
|
78
|
-
@features[name][(test_pass) ? 1 : 2]+=1
|
79
|
-
else
|
80
|
-
@features[name]=[0,0,0]
|
81
|
-
@features[name][0]+=1
|
82
|
-
@features[name][(test_pass) ? 1 : 2]+=1
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def build()
|
87
|
-
write()
|
88
|
-
if @auto_open && report_success()
|
89
|
-
system("open #{@nxg_report_path}")
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
# Private methods
|
94
|
-
def log(message)
|
95
|
-
puts("🤖- #{message}")
|
96
|
-
end
|
97
|
-
|
98
|
-
def folder_check()
|
99
|
-
folder = File.dirname(@nxg_report_path)
|
100
|
-
FileUtils.mkdir_p(folder) unless File.directory?(folder)
|
101
|
-
end
|
102
|
-
|
103
|
-
def report_success()
|
104
|
-
return File.file?(@nxg_report_path)
|
105
|
-
end
|
106
|
-
|
107
|
-
def clean()
|
108
|
-
File.delete(@nxg_report_path) if File.file?(@nxg_report_path)
|
109
|
-
end
|
110
|
-
|
111
|
-
def htmlize(features)
|
112
|
-
html_content = ''
|
113
|
-
features.each do |name, metrics|
|
114
|
-
html_content += "\n<div class=\"module dark #{metrics[2] != 0 ? 'danger' : ''} \">
|
115
|
-
<div class=\"funcname\">
|
116
|
-
<h4>#{name}</h4>
|
117
|
-
</div>
|
118
|
-
<div class=\"total\">
|
119
|
-
<h6>Total</h6>
|
120
|
-
<h4>#{metrics[0]}</h4>
|
121
|
-
</div>
|
122
|
-
<div class=\"pass\">
|
123
|
-
<h6>Passed</h6>
|
124
|
-
<h4>#{metrics[1]}</h4>
|
125
|
-
</div>
|
126
|
-
<div class=\"fail\">
|
127
|
-
<h6>Failed</h6>
|
128
|
-
<h4>#{metrics[2]}</h4>
|
129
|
-
</div>
|
130
|
-
</div>"
|
131
|
-
end
|
132
|
-
return html_content
|
133
|
-
end
|
134
|
-
|
135
|
-
def write()
|
136
|
-
if @features.length == 0
|
137
|
-
log("No tests logged, cannot build empty report.")
|
138
|
-
return
|
139
|
-
end
|
140
|
-
clean()
|
141
|
-
template = File.new(@nxg_report_path, 'w')
|
142
|
-
template.puts("<html lang=\"en\">
|
143
|
-
<head>
|
144
|
-
<meta charset=\"UTF-8\" />
|
145
|
-
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />
|
146
|
-
<title id=\"meta-app-title\"></title>
|
147
|
-
<link
|
148
|
-
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\"
|
149
|
-
rel=\"stylesheet\"
|
150
|
-
/>
|
151
|
-
<link
|
152
|
-
href=\"https://fonts.googleapis.com/icon?family=Material+Icons\"
|
153
|
-
rel=\"stylesheet\"
|
154
|
-
/>
|
155
|
-
<style>
|
156
|
-
:root {
|
157
|
-
--dark-bg: rgb(41, 40, 40);
|
158
|
-
--dark-primary: #050505;
|
159
|
-
--dark-font: rgb(201, 201, 201);
|
160
|
-
--dark-blue: rgb(0, 225, 255);
|
161
|
-
--dark-green: rgba(115, 255, 0, 0.89);
|
162
|
-
--dark-red: rgb(255, 0, 0);
|
163
|
-
|
164
|
-
--light-bg: rgb(226, 226, 226);
|
165
|
-
--light-primary: #fff;
|
166
|
-
--light-font: rgb(44, 44, 44);
|
167
|
-
--light-blue: rgb(1, 67, 165);
|
168
|
-
--light-green: rgb(14, 138, 2);
|
169
|
-
--light-red: rgb(255, 0, 0);
|
170
|
-
|
171
|
-
--font: \"Open Sans\", sans-serif;
|
172
|
-
--danger-bg: rgba(255, 0, 0, 0.185);
|
173
|
-
}
|
174
|
-
|
175
|
-
body {
|
176
|
-
font-family: var(--font);
|
177
|
-
margin: auto;
|
178
|
-
}
|
179
|
-
|
180
|
-
.wrapper {
|
181
|
-
display: grid;
|
182
|
-
grid-template-rows: auto auto 1fr;
|
183
|
-
height: 100vh;
|
184
|
-
width: 100vw;
|
185
|
-
}
|
186
|
-
|
187
|
-
.header {
|
188
|
-
display: grid;
|
189
|
-
grid-template-columns: 6fr 1fr;
|
190
|
-
text-align: center;
|
191
|
-
#{@title_color.empty?() ? "background: linear-gradient(to bottom right, #ff644e, #cb3018);" : "background-color: #{@title_color}"}
|
192
|
-
}
|
193
|
-
|
194
|
-
.test-config-area {
|
195
|
-
padding-top: 2em;
|
196
|
-
display: flex;
|
197
|
-
flex-wrap: wrap;
|
198
|
-
justify-content: space-around;
|
199
|
-
text-align: center;
|
200
|
-
}
|
201
|
-
|
202
|
-
.config-item {
|
203
|
-
display: flex;
|
204
|
-
|
205
|
-
}
|
206
|
-
|
207
|
-
.config-item-icon {
|
208
|
-
font-size: 2em;
|
209
|
-
padding-right: 0.5em;
|
210
|
-
}
|
211
|
-
|
212
|
-
.mc {
|
213
|
-
display: grid;
|
214
|
-
grid-template-columns: 1fr 1fr 1fr;
|
215
|
-
grid-auto-rows: 70px;
|
216
|
-
grid-gap: 0.5em;
|
217
|
-
padding: 0.5em 2em;
|
218
|
-
padding-top: 2em;
|
219
|
-
}
|
220
|
-
|
221
|
-
.footer {
|
222
|
-
margin-bottom: 1em;
|
223
|
-
padding: 3em;
|
224
|
-
text-align: center;
|
225
|
-
font-size: 0.7rem;
|
226
|
-
font-weight: 600;
|
227
|
-
}
|
228
|
-
|
229
|
-
a {
|
230
|
-
cursor: pointer;
|
231
|
-
font-weight: 600;
|
232
|
-
}
|
233
|
-
|
234
|
-
.module {
|
235
|
-
display: grid;
|
236
|
-
place-items: center;
|
237
|
-
grid-template-columns: 3fr 1fr 1fr 1fr;
|
238
|
-
border-radius: 0.7rem;
|
239
|
-
padding: 10px 10px;
|
240
|
-
}
|
241
|
-
|
242
|
-
.button-wrapper {
|
243
|
-
place-items: center;
|
244
|
-
}
|
245
|
-
|
246
|
-
#theme-switch {
|
247
|
-
width: 5em;
|
248
|
-
height: 5em;
|
249
|
-
background-color: Transparent;
|
250
|
-
background-repeat: no-repeat;
|
251
|
-
border: none;
|
252
|
-
cursor: pointer;
|
253
|
-
overflow: hidden;
|
254
|
-
outline: none;
|
255
|
-
margin: 0;
|
256
|
-
position: relative;
|
257
|
-
top: 50%;
|
258
|
-
-ms-transform: translateY(-50%);
|
259
|
-
transform: translateY(-50%);
|
260
|
-
}
|
261
|
-
|
262
|
-
h2,
|
263
|
-
h3,
|
264
|
-
h4,
|
265
|
-
h5,
|
266
|
-
h6 {
|
267
|
-
text-align: center;
|
268
|
-
margin: auto;
|
269
|
-
}
|
270
|
-
|
271
|
-
.total,
|
272
|
-
.pass,
|
273
|
-
.fail {
|
274
|
-
display: grid;
|
275
|
-
width: 100%;
|
276
|
-
height: 100%;
|
277
|
-
place-items: center;
|
278
|
-
}
|
279
|
-
|
280
|
-
body.dark {
|
281
|
-
background-color: var(--dark-bg);
|
282
|
-
color: var(--dark-font);
|
283
|
-
}
|
284
|
-
|
285
|
-
body.dark > .wrapper > .footer {
|
286
|
-
color: var(--dark-font);
|
287
|
-
}
|
288
|
-
|
289
|
-
body.dark > .wrapper > .mc > .module {
|
290
|
-
background-color: var(--dark-primary);
|
291
|
-
color: var(--dark-font);
|
292
|
-
}
|
293
|
-
|
294
|
-
body.dark > .wrapper > .mc > .module > .total {
|
295
|
-
color: var(--dark-blue);
|
296
|
-
}
|
297
|
-
|
298
|
-
body.dark > .wrapper > .mc > .module > .pass {
|
299
|
-
color: var(--dark-green);
|
300
|
-
}
|
301
|
-
|
302
|
-
body.dark > .wrapper > .mc > .module > .fail {
|
303
|
-
color: var(--dark-red);
|
304
|
-
}
|
305
|
-
|
306
|
-
body.dark > .wrapper > .mc > .module.danger {
|
307
|
-
background-color: rgba(255, 0, 0, 0.185);
|
308
|
-
}
|
309
|
-
|
310
|
-
body.dark > .wrapper > .header {
|
311
|
-
color: var(--dark-primary);
|
312
|
-
}
|
313
|
-
|
314
|
-
body.dark > .wrapper > .test-config-area > .config-item {
|
315
|
-
color: var(--dark-font);
|
316
|
-
}
|
317
|
-
|
318
|
-
body.dark > .wrapper > .footer > p > span > a {
|
319
|
-
color: var(--dark-font);
|
320
|
-
}
|
321
|
-
|
322
|
-
body.dark > .wrapper > .header > div > button > #theme-switch-icon {
|
323
|
-
color: var(--dark-primary);
|
324
|
-
}
|
325
|
-
|
326
|
-
body {
|
327
|
-
background-color: var(--light-bg);
|
328
|
-
color: var(--dark-font);
|
329
|
-
}
|
330
|
-
|
331
|
-
body > .wrapper > .footer {
|
332
|
-
color: var(--light-font);
|
333
|
-
}
|
334
|
-
|
335
|
-
body > .wrapper > .mc > .module {
|
336
|
-
background-color: var(--light-primary);
|
337
|
-
color: var(--light-font);
|
338
|
-
}
|
339
|
-
|
340
|
-
body > .wrapper > .mc > .module > .total {
|
341
|
-
color: var(--light-blue);
|
342
|
-
}
|
343
|
-
|
344
|
-
body > .wrapper > .mc > .module > .pass {
|
345
|
-
color: var(--light-green);
|
346
|
-
}
|
347
|
-
|
348
|
-
body > .wrapper > .mc > .module > .fail {
|
349
|
-
color: var(--light-red);
|
350
|
-
}
|
351
|
-
|
352
|
-
body > .wrapper > .mc > .module.danger {
|
353
|
-
background-color: var(--danger-bg);
|
354
|
-
}
|
355
|
-
|
356
|
-
body > .wrapper > .header {
|
357
|
-
color: var(--light-primary);
|
358
|
-
}
|
359
|
-
|
360
|
-
body > .wrapper > .test-config-area > .config-item {
|
361
|
-
color: var(--light-font);
|
362
|
-
}
|
363
|
-
|
364
|
-
body > .wrapper > .footer > p > span > a {
|
365
|
-
color: var(--light-font);
|
366
|
-
}
|
367
|
-
|
368
|
-
body > .wrapper > .header > div > button > #theme-switch-icon {
|
369
|
-
color: var(--light-primary);
|
370
|
-
}
|
371
|
-
|
372
|
-
@media only screen and (max-width: 600px) {
|
373
|
-
h1 {
|
374
|
-
font-size: 24px;
|
375
|
-
}
|
376
|
-
|
377
|
-
.mc {
|
378
|
-
grid-template-columns: 1fr;
|
379
|
-
padding: 0.5em 0.5em;
|
380
|
-
padding-top: 1em;
|
381
|
-
}
|
382
|
-
}
|
383
|
-
|
384
|
-
@media (min-width: 600px) and (max-width: 992px) {
|
385
|
-
.mc {
|
386
|
-
grid-template-columns: 1fr 1fr;
|
387
|
-
}
|
388
|
-
}
|
389
|
-
</style>
|
390
|
-
</head>
|
391
|
-
<body class=\"dark\" id=\"app\">
|
392
|
-
<div class=\"wrapper\">
|
393
|
-
<div class=\"header\">
|
394
|
-
<h1 id=\"app-title\"></h1>
|
395
|
-
<div class=\"button-wrapper\">
|
396
|
-
<button id=\"theme-switch\" onclick=\"handleThemeSwitch()\">
|
397
|
-
<i class=\"material-icons\" id=\"theme-switch-icon\">brightness_2</i>
|
398
|
-
</button>
|
399
|
-
</div>
|
400
|
-
</div>
|
401
|
-
#{config_htmlize()}
|
402
|
-
<div class=\"mc\">
|
403
|
-
#{htmlize(@features)}
|
404
|
-
</div>
|
405
|
-
<div class=\"footer\">
|
406
|
-
<p>
|
407
|
-
Developed by
|
408
|
-
<span
|
409
|
-
><a
|
410
|
-
href=\"https://www.linkedin.com/in/balabharathijayaraman\"
|
411
|
-
rel=\"nofollow\"
|
412
|
-
target=\"_blank\"
|
413
|
-
>Balabharathi Jayaraman</a
|
414
|
-
></span
|
415
|
-
>
|
416
|
-
</p>
|
417
|
-
</div>
|
418
|
-
</div>
|
419
|
-
</body>
|
420
|
-
<script>
|
421
|
-
var appTitle = \"#{@title}\";
|
422
|
-
var theme = \"dark\";
|
423
|
-
|
424
|
-
window.onload = function () {
|
425
|
-
document.getElementById(
|
426
|
-
\"meta-app-title\"
|
427
|
-
).innerHTML = `Home | ${appTitle}`;
|
428
|
-
document.getElementById(\"app-title\").innerHTML = appTitle;
|
429
|
-
};
|
430
|
-
|
431
|
-
function handleThemeSwitch() {
|
432
|
-
if (theme === \"dark\") {
|
433
|
-
theme = \"light\";
|
434
|
-
document.getElementById(\"app\").classList.remove(\"dark\");
|
435
|
-
document.getElementById(\"theme-switch-icon\").innerHTML = \"wb_sunny\";
|
436
|
-
document.getElementById(\"theme-switch-icon\");
|
437
|
-
return;
|
438
|
-
}
|
439
|
-
if (theme === \"light\") {
|
440
|
-
theme = \"dark\";
|
441
|
-
document.getElementById(\"app\").classList.add(\"dark\");
|
442
|
-
document.getElementById(\"theme-switch-icon\").innerHTML = \"brightness_2\";
|
443
|
-
}
|
444
|
-
}
|
445
|
-
</script>
|
446
|
-
</html>
|
447
|
-
")
|
448
|
-
template.close()
|
449
|
-
end
|
450
|
-
|
451
|
-
def config_htmlize()
|
452
|
-
|
453
|
-
if @execution_configuration.length == 0
|
454
|
-
return
|
455
|
-
end
|
456
|
-
|
457
|
-
return "
|
458
|
-
<div class=\"test-config-area\">
|
459
|
-
#{execution_date_htmllize()}
|
460
|
-
#{device_htmllize()}
|
461
|
-
#{os_htmllize()}
|
462
|
-
#{release_name_htmllize()}
|
463
|
-
#{app_version_htmllize()}
|
464
|
-
#{environment_htmllize()}
|
465
|
-
</div>"
|
466
|
-
end
|
467
|
-
|
468
|
-
def environment_htmllize()
|
469
|
-
if !@execution_configuration.key?(:environment)
|
470
|
-
return
|
471
|
-
end
|
472
|
-
|
473
|
-
return "<div class=\"config-item\">
|
474
|
-
<i class=\"config-item-icon material-icons\" id=\"theme-switch-icon\"
|
475
|
-
>layers</i
|
476
|
-
>
|
477
|
-
<h5>#{@execution_configuration[:environment]}</h5>
|
478
|
-
</div>"
|
479
|
-
end
|
480
|
-
|
481
|
-
def app_version_htmllize()
|
482
|
-
if !@execution_configuration.key?(:app_version)
|
483
|
-
return
|
484
|
-
end
|
485
|
-
|
486
|
-
return "<div class=\"config-item\">
|
487
|
-
<i class=\"config-item-icon material-icons\" id=\"theme-switch-icon\"
|
488
|
-
>info</i
|
489
|
-
>
|
490
|
-
<h5>#{@execution_configuration[:app_version]}</h5>
|
491
|
-
</div>"
|
492
|
-
end
|
493
|
-
|
494
|
-
def release_name_htmllize()
|
495
|
-
if !@execution_configuration.key?(:release_name)
|
496
|
-
return
|
497
|
-
end
|
498
|
-
|
499
|
-
return "<div class=\"config-item\">
|
500
|
-
<i class=\"config-item-icon material-icons\" id=\"theme-switch-icon\"
|
501
|
-
>bookmark</i
|
502
|
-
>
|
503
|
-
<h5>#{@execution_configuration[:release_name]}</h5>
|
504
|
-
</div>"
|
505
|
-
end
|
506
|
-
|
507
|
-
def os_htmllize()
|
508
|
-
if !@execution_configuration.key?(:os)
|
509
|
-
return
|
510
|
-
end
|
511
|
-
|
512
|
-
return "<div class=\"config-item\">
|
513
|
-
<i class=\"config-item-icon material-icons\" id=\"theme-switch-icon\"
|
514
|
-
>settings</i
|
515
|
-
>
|
516
|
-
<h5>#{@execution_configuration[:os]}</h5>
|
517
|
-
</div>"
|
518
|
-
end
|
519
|
-
|
520
|
-
def device_htmllize()
|
521
|
-
if !@execution_configuration.key?(:device)
|
522
|
-
return
|
523
|
-
end
|
524
|
-
|
525
|
-
return "<div class=\"config-item\">
|
526
|
-
<i class=\"config-item-icon material-icons\" id=\"theme-switch-icon\"
|
527
|
-
>devices_other</i
|
528
|
-
>
|
529
|
-
<h5>#{@execution_configuration[:device]}</h5>
|
530
|
-
</div>"
|
531
|
-
end
|
532
|
-
|
533
|
-
def execution_date_htmllize()
|
534
|
-
if !@execution_configuration.key?(:execution_date)
|
535
|
-
return
|
536
|
-
end
|
537
|
-
|
538
|
-
return "<div class=\"config-item\">
|
539
|
-
<i class=\"config-item-icon material-icons\" id=\"theme-switch-icon\"
|
540
|
-
>date_range</i
|
541
|
-
>
|
542
|
-
<h5>#{@execution_configuration[:execution_date]}</h5>
|
543
|
-
</div>"
|
544
|
-
end
|
545
|
-
|
546
|
-
private :log, :clean, :write, :htmlize, :report_success, :config_htmlize
|
547
|
-
end
|
548
|
-
|
549
|
-
$NxgReport = NxgReport.new()
|
5
|
+
$NxgReport = NxgCore.new().instance()
|