File: simple_formatter.rb

package info (click to toggle)
ruby-simplecov 0.22.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,512 kB
  • sloc: ruby: 5,550; makefile: 10
file content (25 lines) | stat: -rw-r--r-- 630 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module SimpleCov
  module Formatter
    #
    # A ridiculously simple formatter for SimpleCov results.
    #
    class SimpleFormatter
      # Takes a SimpleCov::Result and generates a string out of it
      def format(result)
        output = +""
        result.groups.each do |name, files|
          output << "Group: #{name}\n"
          output << "=" * 40
          output << "\n"
          files.each do |file|
            output << "#{file.filename} (coverage: #{file.covered_percent.round(2)}%)\n"
          end
          output << "\n"
        end
        output
      end
    end
  end
end