Sha256: 317b031414cfe0898727f0252ca9759cb7bfc6dd7dc58ec607536812130c1bd0

Contents?: true

Size: 936 Bytes

Versions: 4

Compression:

Stored size: 936 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

4 entries across 4 versions & 1 rubygems

Version Path
fitting-2.0.3 lib/fitting/statistics.rb
fitting-2.0.2 lib/fitting/statistics.rb
fitting-2.0.1 lib/fitting/statistics.rb
fitting-2.0.0 lib/fitting/statistics.rb