EnhanceXCpretty 0.0.21

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/EnhanceXCpretty +104 -0
  3. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d2104167a6d4ba10ed5d706842891acd9b879f44
4
+ data.tar.gz: 0c942e202ed094f3f2f99255af03c8c7b3e6be4e
5
+ SHA512:
6
+ metadata.gz: 833933e70f5be04137182f4003b77080f30e6d06ef9c191d36d37873e6770c6609edda555ee21639426f55ad7006a52de69724540992684a14efb60f50046e8d
7
+ data.tar.gz: aeab9e997aa6dd250ce3a75a433dfb3abd0db61fce66b1b8917cb7724bc87a2fc0c63d9a518fcf09084c2c2079fd37a16db982c24a8081ea30763d4dd0a4c679
@@ -0,0 +1,104 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require "rexml/document"
4
+
5
+ @total_count = 0
6
+ @pass_count = 0
7
+ @fail_count = 0
8
+
9
+ def calculateTestCaseCount(filename)
10
+ file = File.new(filename)
11
+ repair_malformed_html(filename)
12
+ begin
13
+ doc = REXML::Document.new(file)
14
+ rescue REXML::ParseException => e
15
+ puts "ERROR OCCURED!!!!!!!!!!!!!!!!!!!!!"
16
+ end
17
+ testCaseNames = []
18
+ titleArray = REXML::XPath.match(doc , '//h3[@class=\'title\']')
19
+ for title in titleArray do
20
+ value = title.text
21
+ if !(value.include? "BlibliMobile")
22
+ if !(testCaseNames.include? value)
23
+ testCaseNames.push(value)
24
+ @total_count = @total_count + 1
25
+ end
26
+ end
27
+ end
28
+ passArray = REXML::XPath.match(doc , '//h3[@class=\'time\']')
29
+ @pass_count = passArray.count
30
+ @fail_count = @total_count - @pass_count
31
+ showUpdatedTestCount(filename)
32
+ addPieChart(filename)
33
+ end
34
+
35
+ def repair_malformed_html(filename)
36
+ html_file_contents = File.read(filename)
37
+ File.open(filename, 'w') do |file|
38
+ html_file_contents.each_line do |line|
39
+ if %r{</head>}.match(line)
40
+ if !(line.include? "meta")
41
+ line = "</meta></meta>" + line
42
+ end
43
+ end
44
+ file.puts line
45
+ end
46
+ end
47
+ end
48
+
49
+ def updateContentToFile(filename , searchString , newString)
50
+ html_file_contents = File.read(filename)
51
+ File.open(filename, 'w') do |file|
52
+ html_file_contents.each_line do |line|
53
+ if line.include? searchString
54
+ line = newString
55
+ end
56
+ file.puts line
57
+ end
58
+ end
59
+ end
60
+
61
+ def showUpdatedTestCount(filename)
62
+ updateContentToFile(filename , "</span> tests</h2>" , "<span class=\"number\">"+@total_count.to_s+"</span> tests</h2>")
63
+ updateContentToFile(filename , "</span> failures</h2>" , "<span class=\"number\">"+@fail_count.to_s+"</span> failures</h2>")
64
+ end
65
+
66
+ def addPieChart(filename)
67
+ pieChart = "<section class=\"piechart\">
68
+ <div id=\"piechart\" align=\"middle\" style=\"vertical-align: top;\"></div>
69
+ <script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>
70
+
71
+ <script type=\"text/javascript\">
72
+ // Load google charts
73
+ google.charts.load('current', {'packages':['corechart']});
74
+ google.charts.setOnLoadCallback(drawChart);
75
+
76
+ // Draw the chart and set the chart values
77
+ function drawChart() {
78
+ var data = google.visualization.arrayToDataTable([
79
+ ['Result', 'Count'],
80
+ ['Pass', $PASS_COUNT],
81
+ ['Fail', $FAIL_COUNT]
82
+ ]);
83
+
84
+ // Optional; add a title and set the width and height of the chart
85
+ var options = {'title':'Test Results', 'width':450, 'height':300 };
86
+
87
+ // Display the chart inside the div element with id=\"piechart\"
88
+ var chart = new google.visualization.PieChart(document.getElementById('piechart'));
89
+ chart.draw(data, options);
90
+ }
91
+ </script>
92
+ </section>"
93
+
94
+ pieChart["$PASS_COUNT"] = @pass_count.to_s
95
+ pieChart["$FAIL_COUNT"] = @fail_count.to_s
96
+
97
+ updateContentToFile(filename , "</style>" , ".piechart {float: left; margin-left: 500px; margin-top: 68px; margin-right: 120px;}" + "rect {fill-opacity: 0.0 ;} \n </style> ")
98
+ updateContentToFile(filename , "<section id=\"test-suites\">" , pieChart + "\n<section id=\"test-suites\">\n")
99
+ end
100
+
101
+ # if __FILE__ = $0
102
+ filename = ARGV[0]
103
+ calculateTestCaseCount(filename)
104
+ # end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: EnhanceXCpretty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.21
5
+ platform: ruby
6
+ authors:
7
+ - Hitesh Jain
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2010-09-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Simple gem to enhance xcpretty report
14
+ email: jainhitesh3@gmail.com
15
+ executables:
16
+ - EnhanceXCpretty
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/EnhanceXCpretty
21
+ homepage: https://github.com/jainhitesh3/EnhanceXCpretty
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.5.2.3
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Enhances the existing xcpretty report by adding pie chart to it. Also corrects
45
+ the test count if it is not correct
46
+ test_files: []