Sha256: 9344b99a5c5b5f1b64f110436a4844300cf460db2156f78cf7a17b74c5da9c70

Contents?: true

Size: 841 Bytes

Versions: 4

Compression:

Stored size: 841 Bytes

Contents

module DeepTest
  module Metrics
    class Data
      def initialize
        @measurements_by_category = {}
      end

      def add(measurement)
        categories = @measurements_by_category[measurement.category] ||= []
        categories << measurement
      end

      def summary
        summary = []
        summary << "Metrics Data\n"
        summary << "------------\n"

        @measurements_by_category.keys.sort.map do |category|
          measurements = @measurements_by_category[category]
          units = measurements.first.units
          summary << "#{category}: #{Measurement.average(measurements)} avg / #{Measurement.total(measurements)} total #{units}\n"
        end

        summary.join
      end

      def save(file)
        File.open(file, "w") do |f|
          f << summary
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
deep_test_pre-2.0 lib/deep_test/metrics/data.rb
jstorimer-deep-test-2.0.0 lib/deep_test/metrics/data.rb
jstorimer-deep-test-0.2.0 lib/deep_test/metrics/data.rb
jstorimer-deep-test-0.1.0 lib/deep_test/metrics/data.rb