Sha256: 68613a3e6c571557e39f5db34174f2ad4f12dea7ec7df3eadcb63c5d339b47f0

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

module MetricFu
  class MetricRcov < Metric
    def name
      :rcov
    end

    def default_run_options
      {
        environment: "test",
        test_files: Dir["{spec,test}/**/*_{spec,test}.rb"],
        rcov_opts: rcov_opts,
        external: nil,
      }
    end

    def coverage_file=(coverage_file)
      configured_run_options.update(external: coverage_file)
    end

    def has_graph?
      true
    end

    def enable
      if external_coverage_file?
        super
      else
        mf_debug("RCov is not available. See README")
      end
    end

    def activate
      super
    end

    def external_coverage_file?
      if coverage_file = run_options[:external]
        File.exist?(coverage_file) ||
          mf_log("Configured RCov file #{coverage_file.inspect} does not exist")
      else
        false
      end
    end

    private

    def rcov_opts
      rcov_opts = [
        "--sort coverage",
        "--no-html",
        "--text-coverage",
        "--no-color",
        "--profile",
        "--exclude-only '.*'",
        '--include-file "\Aapp,\Alib"'
      ]
      rcov_opts << "-Ispec" if File.exist?("spec")
      rcov_opts
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

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