Sha256: e67e0aaf88d35a0069b2966862c8a1fa52b1db8f3802cda4e40a3ab63f8a3257

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 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

8 entries across 8 versions & 1 rubygems

Version Path
metric_fu-4.11.3 lib/metric_fu/metrics/rcov/metric.rb
metric_fu-4.11.2 lib/metric_fu/metrics/rcov/metric.rb
metric_fu-4.11.1 lib/metric_fu/metrics/rcov/metric.rb
metric_fu-4.11.0 lib/metric_fu/metrics/rcov/metric.rb
metric_fu-4.10.0 lib/metric_fu/metrics/rcov/init.rb
metric_fu-4.9.0 lib/metric_fu/metrics/rcov/init.rb
metric_fu-4.8.0 lib/metric_fu/metrics/rcov/init.rb
metric_fu-4.7.4 lib/metric_fu/metrics/rcov/init.rb