Class: Gergich::FileReview
- Inherits:
-
Object
- Object
- Gergich::FileReview
- Defined in:
- lib/gergich.rb
Instance Attribute Summary collapse
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#inline ⇒ Object
Returns the value of attribute inline.
-
#min_score ⇒ Object
Returns the value of attribute min_score.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #add_comment(position, message, severity) ⇒ Object
- #count ⇒ Object
-
#initialize(path, inline) ⇒ FileReview
constructor
A new instance of FileReview.
- #to_a ⇒ Object
Constructor Details
#initialize(path, inline) ⇒ FileReview
Returns a new instance of FileReview.
570 571 572 573 574 |
# 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 |
Instance Attribute Details
#comments ⇒ Object
Returns the value of attribute comments.
568 569 570 |
# File 'lib/gergich.rb', line 568 def comments @comments end |
#inline ⇒ Object
Returns the value of attribute inline.
568 569 570 |
# File 'lib/gergich.rb', line 568 def inline @inline end |
#min_score ⇒ Object
Returns the value of attribute min_score.
568 569 570 |
# File 'lib/gergich.rb', line 568 def min_score @min_score end |
#path ⇒ Object
Returns the value of attribute path.
568 569 570 |
# File 'lib/gergich.rb', line 568 def path @path end |
Instance Method Details
#add_comment(position, message, severity) ⇒ Object
576 577 578 579 580 |
# File 'lib/gergich.rb', line 576 def add_comment(position, , severity) position = position.to_i if position =~ /\A\d+\z/ comments[position] << "[#{severity.upcase}] #{}" self.min_score = [min_score || 0, Draft::SEVERITY_MAP[severity]].min end |
#count ⇒ Object
582 583 584 |
# File 'lib/gergich.rb', line 582 def count comments.size end |
#to_a ⇒ Object
586 587 588 589 590 591 592 593 594 595 596 |
# 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 |