Class: Cukeregator::Aggregator
- Inherits:
-
Object
- Object
- Cukeregator::Aggregator
- Includes:
- Status
- Defined in:
- lib/cukeregator/aggregator.rb
Instance Attribute Summary collapse
-
#docs ⇒ Object
readonly
Returns the value of attribute docs.
Instance Method Summary collapse
- #duration ⇒ Object
- #duration_inner_html ⇒ Object
- #duration_string ⇒ Object
-
#initialize(files) ⇒ Aggregator
constructor
A new instance of Aggregator.
- #scenario_totals ⇒ Object
- #step_totals ⇒ Object
- #total_scenarios ⇒ Object
- #total_steps ⇒ Object
- #totals_inner_html ⇒ Object
Methods included from Status
Constructor Details
#initialize(files) ⇒ Aggregator
Returns a new instance of Aggregator.
32 33 34 35 36 |
# File 'lib/cukeregator/aggregator.rb', line 32 def initialize(files) @docs = files.map do |f| HtmlReader.new(File.read(f), f) end end |
Instance Attribute Details
#docs ⇒ Object (readonly)
Returns the value of attribute docs.
30 31 32 |
# File 'lib/cukeregator/aggregator.rb', line 30 def docs @docs end |
Instance Method Details
#duration ⇒ Object
61 62 63 64 65 66 |
# File 'lib/cukeregator/aggregator.rb', line 61 def duration @duration ||= @docs.inject(0) do |result, doc| result += doc.duration result end end |
#duration_inner_html ⇒ Object
50 51 52 |
# File 'lib/cukeregator/aggregator.rb', line 50 def duration_inner_html SummaryFormatter.duration_inner_html(duration_string) end |
#duration_string ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/cukeregator/aggregator.rb', line 68 def duration_string hours = (duration / 3600).to_i min_sec = duration % 3600 minutes = (min_sec / 60).to_i seconds = min_sec % 60 s = "" s += "#{hours}h" if hours > 0 s += "#{minutes}m" s += "#{seconds.to_s[0..5]}s" s end |
#scenario_totals ⇒ Object
38 39 40 |
# File 'lib/cukeregator/aggregator.rb', line 38 def scenario_totals @scenario_totals ||= sum_hash(:scenario_totals) end |
#step_totals ⇒ Object
57 58 59 |
# File 'lib/cukeregator/aggregator.rb', line 57 def step_totals @step_totals ||= sum_hash(:step_totals) end |
#total_scenarios ⇒ Object
42 43 44 |
# File 'lib/cukeregator/aggregator.rb', line 42 def total_scenarios @total_scenarios ||= sum(:total_scenarios) end |
#total_steps ⇒ Object
53 54 55 |
# File 'lib/cukeregator/aggregator.rb', line 53 def total_steps @total_steps ||= sum(:total_steps) end |
#totals_inner_html ⇒ Object
46 47 48 |
# File 'lib/cukeregator/aggregator.rb', line 46 def totals_inner_html SummaryFormatter.totals_inner_html {|method| self.send(method) } end |