Sha256: b886af7b8b9a130544d41bc1da7908540a8f9148253a9bcf746142d04c93ee88

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

module Xcov
  class Report < Xcov::Base

    attr_accessor :coverage
    attr_accessor :targets
    attr_accessor :summary
    attr_accessor :target_templates

    def initialize (targets)
      @targets = targets
      @coverage = average_coverage(targets)
      @displayable_coverage = self.create_displayable_coverage
      @coverage_color = self.create_coverage_color
      @summary = self.create_summary
    end

    def average_coverage targets
      coverage = 0
      targets.each do |target|
        coverage = coverage + target.coverage
      end
      coverage / targets.count
    end

    def print_description
      puts "Total coverage: (#{@coverage})"
      @targets.each do |target|
        target.print_description
      end
    end

    def html_value
      @target_templates = ""
      @targets.each do |target|
        @target_templates << target.html_value
      end

      Function.template("report").result(binding)
    end

    # Class methods

    def self.map dictionary
      targets = dictionary["targets"]
        .select { |target| !target["name"].include?(".xctest") }
        .map { |target| Target.map(target)}

      Report.new(targets)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xcov-0.3 lib/xcov/model/report.rb
xcov-0.2 lib/xcov/model/report.rb
xcov-0.1 lib/xcov/model/report.rb