Class: SuiteView
- Inherits:
-
Object
- Object
- SuiteView
- Defined in:
- lib/suiteview.rb
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.
5 6 7 8 9 |
# File 'lib/suiteview.rb', line 5 def initialize(opts) self.output = nil self.repo = CQL::Repository.new(opts[:repo]) self. = opts[:include_tags] end |
Instance Attribute Details
#include_tags ⇒ Object
Returns the value of attribute include_tags.
4 5 6 |
# File 'lib/suiteview.rb', line 4 def end |
#output ⇒ Object
Returns the value of attribute output.
4 5 6 |
# File 'lib/suiteview.rb', line 4 def output @output end |
#repo ⇒ Object
Returns the value of attribute repo.
4 5 6 |
# File 'lib/suiteview.rb', line 4 def repo @repo end |
Instance Method Details
#outline_tag_count(tag) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/suiteview.rb', line 11 def outline_tag_count(tag) self.output = self.repo.query do select examples transform examples => lambda {|examples| examples[0].rows.drop(1) } from outlines with { |outline| outline..map(&:name).include?(tag)} end.map {|item| item['examples']}.flatten.count self end |
#percentages ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/suiteview.rb', line 44 def percentages output = [%w(tag percent)] total_count = 0 tag_counts = {} self..split(',').each do |include_tag| total_count += total_tag_count(include_tag).render tag_counts[include_tag] = total_tag_count(include_tag).render end self..split(',').each do |include_tag| output << [include_tag, ((tag_counts[include_tag]/total_count.to_f)*100).to_s] end self.output = output self end |
#render ⇒ Object
68 69 70 |
# File 'lib/suiteview.rb', line 68 def render self.output end |
#render_to_file(filename) ⇒ Object
72 73 74 75 76 |
# File 'lib/suiteview.rb', line 72 def render_to_file(filename) File.open(filename, "w") do |f| f.puts self.output end end |
#scenario_tag_count(tag) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/suiteview.rb', line 21 def scenario_tag_count(tag) self.output = self.repo.query do select name from scenarios with { |scenario| scenario..map(&:name).include?(tag)} end.map {|item| item['name']}.count self end |
#to_csv ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/suiteview.rb', line 59 def to_csv self.output = CSV.generate do |csv| self.output.each do |row| csv << row end end self end |
#total_tag_count(tag) ⇒ Object
30 31 32 33 |
# File 'lib/suiteview.rb', line 30 def total_tag_count(tag) self.output = scenario_tag_count(tag).render + outline_tag_count(tag).render self end |
#total_tags_count ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/suiteview.rb', line 35 def output = [%w(tag count)] self..split(',').each do |tag| output << [tag, total_tag_count(tag).render.to_s] end self.output = output self end |