class SimpleCov::Sublime::SourceFileWrapper
Representation of a source file including it's coverage data, source code, source lines and featuring helpers to interpret that data.
@author Mikael Henriksson <mikael@mhenrixon.com>
Attributes
source_file[R]
Public Class Methods
new(source_file)
click to toggle source
Wrap the SimpleCov::SourceFile to enable hash conversion without monkey patching
@param [SimpleCov::SourceFile] source_file
the source file to generate hash for
# File lib/simple_cov/sublime/source_file_wrapper.rb, line 17 def initialize(source_file) @source_file = source_file end
Public Instance Methods
to_h()
click to toggle source
Returns a nicely formatted hash from the source file data
@return [Hash]
# File lib/simple_cov/sublime/source_file_wrapper.rb, line 27 def to_h { filename: filename, covered_percent: covered_percent, coverage: coverage_data, covered_strength: covered_strength, covered_lines: covered_lines_count, lines_of_code: lines_of_code } end
Private Instance Methods
coverage()
click to toggle source
# File lib/simple_cov/sublime/source_file_wrapper.rb, line 47 def coverage @coverage ||= if SimpleCov::SourceFile.instance_methods.include?(:coverage_data) source_file.coverage_data else source_file.coverage end end
coverage_data()
click to toggle source
@private
# File lib/simple_cov/sublime/source_file_wrapper.rb, line 41 def coverage_data return coverage if coverage.is_a?(Array) coverage.transform_keys(&:to_sym)[:lines] end
covered_lines()
click to toggle source
@private
# File lib/simple_cov/sublime/source_file_wrapper.rb, line 57 def covered_lines source_file.covered_lines end
covered_lines_count()
click to toggle source
@private
# File lib/simple_cov/sublime/source_file_wrapper.rb, line 62 def covered_lines_count covered_lines.count end
covered_percent()
click to toggle source
@private
# File lib/simple_cov/sublime/source_file_wrapper.rb, line 67 def covered_percent source_file.covered_percent end
covered_strength()
click to toggle source
@private
# File lib/simple_cov/sublime/source_file_wrapper.rb, line 72 def covered_strength return 0.0 unless (coverage = source_file.covered_strength) coverage.nan? ? 0.0 : coverage end
filename()
click to toggle source
@private
# File lib/simple_cov/sublime/source_file_wrapper.rb, line 79 def filename source_file.filename end
lines_of_code()
click to toggle source
@private
# File lib/simple_cov/sublime/source_file_wrapper.rb, line 84 def lines_of_code source_file.lines_of_code end