suiteview 2.1.41 → 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: d9147697462708141f5c1dc6714487b05a20f9365470b38d9ecc467ed57088c9
4
- data.tar.gz: a63fa95ad432ed7e3c7b2b8e7fe9d87da08d7629a737323b915850d50a8f45fa
3
+ metadata.gz: 2df11cb6d8ba4cef750ea24f96ee88ffc3bba1d234d242960b99e2568703e5ac
4
+ data.tar.gz: 70761f9adf5a899321ce60f1f23793b7f5012201d23448ba341c6401c05aae08
5
5
  SHA512:
6
- metadata.gz: 93c0b7efecf86f3454741879825c8d05b25ff2fa65dff08ececcf6d3d0ff7ad49203030efb64421962f586408b5fa4d58d7742e66e08293d48a3cbe41127890b
7
- data.tar.gz: aeaf77255c85d7bf60c78261bfd691e60942dfcdbda23405e792025f88c3730ddb03b328b0e74a748d315bcc6594bf2423be323b432919576b76988d4d65c233
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,19 +1,23 @@
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
6
- attr_accessor :repo, :include_tags, :output, :render_step
7
+ include SuiteRender::Pie
8
+ attr_accessor :repo, :include_tags, :exclude_tag, :output, :render_step
7
9
 
8
10
  def initialize(opts)
9
11
  self.output = nil
10
12
  self.repo = CQL::Repository.new(opts[:repo])
11
13
  self.include_tags = opts[:include_tags] || ""
12
14
  self.include_tags = self.include_tags.split(',')
15
+ self.exclude_tag = opts[:exclude_tag]
13
16
 
14
17
  # Create a SuiteRender object and set it as the last step in the chain
15
18
  self.render_step = SuiteRender.new(self)
16
19
  render_step.next_step = self
20
+ self
17
21
  end
18
22
 
19
23
  def outline_tag_count(tag)
@@ -84,19 +88,23 @@ class SuiteView
84
88
  end
85
89
 
86
90
  def outline_query(tag)
91
+ exclude_tag = self.exclude_tag
87
92
  self.repo.query do
88
93
  select examples
89
94
  transform examples => lambda { |examples| examples[0].rows.drop(1) }
90
95
  from outlines
91
96
  with { |outline| outline.tags.map(&:name).include?(tag) }
97
+ without { |outline| outline.tags.map(&:name).include?(exclude_tag) }
92
98
  end
93
99
  end
94
100
 
95
101
  def scenario_query(tag)
102
+ exclude_tag = self.exclude_tag
96
103
  self.repo.query do
97
104
  select name
98
105
  from scenarios
99
106
  with { |scenario| scenario.tags.map(&:name).include?(tag) }
107
+ without { |scenario| scenario.tags.map(&:name).include?(exclude_tag) }
100
108
  end
101
109
  end
102
110
  end
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.1.41
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: