Module: NxgHTML
Instance Method Summary
collapse
#js, #js_detect_system_dark_mode
Methods included from NxgCss
#css, #has_environment_settings
Instance Method Details
#app_version ⇒ Object
160
161
162
163
164
|
# File 'lib/nxgreport/nxghtml.rb', line 160
def app_version()
return if !@data_provider.key?(:app_version)
return config_item("App version tested", @data_provider[:app_version], "info")
end
|
#body ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/nxgreport/nxghtml.rb', line 45
def body()
"<body id=\"app\" onload=\"onRefresh()\">
<div id=\"sidebar\" onclick=\"closeDetails(event)\">
<div id=\"sidebar-div\">
<div id=\"sidebar-title-wrap\">
<h1 id=\"sidebar-title\">Title</h1>
<i class=\"material-icons\" id=\"sidebar-status\">check_circle</i>
</div>
<div id=\"sidebar-catergories\">
</div>
</div>
</div>
<div id=\"sidebar-overlay\" onclick=\"closeDetails(event)\">
<div id=\"sidebar-overlay-grid\"></div>
</div>
<div id=\"body-wrap\">
#{()}
#{config()}
#{features()}
#{()}
</div>
</body>"
end
|
#config ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/nxgreport/nxghtml.rb', line 100
def config()
return if @data_provider.length == 0
return "<div class=\"params-container\">
#{release_name()}
#{execution_date()}
#{device()}
#{os()}
#{app_version()}
#{environment()}
#{passed_tests()}
#{failed_tests()}
#{percentage_pass()}
#{execution_time()}
#{filter()}
</div>"
end
|
#config_item(toot_tip, name, icon) ⇒ Object
190
191
192
193
194
195
|
# File 'lib/nxgreport/nxghtml.rb', line 190
def config_item(toot_tip, name, icon)
"<div class=\"param-wrap\" title=\"#{toot_tip}\">
<i class=\"pi material-icons\">#{icon}</i>
<h5 id=\"pt\">#{name}</h5>
</div>"
end
|
#device ⇒ Object
178
179
180
181
182
|
# File 'lib/nxgreport/nxghtml.rb', line 178
def device()
return if !@data_provider.key?(:device)
return config_item("Device tested", @data_provider[:device], "devices")
end
|
#environment ⇒ Object
154
155
156
157
158
|
# File 'lib/nxgreport/nxghtml.rb', line 154
def environment()
return if !@data_provider.key?(:environment)
return config_item("Test environment", @data_provider[:environment], "layers")
end
|
#execution_date ⇒ Object
184
185
186
187
188
|
# File 'lib/nxgreport/nxghtml.rb', line 184
def execution_date()
@data_provider[:execution_date] = Time.now().strftime("%b %d, %Y") if !@data_provider.key?(:execution_date)
return config_item("Execution date", @data_provider[:execution_date], "event")
end
|
#execution_time ⇒ Object
118
119
120
121
122
|
# File 'lib/nxgreport/nxghtml.rb', line 118
def execution_time()
return if !@data_provider.key?(:environment)
return config_item("Total execution time", @data_provider[:execution_time],'access_time')
end
|
#failed_tests ⇒ Object
138
139
140
141
142
143
|
# File 'lib/nxgreport/nxghtml.rb', line 138
def failed_tests()
"<div class=\"param-wrap\" title=\"Failed tests\" #{@data_provider[:fail] > 0 ? "onclick=\"filterAllFailed()\" style=\"cursor: pointer\"" : ""}>
<i class=\"pi red-font material-icons\">cancel</i>
<h5 id=\"pt\">#{@data_provider[:fail] == 0 ? "None" : @data_provider[:fail]}</h5>
</div>"
end
|
#features ⇒ Object
80
81
82
|
# File 'lib/nxgreport/nxghtml.rb', line 80
def features()
"<div class=\"features-grid\"></div>"
end
|
#filter ⇒ Object
124
125
126
127
128
129
|
# File 'lib/nxgreport/nxghtml.rb', line 124
def filter()
"<div class=\"param-wrap\" onclick=\"setFilter()\" id=\"filter\" title=\"Filter tests\">
<i class=\"pi material-icons\">filter_list</i>
<h5 id=\"pt\">Failed</h5>
</div>"
end
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/nxgreport/nxghtml.rb', line 84
def ()
"<div id=\"footer\">
<p>
Made with ❤️ by
<span>
<a
href=\"https://www.linkedin.com/in/balabharathijayaraman\"
rel=\"noopener\"
target=\"_blank\"
>Balabharathi Jayaraman</a
>
</span>
</p>
</div>"
end
|
#google_fonts_link ⇒ Object
31
32
33
34
35
36
|
# File 'lib/nxgreport/nxghtml.rb', line 31
def google_fonts_link()
"<link
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\"
rel=\"stylesheet\"
/>"
end
|
#head ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/nxgreport/nxghtml.rb', line 18
def head()
"<head>
<meta charset=\"UTF-8\" />
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />
<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js\"></script>
<script> #{js_detect_system_dark_mode()}</script>
<title>Home | #{@data_provider[:title]}</title>
#{google_fonts_link()}
#{icons_link()}
#{css(@data_provider)}
</head>"
end
|
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/nxgreport/nxghtml.rb', line 69
def ()
"<div id=\"header\">
<h1 id=\"app-title\">#{@data_provider[:title]}</h1>
<div id=\"theme-wrap\">
<button id=\"theme-switch\" onclick=\"switchTheme()\">
<i class=\"material-icons\" id=\"theme-icon\">wb_sunny</i>
</button>
</div>
</div>"
end
|
#html(data_provider) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/nxgreport/nxghtml.rb', line 9
def html(data_provider)
@data_provider = data_provider
"<html lang=\"en\">
#{head()}
#{body()}
#{js(@data_provider)}
</html>"
end
|
#icons_link ⇒ Object
38
39
40
41
42
43
|
# File 'lib/nxgreport/nxghtml.rb', line 38
def icons_link()
"<link
href=\"https://fonts.googleapis.com/icon?family=Material+Icons\"
rel=\"stylesheet\"
/>"
end
|
#os ⇒ Object
172
173
174
175
176
|
# File 'lib/nxgreport/nxghtml.rb', line 172
def os()
return if !@data_provider.key?(:os)
return config_item("Os tested", @data_provider[:os], "settings")
end
|
#passed_tests ⇒ Object
131
132
133
134
135
136
|
# File 'lib/nxgreport/nxghtml.rb', line 131
def passed_tests()
"<div class=\"param-wrap\" title=\"Passed tests\">
<i class=\"pi green-font material-icons\">check_circle</i>
<h5 id=\"pt\">#{@data_provider[:pass] == 0 ? "None" : @data_provider[:pass]}</h5>
</div>"
end
|
#percentage_pass ⇒ Object
145
146
147
148
149
150
151
152
|
# File 'lib/nxgreport/nxghtml.rb', line 145
def percentage_pass()
pass_percentage = ((@data_provider[:pass]/@data_provider[:total].to_f) * 100).round(2)
return "<div class=\"param-wrap\" title=\"Pass percentage\">
<i class=\"pi #{pass_percentage.to_i == 100 ? "green-font" : ""} material-icons\">equalizer</i>
<h5 id=\"pt\">#{pass_percentage.to_i == 100 ? pass_percentage.to_i : pass_percentage}%</h5>
</div>"
end
|
#release_name ⇒ Object
166
167
168
169
170
|
# File 'lib/nxgreport/nxghtml.rb', line 166
def release_name()
return if !@data_provider.key?(:release_name)
return config_item("Release", @data_provider[:release_name], "bookmark")
end
|