Sha256: d0305c7921870d900b1bb5d4ea4b946c1642320073f3b44cd168e39d8ab80dfc
Contents?: true
Size: 1.07 KB
Versions: 10
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require 'coverage' require 'simplecov' class << SimpleCov::LinesClassifier alias_method :orig_whitespace_line?, :whitespace_line? def whitespace_line?(line) line.strip =~ /^(begin|end|ensure|else|\})|(\s*rescue\s.+)$/ || orig_whitespace_line?(line) end end module Coverage EXCLUDE = %w{coverage eg helper run }.map { |n| File.expand_path("test/#{n}.rb") } LIB_FILES = Dir["#{File.join(FileUtils.pwd, 'lib')}/polyphony/**/*.rb"] class << self def relevant_lines_for_filename(filename) @classifier ||= SimpleCov::LinesClassifier.new @classifier.classify(IO.read(filename).lines) end def start @result = {} trace = TracePoint.new(:line) do |tp| next if tp.path =~ /\(/ absolute = File.expand_path(tp.path) next unless LIB_FILES.include?(absolute)# =~ /^#{LIB_DIR}/ @result[absolute] ||= relevant_lines_for_filename(absolute) @result[absolute][tp.lineno - 1] = 1 end trace.enable end def result @result end end end SimpleCov.start
Version data entries
10 entries across 10 versions & 1 rubygems