Sha256: 88dd0199983b3da7bd34ee9ea5c11920664bbc40eed40ec83c314cd80fdc7bbc

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require 'cgi'

module Xcov
  class Target < Xcov::Base

    attr_accessor :name
    attr_accessor :coverage
    attr_accessor :files
    attr_accessor :file_templates

    def initialize (name, coverage, files)
      @name = CGI::escapeHTML(name)
      @coverage = coverage
      @files = files
      @displayable_coverage = self.create_displayable_coverage
      @coverage_color = self.create_coverage_color
      @id = Target.create_id(name)
    end

    def print_description
      puts "\t#{@name} (#{@coverage})"
      @files.each do |file|
        file.print_description
      end
    end

    def html_value
      @file_templates = ""
      @files.each do |file|
        @file_templates << file.html_value
      end

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

    # Class methods

    def self.map (dictionary)
      name = dictionary["name"]
      coverage = dictionary["coverage"]
      files = dictionary["files"].map { |file| Source.map(file)}
      files = files.sort! { |lhs, rhs| lhs.coverage <=> rhs.coverage }

      Target.new(name, coverage, files)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xcov-0.5 lib/xcov/model/target.rb
xcov-0.4 lib/xcov/model/target.rb
xcov-0.3 lib/xcov/model/target.rb
xcov-0.2 lib/xcov/model/target.rb