relevance-rcovを触る

relevance-rcovを触っている。

sample.rb

class Sample
  def foo
    1
  end
end

sample_cov.rb

require 'rcov'
require 'sample'

analyzer = Rcov::CodeCoverageAnalyzer.new
analyzer.run_hooked do
  sample = Sample.new
  sample.foo
end

lines, marked_info, count_info = analyzer.data("path/to/sample.rb")

stat = Rcov::FileStatistics.new("path/to/sample.rb", lines, count_info)

p stat.code_coverage
$ ruby sample_cov.rb
0.6

ヒィ
1.0じゃねぇのかYo