Class: Danger::Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/danger/helpers/comment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, body) ⇒ Comment

Returns a new instance of Comment.



5
6
7
8
# File 'lib/danger/helpers/comment.rb', line 5

def initialize(id, body)
  @id = id
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/danger/helpers/comment.rb', line 3

def body
  @body
end

#idObject (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



10
11
12
# File 'lib/danger/helpers/comment.rb', line 10

def self.from_github(comment)
  self.new(comment["id"], comment["body"])
end

.from_gitlab(comment) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/danger/helpers/comment.rb', line 14

def self.from_gitlab(comment)
  if comment.respond_to?(:id) && comment.respond_to?(:body)
    self.new(comment.id, comment.body)
  else
    self.new(comment["id"], comment["body"])
  end
end

Instance Method Details

#generated_by_danger?(danger_id) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/danger/helpers/comment.rb', line 22

def generated_by_danger?(danger_id)
  body.include?("\"generated_by_#{danger_id}\"")
end

#inline?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/danger/helpers/comment.rb', line 26

def inline?
  body.include?("")
end