Class: RspecLogFormatter::Analysis::Analyzer
- Inherits:
-
Object
- Object
- RspecLogFormatter::Analysis::Analyzer
- Defined in:
- lib/rspec_log_formatter/analysis/analyzer.rb
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(history_provider, options = {}) ⇒ Analyzer
constructor
A new instance of Analyzer.
Constructor Details
#initialize(history_provider, options = {}) ⇒ Analyzer
Returns a new instance of Analyzer.
6 7 8 9 10 11 |
# File 'lib/rspec_log_formatter/analysis/analyzer.rb', line 6 def initialize(history_provider, ={}) @builds_to_analyze = [:builds_to_analyze] @max_reruns = [:max_reruns] @limit_history = [:limit_history] @history_provider = history_provider end |
Instance Method Details
#analyze ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rspec_log_formatter/analysis/analyzer.rb', line 13 def analyze build_numbers = @history_provider.builds results = @history_provider.results.reject do |res| @builds_to_analyze && !build_numbers.last(@builds_to_analyze).include?(res.build_number.to_i) end scores = [] results.group_by(&:description).each do |description, results| score = Score.new(description, max_reruns: @max_reruns) results.group_by(&:build_number).each do |build_number, results| next if results.all?(&:failure?) #not flaky results.each{|r| score.absorb(r) } score.runs += results.count score.failures += results.count(&:failure?) score. += results.select(&:failure?).map { |r| "#{r.klass}\n #{r.}" } end scores << score if score.runs > 0 end scores.select(&:flaky?).sort.map(&:as_hash) end |