Sha256: 1c7e970b8fb3c411da5cb16a7d598099b495e6dc9cd8414ebe5a6a024d1e5496

Contents?: true

Size: 1.38 KB

Versions: 129

Compression:

Stored size: 1.38 KB

Contents

module Rcov
  class FullTextReport < BaseFormatter # :nodoc:
    DEFAULT_OPTS = {:textmode => :coverage}

    def initialize(opts = {})
      options = DEFAULT_OPTS.clone.update(opts)
      @textmode = options[:textmode]
      @color = options[:color]
      super(options)
    end

    def execute
      each_file_pair_sorted do |filename, fileinfo|
        puts "=" * 80
        puts filename
        puts "=" * 80
        lines = SCRIPT_LINES__[filename]

        unless lines
          # try to get the source code from the global code coverage
          # analyzer
          re = /#{Regexp.escape(filename)}\z/
          if $rcov_code_coverage_analyzer and
            (data = $rcov_code_coverage_analyzer.data_matching(re))
            lines = data[0]
          end
        end

        (lines || []).each_with_index do |line, i|
          case @textmode
          when :counts
            puts "%-70s| %6d" % [line.chomp[0,70], fileinfo.counts[i]]
          when :gcc
            puts "%s:%d:%s" % [filename, i+1, line.chomp] unless fileinfo.coverage[i]
          when :coverage
            if @color
              prefix = fileinfo.coverage[i] ? "\e[32;40m" : "\e[31;40m"
              puts "#{prefix}%s\e[37;40m" % line.chomp
            else
              prefix = fileinfo.coverage[i] ? "   " : "!! "
              puts "#{prefix}#{line}"
            end
          end
        end
      end
    end
  end
end

Version data entries

129 entries across 61 versions & 9 rubygems

Version Path
gigpark-rcov-0.8.6 lib/rcov/formatters/full_text_report.rb
hooligan495-rcov-0.9.1-java lib/rcov/formatters/full_text_report.rb
relevance-rcov-0.8.6 lib/rcov/formatters/full_text_report.rb
relevance-rcov-0.9.0 lib/rcov/formatters/full_text_report.rb
relevance-rcov-0.9.1.1 lib/rcov/formatters/full_text_report.rb
relevance-rcov-0.9.2.1 lib/rcov/formatters/full_text_report.rb
relevance-rcov-0.9.3-java lib/rcov/formatters/full_text_report.rb
devise_sociable-0.1.0 vendor/bundle/gems/rcov-1.0.0/lib/rcov/formatters/full_text_report.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/rcov-0.9.9/lib/rcov/formatters/full_text_report.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/rcov-0.9.11/lib/rcov/formatters/full_text_report.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/rcov-0.9.11/lib/rcov/formatters/full_text_report.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/rcov-0.9.9/lib/rcov/formatters/full_text_report.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/rcov-0.9.9/lib/rcov/formatters/full_text_report.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/rcov-0.9.11/lib/rcov/formatters/full_text_report.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/rcov-0.9.11/lib/rcov/formatters/full_text_report.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/rcov-0.9.9/lib/rcov/formatters/full_text_report.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/rcov-0.9.11/lib/rcov/formatters/full_text_report.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/rcov-0.9.9/lib/rcov/formatters/full_text_report.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/rcov-0.9.9/lib/rcov/formatters/full_text_report.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/rcov-0.9.11/lib/rcov/formatters/full_text_report.rb