class Gergich::FileReview

Attributes

comments[RW]
inline[RW]
min_score[RW]
path[RW]

Public Class Methods

new(path, inline) click to toggle source
# File lib/gergich.rb, line 570
def initialize(path, inline)
  self.path = path
  self.comments = Hash.new { |hash, position| hash[position] = [] }
  self.inline = inline
end

Public Instance Methods

add_comment(position, message, severity) click to toggle source
# File lib/gergich.rb, line 576
def add_comment(position, message, severity)
  position = position.to_i if position =~ /\A\d+\z/
  comments[position] << "[#{severity.upcase}] #{message}"
  self.min_score = [min_score || 0, Draft::SEVERITY_MAP[severity]].min
end
count() click to toggle source
# File lib/gergich.rb, line 582
def count
  comments.size
end
to_a() click to toggle source
# File lib/gergich.rb, line 586
def to_a
  comments.map do |position, position_comments|
    comment = position_comments.join("\n\n")
    position_key = position.is_a?(Integer) ? :line : :range
    position = JSON.parse(position) unless position.is_a?(Integer)
    {
      :message => comment,
      position_key => position
    }
  end
end