suiteview 2.2.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 520d19b48b2266640d01fabfc62831c79ced8292ffa9c1ad493f77197bb901c4
4
- data.tar.gz: 43f7c82b7a9a2b7e87000f77e5776bfd2a2217c41b54bce1a6565014e53601db
3
+ metadata.gz: 2df11cb6d8ba4cef750ea24f96ee88ffc3bba1d234d242960b99e2568703e5ac
4
+ data.tar.gz: 70761f9adf5a899321ce60f1f23793b7f5012201d23448ba341c6401c05aae08
5
5
  SHA512:
6
- metadata.gz: 01e2da4c0157741996ce10ba83557c390b87c97184dd42d616d157c3cfb06e622443c412fd0ac9ebb4796cd12a2093b86a93a486e8057e832a5d1e43444b4e7d
7
- data.tar.gz: 90bc95a07718412cd38712818f40f8c154e35fd04c22d763b9b1d9c13ea491f9fa679fb07adddfa38299b94cf90ab040ae288af8c5a527c35babf6009e87fdcf
6
+ metadata.gz: 12b4b09b9e773a6f92a1bfed3171038e00e75c516a39ad1f26283389876f547007ba93ab1a790e664e2cee86e8303ab6d3324fa7681a9189f0919c976531001f
7
+ data.tar.gz: 0302dc38df87ae9b12ecec9923278f91604b928c7eb154aa3b58f5c8cf0549473d7c70f2b94c73d657962b969937ec6706b7acfe2afb333e049e39fc7a23526d
@@ -0,0 +1,58 @@
1
+ require 'csv'
2
+ require 'chartkick'
3
+ require 'launchy'
4
+
5
+ # The SuiteRender::Pie module makes an html Pie chart
6
+ class SuiteRender
7
+ module Pie
8
+ include Chartkick::Helper
9
+ def render_pie_chart_html(filename)
10
+ @filename = filename
11
+ html = pie_chart_html
12
+
13
+ File.open(filename, 'w') do |file|
14
+ file.puts html
15
+ end
16
+ self
17
+ end
18
+
19
+ def launch
20
+ Launchy.open(@filename)
21
+ end
22
+
23
+ end
24
+
25
+ private
26
+
27
+ def pie_chart_html
28
+ csv_string = self.view.output
29
+ data = {}
30
+ CSV.parse(csv_string, headers: true) do |row|
31
+ data[row['tag']] = row['count'].to_i
32
+ end
33
+
34
+ # Group the data by category and calculate the sum of values for each category
35
+ grouped_data = data.group_by { |k, v| k }
36
+ .transform_values { |v| v.map(&:last).reduce(:+) }
37
+
38
+ pie_chart = pie_chart(grouped_data)
39
+
40
+
41
+ # Return the HTML code for the pie chart
42
+ <<~HTML
43
+ <!DOCTYPE html>
44
+ <html>
45
+ <head>
46
+ <title>Pie Chart</title>
47
+ <script src="https://code.highcharts.com/highcharts.js"></script>
48
+ <script src="https://cdn.jsdelivr.net/npm/chartkick@5.0.1"></script>
49
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.css">
50
+ </head>
51
+ <body>
52
+ <div id="pie-chart" style="height: 300px;"></div>
53
+ #{pie_chart}
54
+ </body>
55
+ </html>
56
+ HTML
57
+ end
58
+ end
@@ -0,0 +1,38 @@
1
+ require 'csv'
2
+ require_relative './pie'
3
+
4
+ # SuiteRender is responsible for rendering the output of SuiteView
5
+ class SuiteRender
6
+ include Pie
7
+ attr_accessor :next_step, :view
8
+
9
+ def initialize(suiteview)
10
+ self.next_step = nil
11
+ self.view = suiteview
12
+ end
13
+
14
+ def self.to_csv
15
+ to_csv
16
+ end
17
+
18
+ def to_csv
19
+ self.view.output = CSV.generate do |csv|
20
+ self.view.output.each { |row| csv << row }
21
+ end
22
+ self
23
+ end
24
+
25
+ def render_to_file(filename)
26
+ File.open(filename, "w") do |file|
27
+ file.puts self.view.output
28
+ end
29
+ end
30
+
31
+ def render
32
+ self.view.output
33
+ end
34
+
35
+ def next_step=(step)
36
+ @next_step = step
37
+ end
38
+ end
data/lib/suitestat.rb ADDED
@@ -0,0 +1,10 @@
1
+ # SuiteStat is a DTO for passing info used to create metrics
2
+ class SuiteStat
3
+ attr_accessor :total_count, :output, :tag_counts
4
+
5
+ def initialize(output = nil, total_count = 0, tag_counts = {})
6
+ self.output = output
7
+ self.total_count = total_count
8
+ self.tag_counts = tag_counts
9
+ end
10
+ end
data/lib/suiteview.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  require 'cql'
2
2
  require_relative './suitestat'
3
- require_relative './suiterender'
3
+ require_relative './suiterender/suiterender'
4
+ require_relative './suiterender/pie'
4
5
  # SuiteView is responsible for providing consumable Ruby Cucumber suite stats
5
6
  class SuiteView
7
+ include SuiteRender::Pie
6
8
  attr_accessor :repo, :include_tags, :exclude_tag, :output, :render_step
7
9
 
8
10
  def initialize(opts)
@@ -15,6 +17,7 @@ class SuiteView
15
17
  # Create a SuiteRender object and set it as the last step in the chain
16
18
  self.render_step = SuiteRender.new(self)
17
19
  render_step.next_step = self
20
+ self
18
21
  end
19
22
 
20
23
  def outline_tag_count(tag)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suiteview
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David West
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: chartkick
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.4.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.4.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: launchy
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.4.3
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.4.3
69
97
  description: |
70
98
  suiteview is a tool to help show the contents of a cucumber suite with your unique specifications
71
99
 
@@ -115,6 +143,9 @@ executables: []
115
143
  extensions: []
116
144
  extra_rdoc_files: []
117
145
  files:
146
+ - lib/suiterender/pie.rb
147
+ - lib/suiterender/suiterender.rb
148
+ - lib/suitestat.rb
118
149
  - lib/suiteview.rb
119
150
  homepage: https://github.com/suiteview/suiteview
120
151
  licenses: