class SimpleCovLinterFormatter::FileLine

Attributes

file_name[R]

Public Class Methods

new(line) click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 5
def initialize(line)
  @line = line
  assign_attributes
end

Public Instance Methods

column() click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 22
def column
  @column.to_i
end
file_int_percentage() click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 38
def file_int_percentage
  @file_int_percentage ||= percentage.to_i
end
file_short_name() click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 34
def file_short_name
  @file_short_name ||= file_name.gsub(project_path, "")
end
line_number() click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 14
def line_number
  @line_number.to_i
end
line_number_idx() click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 18
def line_number_idx
  line_number - 1
end
lines_count() click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 26
def lines_count
  @lines_count.to_i
end
percentage() click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 30
def percentage
  @percentage.to_f
end
status() click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 10
def status
  @status.to_sym
end

Private Instance Methods

assign_attributes() click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 54
def assign_attributes
  @file_name, @line_number, @column, status_lines_count = @line.split(
    SimpleCovLinterFormatter::LINE_SECTIONS_DIVIDER
  )
  @status, @lines_count, @percentage = status_lines_count.split(
    SimpleCovLinterFormatter::MSG_DIVIDER
  )
end
project_path() click to toggle source
# File lib/simplecov_linter_formatter/file_line.rb, line 44
def project_path
  root_path = ""
  return root_path unless Object.const_defined?('Rails')
  return root_path unless Rails.respond_to?(:root)

  Rails.root.to_s
rescue NameError
  ""
end