Sha256: 829f627d2be824363a55d0c6739d1e3450338312aedd1432b9f6205025b7bb95

Contents?: true

Size: 1.52 KB

Versions: 32

Compression:

Stored size: 1.52 KB

Contents

module Slather
  module CoverageService
    module GutterJsonOutput

      def coverage_file_class
        if input_format == "profdata"
          Slather::ProfdataCoverageFile
        else
          Slather::CoverageFile
        end
      end
      private :coverage_file_class

      def post
        output = { 'meta' => { 'timestamp' => DateTime.now.strftime('%Y-%m-%d %H:%M:%S.%6N') } }
        symbols = {}

        coverage_files.each do |coverage_file|
          next unless coverage_file.raw_data

          filename = coverage_file.source_file_pathname.to_s
          filename = filename.sub(Pathname.pwd.to_s, '').reverse.chomp("/").reverse

          coverage_file.all_lines.each do |line|

            line_number = coverage_file.line_number_in_line(line)
            next unless line_number > 0

            coverage = coverage_file.coverage_for_line(line)
            short_text = coverage != nil ? coverage.to_s : "-"

            symbol = {  'line' => line_number,
                        'long_text' => '',
                        'short_text' => short_text }

            if coverage != nil
              symbol['background_color'] = coverage.to_i > 0 ? '0x35CC4B' : '0xFC635E'
            end

            if symbols.has_key?(filename)
              symbols[filename] << symbol
            else
              symbols[filename] = [ symbol ]
            end
          end
        end

        output['symbols_by_file'] = symbols
        File.open('.gutter.json', 'w') { |file| file.write(output.to_json) }
      end

    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
slather-2.8.5 lib/slather/coverage_service/gutter_json_output.rb
slather-2.8.4 lib/slather/coverage_service/gutter_json_output.rb
slather-2.8.3 lib/slather/coverage_service/gutter_json_output.rb
slather-2.8.2 lib/slather/coverage_service/gutter_json_output.rb
slather-2.8.1 lib/slather/coverage_service/gutter_json_output.rb
slather-2.8.0 lib/slather/coverage_service/gutter_json_output.rb
slather-2.7.5 lib/slather/coverage_service/gutter_json_output.rb
slather-2.7.4 lib/slather/coverage_service/gutter_json_output.rb
slather-2.7.3 lib/slather/coverage_service/gutter_json_output.rb
slather-2.7.2 lib/slather/coverage_service/gutter_json_output.rb
slather-2.7.1 lib/slather/coverage_service/gutter_json_output.rb
slather-2.7.0 lib/slather/coverage_service/gutter_json_output.rb
slather-2.6.1 lib/slather/coverage_service/gutter_json_output.rb
slather-2.6.0 lib/slather/coverage_service/gutter_json_output.rb
slather-2.5.0 lib/slather/coverage_service/gutter_json_output.rb
slather-2.4.9 lib/slather/coverage_service/gutter_json_output.rb
slather-2.4.8 lib/slather/coverage_service/gutter_json_output.rb
slather-2.4.7 lib/slather/coverage_service/gutter_json_output.rb
slather-2.4.6 lib/slather/coverage_service/gutter_json_output.rb
slather-2.4.5 lib/slather/coverage_service/gutter_json_output.rb