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.
559 560 561 562 563 |
# File 'lib/gergich.rb', line 559 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.
557 558 559 |
# File 'lib/gergich.rb', line 557 def comments @comments end |
#inline ⇒ Object
Returns the value of attribute inline.
557 558 559 |
# File 'lib/gergich.rb', line 557 def inline @inline end |
#min_score ⇒ Object
Returns the value of attribute min_score.
557 558 559 |
# File 'lib/gergich.rb', line 557 def min_score @min_score end |
#path ⇒ Object
Returns the value of attribute path.
557 558 559 |
# File 'lib/gergich.rb', line 557 def path @path end |
Instance Method Details
#add_comment(position, message, severity) ⇒ Object
565 566 567 568 569 |
# File 'lib/gergich.rb', line 565 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
571 572 573 |
# File 'lib/gergich.rb', line 571 def count comments.size end |
#to_a ⇒ Object
575 576 577 578 579 580 581 582 583 584 585 |
# File 'lib/gergich.rb', line 575 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 |