Class: SuiteView
- Inherits:
-
Object
- Object
- SuiteView
- Defined in:
- lib/suiteview.rb
Overview
SuiteView is responsible for providing consumable Ruby Cucumber suite stats
Instance Attribute Summary collapse
-
#include_tags ⇒ Object
Returns the value of attribute include_tags.
-
#output ⇒ Object
Returns the value of attribute output.
-
#repo ⇒ Object
Returns the value of attribute repo.
Instance Method Summary collapse
-
#initialize(opts) ⇒ SuiteView
constructor
A new instance of SuiteView.
- #outline_tag_count(tag) ⇒ Object
- #percentages ⇒ Object
- #render ⇒ Object
- #render_to_file(filename) ⇒ Object
- #scenario_tag_count(tag) ⇒ Object
- #to_csv ⇒ Object
- #total_tag_count(tag) ⇒ Object
- #total_tags_count ⇒ Object
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. = opts[:include_tags] || "" self. = self..split(',') end |
Instance Attribute Details
#include_tags ⇒ Object
Returns the value of attribute include_tags.
6 7 8 |
# File 'lib/suiteview.rb', line 6 def @include_tags end |
#output ⇒ Object
Returns the value of attribute output.
6 7 8 |
# File 'lib/suiteview.rb', line 6 def output @output end |
#repo ⇒ Object
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 |
#percentages ⇒ Object
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 |
#render ⇒ Object
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_csv ⇒ Object
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_count ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/suiteview.rb', line 30 def output = [%w(tag count)] self..each do |tag| output << [tag, total_tag_count(tag).render.to_s] end self.output = output self end |