Sha256: 7858931002f0d32e1ec220b57437200785034e2aca1657d5825760054eddba8f

Contents?: true

Size: 792 Bytes

Versions: 8

Compression:

Stored size: 792 Bytes

Contents

module MetricFu
  class RCovLine
    attr_accessor :content, :was_run

    def initialize(content, was_run)
      @content = content
      @was_run = was_run
    end

    def to_h
      { content: @content, was_run: @was_run }
    end

    def covered?
      @was_run == 1
    end

    def missed?
      @was_run == 0
    end

    def ignored?
      @was_run.nil?
    end

    def self.line_coverage(lines)
      lines.map { |line| line[:was_run] }
    end

    def self.covered_lines(line_coverage)
      line_coverage.count(1)
    end

    def self.missed_lines(line_coverage)
      line_coverage.count(0)
    end

    def self.ignored_lines(line_coverage)
      line_coverage.count(nil)
    end

    def css_class
      return "rcov_not_run" if missed?

      "rcov_run"
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
metric_fu-4.13.0 lib/metric_fu/metrics/rcov/rcov_line.rb
fastruby-metric_fu-5.0.0 lib/metric_fu/metrics/rcov/rcov_line.rb
code_metric_fu-4.14.4 lib/metric_fu/metrics/rcov/rcov_line.rb
code_metric_fu-4.14.3 lib/metric_fu/metrics/rcov/rcov_line.rb
code_metric_fu-4.14.2 lib/metric_fu/metrics/rcov/rcov_line.rb
code_metric_fu-4.14.1 lib/metric_fu/metrics/rcov/rcov_line.rb
code_metric_fu-4.14.0 lib/metric_fu/metrics/rcov/rcov_line.rb
metric_fu-4.12.0 lib/metric_fu/metrics/rcov/rcov_line.rb