class SimpleCov::Sublime::ResultToHash
Massage result into a hash that can be dumped to json by OJ
@author Mikael Henriksson <mikael@mhenrixon.se>
Attributes
data[R]
result[R]
Public Class Methods
new(result)
click to toggle source
Initialize a new ResultToHash
@param [SimpleCov::Result] result the final result from simplecov
# File lib/simple_cov/sublime/result_to_hash.rb, line 16 def initialize(result) @result = result @data = { timestamp: result.created_at.to_i, command_name: result.command_name, files: [] } end
Public Instance Methods
to_h()
click to toggle source
Create a hash from the result that can be used for JSON dumping
@return [Hash]
# File lib/simple_cov/sublime/result_to_hash.rb, line 31 def to_h extract_files extract_metrics data end
Private Instance Methods
extract_files()
click to toggle source
@private
# File lib/simple_cov/sublime/result_to_hash.rb, line 42 def extract_files data[:files] = source_file_collection end
extract_metrics()
click to toggle source
@private
# File lib/simple_cov/sublime/result_to_hash.rb, line 56 def extract_metrics data[:metrics] = ResultWrapper.new(result).to_h end
source_file_collection()
click to toggle source
@private
# File lib/simple_cov/sublime/result_to_hash.rb, line 47 def source_file_collection result.files.each_with_object([]) do |source_file, memo| next unless result.filenames.include?(source_file.filename) memo << SourceFileWrapper.new(source_file).to_h end end