Sha256: 36225f1359641eacbf2bc6eaa904ca5a9a9ce9c761dbe22144f3cf18c775d4ed

Contents?: true

Size: 935 Bytes

Versions: 5

Compression:

Stored size: 935 Bytes

Contents

require 'fitting/route'
require 'fileutils'

module Fitting
  class Statistics
    def initialize(documentation, all_responses, strict)
      @documentation = documentation
      @black_route = Fitting::Route.new(all_responses, @documentation.black, strict)
      @white_route = Fitting::Route.new(all_responses, @documentation.white, strict)
    end

    def save
      FileUtils.mkdir_p 'fitting'
      File.open('fitting/stats', 'w') { |file| file.write(to_s) }
      File.open('fitting/not_covered', 'w') { |file| file.write(@white_route.errors) }
    end

    def to_s
      if @documentation.black.any?
        [
          ['[Black list]', @black_route.statistics_with_conformity_lists].join("\n"),
          ['[White list]', @white_route.statistics_with_conformity_lists].join("\n"),
          ''
        ].join("\n\n")
      else
        [@white_route.statistics_with_conformity_lists, "\n\n"].join
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fitting-2.2.0 lib/fitting/statistics.rb
fitting-2.1.3 lib/fitting/statistics.rb
fitting-2.1.2 lib/fitting/statistics.rb
fitting-2.1.1 lib/fitting/statistics.rb
fitting-2.1.0 lib/fitting/statistics.rb