class Mutest::SourceFile

A source file representation

Constants

COMMENT_TEXT

Attributes

comments[R]

Public Class Methods

new(path, ast, comments) click to toggle source
Calls superclass method
# File lib/mutest/source_file.rb, line 16
def initialize(path, ast, comments)
  super(path, ast)

  @comments = comments
end
read(path) click to toggle source

Read and parse file with comments

@return [undefined]

# File lib/mutest/source_file.rb, line 12
def self.read(path)
  new(path, *Unparser.parse_with_comments(path.read))
end

Public Instance Methods

ignore?(node) click to toggle source

TODO: Support multiple lines of comments preceeding a disable TODO: Support inline comment disable

# File lib/mutest/source_file.rb, line 24
def ignore?(node)
  location = node.location
  return false unless location&.expression

  disable_lines.include?(location.line)
end

Private Instance Methods

disable_comments() click to toggle source
# File lib/mutest/source_file.rb, line 42
def disable_comments
  comments.select do |comment|
    comment.text.eql?(COMMENT_TEXT)
  end
end
disable_lines() click to toggle source
# File lib/mutest/source_file.rb, line 35
def disable_lines
  disable_comments.map do |comment|
    comment.location.line + 1
  end
end