123456789_123456789_123456789_123456789_123456789_

Class: SimpleCov::ResultAdapter

Relationships & Source Files
Inherits: Object
Defined in: lib/simplecov/result_adapter.rb

Overview

Responsible for adapting the format of the coverage result whether it’s default or with statistics

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(result) ⇒ ResultAdapter

[ GitHub ]

  
# File 'lib/simplecov/result_adapter.rb', line 10

def initialize(result)
  @result = result
end

Class Method Details

.call(*args)

[ GitHub ]

  
# File 'lib/simplecov/result_adapter.rb', line 14

def self.call(*args)
  new(*args).adapt
end

Instance Attribute Details

#result (readonly)

[ GitHub ]

  
# File 'lib/simplecov/result_adapter.rb', line 8

attr_reader :result

Instance Method Details

#adapt

[ GitHub ]

  
# File 'lib/simplecov/result_adapter.rb', line 18

def adapt
  return unless result

  result.each_with_object({}) do |(file_name, cover_statistic), adapted_result|
    if cover_statistic.is_a?(Array)
      adapted_result.merge!(file_name => {"lines" => cover_statistic})
    else
      adapted_result.merge!(file_name => cover_statistic)
    end
  end
end