Class: SuiteView

Inherits:
Object
  • Object
show all
Defined in:
lib/suiteview.rb

Overview

SuiteView is responsible for providing consumable Ruby Cucumber suite stats

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ SuiteView

Returns a new instance of SuiteView.



8
9
10
11
12
13
# File 'lib/suiteview.rb', line 8

def initialize(opts)
  self.output = nil
  self.repo = CQL::Repository.new(opts[:repo])
  self.include_tags = opts[:include_tags] || ""
  self.include_tags = self.include_tags.split(',')
end

Instance Attribute Details

#include_tagsObject

Returns the value of attribute include_tags.



6
7
8
# File 'lib/suiteview.rb', line 6

def include_tags
  @include_tags
end

#outputObject

Returns the value of attribute output.



6
7
8
# File 'lib/suiteview.rb', line 6

def output
  @output
end

#repoObject

Returns the value of attribute repo.



6
7
8
# File 'lib/suiteview.rb', line 6

def repo
  @repo
end

Instance Method Details

#outline_tag_count(tag) ⇒ Object



15
16
17
18
# File 'lib/suiteview.rb', line 15

def outline_tag_count(tag)
  self.output = outline_query(tag).map { |item| item['examples'] }.flatten.count
  self
end

#percentagesObject



39
40
41
42
43
# File 'lib/suiteview.rb', line 39

def percentages
  suite_stat_dto = SuiteStat.new([%w(tag percent)], 0, {})
  self.output = calc_percentage(suite_stat_dto)
  self
end

#renderObject



52
53
54
# File 'lib/suiteview.rb', line 52

def render
  self.output
end

#render_to_file(filename) ⇒ Object



56
57
58
59
60
# File 'lib/suiteview.rb', line 56

def render_to_file(filename)
  File.open(filename, "w") do |file|
    file.puts self.output
  end
end

#scenario_tag_count(tag) ⇒ Object



20
21
22
23
# File 'lib/suiteview.rb', line 20

def scenario_tag_count(tag)
  self.output = scenario_query(tag).map { |item| item['name'] }.count
  self
end

#to_csvObject



45
46
47
48
49
50
# File 'lib/suiteview.rb', line 45

def to_csv
  self.output = CSV.generate do |csv|
    self.output.each { |row| csv << row }
  end
  self
end

#total_tag_count(tag) ⇒ Object



25
26
27
28
# File 'lib/suiteview.rb', line 25

def total_tag_count(tag)
  self.output = scenario_tag_count(tag).render + outline_tag_count(tag).render
  self
end

#total_tags_countObject



30
31
32
33
34
35
36
37
# File 'lib/suiteview.rb', line 30

def total_tags_count
  output = [%w(tag count)]
  self.include_tags.each do |tag|
    output << [tag, total_tag_count(tag).render.to_s]
  end
  self.output = output
  self
end