Class: SodaLogReporter
- Inherits:
-
Object
- Object
- SodaLogReporter
- Defined in:
- lib/SodaLogReporter.rb
Overview
SodaLogReporter – Class
This is a simple class to take a raw soda report file and turn it into
a more readable html report file.
Params:
sodalog_file: This is the log file to be used to generate the html.
output_file: This is the name of the html report file to create.
Results:
None.
Instance Method Summary collapse
-
#FormatAssertionFailed(line) ⇒ Object
FormatAssertionFailed – Method This method takes an assertion failed line from the raw soda log and creates a nice happy html row from it.
-
#FormatAssertionPassed(line) ⇒ Object
FormatAssertionPassed – Method This method takes an assertion passed line from the raw soda log and creates a nice happy html row from it.
-
#FormatClickingElement(line) ⇒ Object
FormatClickingElement – Method This method finds the replace string message and reformats it a little.
-
#FormatEventDump(line) ⇒ Object
FormatEventDump – Method This method formats a soda event dump log message.
-
#FormatExceptionBT(line) ⇒ Object
FormatExceptionBT – Method This method takes a exception bt from the soda log and makes a nicely formatted html table row with it.
-
#FormatHTMLSavedResults(line) ⇒ Object
FormatHTMLSavedResults – Method This method takes the “HTML Saved” line from the Soda log file and generates a happy html table row from it.
-
#FormatJSError(line) ⇒ Object
FormatJSError – Method This method takes a java script soda error line and formats it into html.
-
#FormatMajorException(line) ⇒ Object
FormatMajorException – Method This method takes a major exception line from a raw soda log and craetes a nice happy html row from it.
-
#FormatModuleLine(type, line) ⇒ Object
FormatModuleLine – Method This method takes a module lines and formats it for html.
-
#FormatReplacingString(line) ⇒ Object
FormatReplacingString – Method This method finds the replace string message and reformats it a little.
-
#FormatScreenShot(line) ⇒ Object
FormatScreenShot – Method This method converts the screenshot log file line into a nice html item for the html log.
-
#FormatTestResults(line) ⇒ Object
FormatTestResults – Method This method takes the results log file line and generates a nice and happy html row.
-
#GenerateHtmlHeader(title = "Soda Test Report:") ⇒ Object
GenerateHtmlHeader – Method This function will create the proper html header for the report file that we generate.
-
#GenerateReport ⇒ Object
GenerateReport – Method This function generates an html report file.
-
#GenerateTableRow(line) ⇒ Object
GenerateTableRow – Method This function generates a new html table row from a row log line.
-
#initialize(sodalog_file, output_file) ⇒ SodaLogReporter
constructor
A new instance of SodaLogReporter.
-
#SafeHTMLStr(str) ⇒ Object
SafeHTMLStr – Method This method makes a string html safe by peforming proper escapes.
Constructor Details
#initialize(sodalog_file, output_file) ⇒ SodaLogReporter
Returns a new instance of SodaLogReporter.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/SodaLogReporter.rb', line 54 def initialize (sodalog_file, output_file) if (!File.exist?(sodalog_file)) raise(ArgumentError, "(!)Can't find file: #{sodalog_file}!\n", caller) end if (!output_file) raise(ArgumentError, "(!)Missing argument: output_file!\n", caller) end @SodaLogFile = sodalog_file @OutPutFile = output_file @BackTraceID = 0 @EventDumpID = 0 end |
Instance Method Details
#FormatAssertionFailed(line) ⇒ Object
FormatAssertionFailed – Method
This method takes an assertion failed line from the raw soda log and
creates a nice happy html row from it.
Params:
line: This is the assertion failed line from the log file.
Results:
returns a hash that is the expected format.
Data: Hash format:
row_data['date']
row_data['msg_type']
row_data['msg']
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
# File 'lib/SodaLogReporter.rb', line 446 def FormatAssertionFailed (line) row_data = Hash.new() line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "#{$2}" msg = "#{$3}" assert_data = msg.split("--") if ( (assert_data[3].nil?) || (assert_data[3].empty?)) assert_data[3] = "No message found in log file." else assert_data[3] = assert_data[3].gsub(/^Assertion\s+Message:/i, "") end if ( (assert_data[4].nil?) || (assert_data[4].empty?)) assert_data[4] = "No line number found!" end url_html = "<a href=\"#{assert_data[1]}\">#{assert_data[1]}</a>" row_data['msg'] = "<b>#{assert_data[0]}</b><br>\n" + "<b>URL:</b> #{url_html}<br>\n" + "<b>Test File:</b> #{assert_data[2]}</br>\n" + "<b>Message:</b> #{assert_data[3]}<br>\n" + "<b>Line Number:</b> #{assert_data[4]}<br>\n" return row_data end |
#FormatAssertionPassed(line) ⇒ Object
FormatAssertionPassed – Method
This method takes an assertion passed line from the raw soda log and
creates a nice happy html row from it.
Params:
line: This is the assertion passed line from the log file.
Results:
returns a hash that is the expected format.
Data: Hash format:
row_data['date']
row_data['msg_type']
row_data['msg']
492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/SodaLogReporter.rb', line 492 def FormatAssertionPassed (line) row_data = Hash.new() line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "AP" msg = "#{$3}" row_data['msg'] = "#{msg}" return row_data end |
#FormatClickingElement(line) ⇒ Object
FormatClickingElement – Method
This method finds the replace string message and reformats it a little.
Input:
line: a soda log file line.
Output:
a row_data hash.
694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
# File 'lib/SodaLogReporter.rb', line 694 def FormatClickingElement(line) row_data = {} tmp = "" line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "#{$2}" tmp = "#{$3}" tmp = SafeHTMLStr("#{tmp}") tmp = tmp.gsub(/\{/, "<b>{") tmp = tmp.gsub(/\}/, "}</b>") row_data['msg'] = "#{tmp}" return row_data end |
#FormatEventDump(line) ⇒ Object
FormatEventDump – Method
This method formats a soda event dump log message.
Params:
line: This is the soda log line.
Results:
returns a hash that is the expected format.
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'lib/SodaLogReporter.rb', line 515 def FormatEventDump(line) ed_id = "ed_div_#{@EventDumpID}" href_id = "href_div_ed_#{@EventDumpID}" @EventDumpID += 1 row_data = Hash.new() line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "#{$2}" msg = "#{$3}" msg =~ /^(.*:)\s+(--.*)/ msg_data = "#{$2}" msg_text = "#{$1}" e_data = msg_data.chop() row_html = "\t<b>#{msg_text}:</b>" + "\t<a id=\"#{href_id}\" href=\"javascript:showdiv('#{ed_id}',"+ " '#{href_id}')\">[ Expand Event Dump ]<b>+</b><br>\n" + "</a><br>\t<div id=\"#{ed_id}\" style=\"display: none\">\n" e_data = msg_data.split("--") e_data.each do |e| row_html << "\t\t#{e}<br>\n" end row_html << "\t<a href=\"javascript:hidediv('#{ed_id}'" + ", '#{href_id}')\">" "[ Collaspe Event Dump ]<b>-</b></a>\t\t</div>\n" row_data['msg'] = row_html return row_data end |
#FormatExceptionBT(line) ⇒ Object
FormatExceptionBT – Method
This method takes a exception bt from the soda log and makes a nicely
formatted html table row with it.
Params:
line: The bt line from the raw soda log file.
Results:
returns a hash that is the expected format.
Data: Hash format:
row_data['date']
row_data['msg_type']
row_data['msg']
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/SodaLogReporter.rb', line 373 def FormatExceptionBT (line) row_data = Hash.new() btid = "bt_div_#{@BackTraceID}" href_id = "href_div_#{@BackTraceID}" @BackTraceID += 1 line =~ /(\w+\s+\w+:)/i row_data['msg_type'] = "bt" row_data['date'] = "" row_html = "\t<b>#{$1}</b>" + "\t<a id=\"#{href_id}\" href=\"javascript:showdiv('#{btid}',"+ " '#{href_id}')\">[ Expand Backtrace ]<b>+</b><br>\n" + "</a><br>\t<div id=\"#{btid}\" style=\"display: none\">\n" line.gsub(/(\w+\s+\w+:)/i, "") e_data = line.split("--") e_data.each do |e| row_html << "\t\t#{e}<br>\n" end row_html << "\t<a href=\"javascript:hidediv('#{btid}', '#{href_id}')\">" + "[ Collaspe Backtrace ]<b>-</b></a>\t\t</div>\n\n" row_data['msg'] = row_html return row_data end |
#FormatHTMLSavedResults(line) ⇒ Object
FormatHTMLSavedResults – Method
This method takes the "HTML Saved" line from the Soda log file and
generates a happy html table row from it.
Params:
line: This is the "HTML Saved" line from the raw soda log file.
Results:
returns a hash that is the expected format.
Data: Hash format:
row_data['date']
row_data['msg_type']
row_data['msg']
341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/SodaLogReporter.rb', line 341 def FormatHTMLSavedResults (line) row_data = Hash.new() line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "#{$2}" sav_msg = "#{$3}" sav_msg =~ /^(html\ssaved:\s+)(.*)/i base_name = File.basename($2) row_data['msg'] = "<b>#{$1}</b>" + "<a href=\"#{base_name}\" target=\"_blank\">#{$2}</a>" return row_data end |
#FormatJSError(line) ⇒ Object
FormatJSError – Method
This method takes a java script soda error line and formats it into
html.
Params:
line: This is the js error line from a soda log.
Results:
returns a hash that is the expected format.
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
# File 'lib/SodaLogReporter.rb', line 561 def FormatJSError(line) row_data = Hash.new() line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "#{$2}" msg = "#{$3}" row_html = "" msg_data = msg.split(/--/) msg_data.each do |d| info = d.split(/::/) if (info.length < 2) row_html << "\t<b>#{info[0]}</b><br>\n" else row_html << "\t<b>#{info[0]}:</b> #{info[1]}<br>\n" end end row_data['msg'] = row_html return row_data end |
#FormatMajorException(line) ⇒ Object
FormatMajorException – Method
This method takes a major exception line from a raw soda log and craetes
a nice happy html row from it.
Params:
line: the line from the soda log.
Results:
returns a hash of formated html
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/SodaLogReporter.rb', line 412 def FormatMajorException(line) row_data = Hash.new() line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "#{$2}" msg = "#{$3}" msg_data = msg.split("--") msg_data[0] = msg_data[0].gsub(/^major\sexception/i, "<b>Major Exception:</b> ") msg_data[1] = msg_data[1].gsub(/^exception\smessage:/i, "<b>Exception Message:</b>") row_data['msg'] = "#{msg_data[0]}</br>#{msg_data[1]}" return row_data end |
#FormatModuleLine(type, line) ⇒ Object
FormatModuleLine – Method
This method takes a module lines and formats it for html.
Params:
line: The raw soda log line.
Results:
returns a hash that is the expected format.
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
# File 'lib/SodaLogReporter.rb', line 595 def FormatModuleLine(type, line) row_data = Hash.new() line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "M" msg = "#{$3}" row_html = "" case type when /module/i msg = msg.gsub(/^module:/i, "<b>Module:</b>") when /test/i msg = msg.gsub(/^test:/i, "<b>Test:</b>") when /lib/i msg = msg.gsub(/^lib:/i, "<b>Lib:</b>") end row_data['msg'] = msg return row_data end |
#FormatReplacingString(line) ⇒ Object
FormatReplacingString – Method
This method finds the replace string message and reformats it a little.
Input:
line: a soda log file line.
Output:
a row_data hash.
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
# File 'lib/SodaLogReporter.rb', line 660 def FormatReplacingString(line) row_data = Hash.new() msg = "" line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "#{$2}" msg = $3 data = msg.split(/'*'/) data.each do |d| next if (d =~ /with/i) || (d =~ /replacing\s+string/i) tmp = d tmp = Regexp.escape(tmp) msg = msg.gsub(/'#{tmp}'/, "<b>'#{d}'</b>") end row_data['msg'] = msg return row_data end |
#FormatScreenShot(line) ⇒ Object
FormatScreenShot – Method
This method converts the screenshot log file line into a nice html
item for the html log.
Input:
line: This is the SODA log file line to format.
Output:
a row_data hash.
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
# File 'lib/SodaLogReporter.rb', line 629 def FormatScreenShot(line) row_data = Hash.new() line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "#{$2}" msg = "#{$3}" row_html = "" data = msg.split(/:\s/) data[1] = File.basename(data[1]) print "(*)#{data[1]}\n" msg = "<b>#{data[0]}:</b> <a href=\"#{data[1]}\">#{data[1]}</a>" row_data['msg'] = msg return row_data end |
#FormatTestResults(line) ⇒ Object
FormatTestResults – Method
This method takes the results log file line and generates a nice and
happy html row.
Prams:
line: This is the "Soda Test Report" line from the log file.
Results:
returns a hash that is the expected format.
Data: Hash format:
row_data['date']
row_data['msg_type']
row_data['msg']
row_data['error']
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/SodaLogReporter.rb', line 241 def FormatTestResults (line) row_data = Hash.new() table_html = "<table>\n" line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "Results" rpt_msg = "#{$3}" res_data = rpt_msg.split("--") res_data.shift() res_data.each do |dline| dline_data = dline.split(":") if ( (dline_data[1].nil?) || (dline_data[1].empty?) ) dline_data[1] = "" end table_html << "<tr class=\"tr_normal\""+ " \"onMouseOver=\"this.className='highlight_report'\" "+ "onMouseOut=\"this.className='tr_normal'\">" + "\n\t<td><b>#{dline_data[0]}:</b></td>\n" case dline_data[0] when /test\s+failure\s+count/i if (dline_data[1].to_i() > 0) table_html << "\t<td><font color=\"#FF0000\">" + "<b>#{dline_data[1]}</b>\n\t</td>\n" else table_html << "\t<td><b>#{dline_data[1]}</b>" + "\n\t</td>\n" end when /assert\s+failures/i if (dline_data[1].to_i() > 0) table_html << "\t<td><font color=\"#FF0000\">" + "<b>#{dline_data[1]}</b>\n\t</td>\n" else table_html << "\t<td><b>#{dline_data[1]}</b>" + "\n\t</td>\n" end when /test\s+major\s+exceptions/i if (dline_data[1].to_i() > 0) table_html << "\t<td><font color=\"#FF0000\">" + "<b>#{dline_data[1]}</b>\n\t</td>\n" else table_html << "\t<td><b>#{dline_data[1]}</b>" + "\n\t</td>\n" end when /test\s+exceptions/i if (dline_data[1].to_i() > 0) table_html << "\t<td><font color=\"#FF0000\">" + "<b>#{dline_data[1]}</b>\n\t</td>\n" else table_html << "\t<td><b>#{dline_data[1]}</b>" + "\n\t</td>\n" end when /test\s+css\s+error\s+count/i if (dline_data[1].to_i() > 0) table_html << "\t<td><font color=\"#FF0000\">" + "<b>#{dline_data[1]}</b>\n\t</td>\n" else table_html << "\t<td><b>#{dline_data[1]}</b>" + "\n\t</td>\n" end when /test\s+javascript\s+error\s+count/i if (dline_data[1].to_i() > 0) table_html << "\t<td><font color=\"#FF0000\">" + "<b>#{dline_data[1]}</b>\n\t</td>\n" else table_html << "\t<td><b>#{dline_data[1]}</b>" + "\n\t</td>\n" end else table_html << "\t<td><b>#{dline_data[1]}</b>" + "\n\t</td>\n" end table_html << "</tr>\n" end table_html << "\n</table>\n" row_data['msg'] = table_html return row_data end |
#GenerateHtmlHeader(title = "Soda Test Report:") ⇒ Object
GenerateHtmlHeader – Method
This function will create the proper html header for the report file that
we generate.
Params:
title: This is to set the HTML <title>#{title}</title>
Results:
returns a string containing HTML code.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/SodaLogReporter.rb', line 82 def GenerateHtmlHeader (title = "Soda Test Report:") header = <<HTML <html> <script language=javascript type='text/javascript'> function hidediv(name, href_id) { document.getElementById(name).style.display = 'none'; document.getElementById(href_id).innerHTML="[ Expand Backtrace ]<b>+</b>"; document.getElementById(href_id).href="javascript:showdiv('" + name + "', '" + href_id + "')"; } function showdiv(name, href_id) { document.getElementById(name).style.display = 'inline'; document.getElementById(href_id).innerHTML="[ Collapse Backtrace ]<b>-</b>"; document.getElementById(href_id).href="javascript:hidediv('" + name + "', '" + href_id + "')"; } </script> <style type="text/css"> body { margin: 0px; font-family: Arial, Verdana, Helvetica, sans-serif; } fieldset, table, pre { margin-bottom:0; } p { margin-top: 0px; margin-bottom: 0px; } textarea { font-family: Arial,Verdana,Helvetica,sans-serif; } td { text-align: left; vertical-align: top; } .td_msgtype { text-align: center; vertical-align: middle; } .tr_normal { background: #e5eef3; } .tr_header { background: #a4a4a4; font-weight: bold; } .tr_module { background: #3c78c8; } .tr_error { background: #ff0000; } .tr_warning { background: #eeff30; } .tr_assert_passed { background: #7ff98a; } .highlight { background-color: #8888FF; } .highlight_report { background-color: #5dec6d; } table { background: #ffff; border: 1px solid black; border-bottom: 1px solid #0000; border-right: 1px solid #0000; color: #0000; padding: 4px; font-size: 11px; } </style> <title>#{title}</title> <body> <table> <tr class="tr_header"> <td nowrap> Date Time: </td> <td nowrap> Message Type: </td> <td> Message: </td> </tr> HTML return header end |
#GenerateReport ⇒ Object
GenerateReport – Method
This function generates an html report file.
Params:
None.
Results:
None.
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
# File 'lib/SodaLogReporter.rb', line 820 def GenerateReport html = GenerateHtmlHeader() rep_file = File.new(@OutPutFile, "w+") rep_file.write(html) log = File.open(@SodaLogFile, "r") log.each do |line| line = line.chomp() if (line.empty?) next end tmp = GenerateTableRow(line) if (!tmp.empty?) rep_file.write(tmp) end end rep_file.write("\n</table>\n</body>\n</html>\n") rep_file.close() log.close() end |
#GenerateTableRow(line) ⇒ Object
GenerateTableRow – Method
This function generates a new html table row from a row log line.
Params:
line: This is a line from a raw soda report file.
Results:
returns a string of html that is a table row.
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 |
# File 'lib/SodaLogReporter.rb', line 720 def GenerateTableRow(line) row_html = "" tr_style = "tr_normal" row_data = Hash.new() case line when /assertion:\s+passed/i row_data = FormatAssertionPassed(line) when /exception\s+backtrace/i row_data = FormatExceptionBT(line) when /assertion:\s+failed/i row_data = FormatAssertionFailed(line) when /soda\s+test\s+report:/i row_data = FormatTestResults(line) when /html\s+saved/i row_data = FormatHTMLSavedResults(line) when /\(E\)/ row_data = FormatEventDump(line) when /major\sexception/i row_data = FormatMajorException(line) when /javascript\s+error:|javascript\s+error\s+\(repeated/i row_data = FormatJSError(line) when /css\s+error:/i row_data = FormatJSError(line) when /\(\*\)module:/i row_data = FormatModuleLine("module", line) when /\(\*\)test:/i row_data = FormatModuleLine("test", line) when /\(\*\)lib:/i row_data = FormatModuleLine("lib", line) when /replacing string/i row_data = FormatReplacingString(line) when /clicking\selement:/i row_data = FormatClickingElement(line) when /setting\selement:/i row_data = FormatClickingElement(line) when /expected element:/i row_data = FormatClickingElement(line) when /element:/i row_data = FormatClickingElement(line) when /screenshot\staken/i row_data = FormatScreenShot(line) else line =~ /\[(\d+\/\d+\/\d+-\d+:\d+:\d+\.\d+)\](\(.\))(.*)/ row_data['date'] = "#{$1}" row_data['msg_type'] = "#{$2}" row_data['msg'] = SafeHTMLStr("#{$3}") end row_data['msg_type'] = row_data['msg_type'].gsub("(", "") row_data['msg_type'] = row_data['msg_type'].gsub(")", "") case row_data['msg_type'].to_s() when "!" row_data['msg_type'] = "Failure" tr_style = "tr_error" when "*" row_data['msg_type'] = "Log" when "W" row_data['msg_type'] = "Warning" tr_style = "tr_warning" when "E" row_data['msg_type'] = "Event Dump" when "bt" row_data['msg_type'] = "BackTrace" when "AP" row_data['msg_type'] = "Assertion Passed" tr_style = "tr_assert_passed" when "M" row_data['msg_type'] = "Un/Load" tr_style = "tr_module" else row_data['msg_type'] = "Log" end if ( (row_data['msg'].empty?) && (row_data['date'].empty?) ) return "" end row_html = "<tr class=\"#{tr_style}\" "+ "onMouseOver=\"this.className='highlight'\" " + "onMouseOut=\"this.className='#{tr_style}'\">\n" + "\t<td>" + row_data['date'] + "</td>\n" + "\t<td class=\"td_msgtype\">" + row_data['msg_type'] + "</td>\n" + "\t<td>" + row_data['msg'] + "</td>\n</tr>\n" return row_html end |
#SafeHTMLStr(str) ⇒ Object
SafeHTMLStr – Method
This method makes a string html safe by peforming proper escapes.
Params:
str: The string to make safe.
Result:
returns a safe html string.
217 218 219 220 221 |
# File 'lib/SodaLogReporter.rb', line 217 def SafeHTMLStr(str) str = str.gsub("<", "<") str = str.gsub(">", ">") return str end |