Class: Danger::Comment
- Inherits:
-
Object
- Object
- Danger::Comment
- Defined in:
- lib/danger/helpers/comment.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #generated_by_danger?(danger_id) ⇒ Boolean
-
#initialize(id, body, inline = nil) ⇒ Comment
constructor
A new instance of Comment.
- #inline? ⇒ Boolean
Constructor Details
#initialize(id, body, inline = nil) ⇒ Comment
Returns a new instance of Comment.
5 6 7 8 9 |
# File 'lib/danger/helpers/comment.rb', line 5 def initialize(id, body, inline = nil) @id = id @body = body @inline = inline end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/danger/helpers/comment.rb', line 3 def body @body end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/danger/helpers/comment.rb', line 3 def id @id end |
Class Method Details
.from_github(comment) ⇒ Object
11 12 13 |
# File 'lib/danger/helpers/comment.rb', line 11 def self.from_github(comment) self.new(comment["id"], comment["body"]) end |
.from_gitlab(comment) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/danger/helpers/comment.rb', line 15 def self.from_gitlab(comment) if comment.respond_to?(:id) && comment.respond_to?(:body) type = comment.respond_to?(:type) ? comment.type : nil self.new(comment.id, comment.body, type == "DiffNote") else self.new(comment["id"], comment["body"], comment["type"] == "DiffNote") end end |
Instance Method Details
#generated_by_danger?(danger_id) ⇒ Boolean
24 25 26 |
# File 'lib/danger/helpers/comment.rb', line 24 def generated_by_danger?(danger_id) body.include?("\"generated_by_#{danger_id}\"") end |
#inline? ⇒ Boolean
28 29 30 |
# File 'lib/danger/helpers/comment.rb', line 28 def inline? @inline.nil? ? body.include?("") : @inline end |