Class: BitbucketServer::Representation::Comment
- Inherits:
-
Base
- Object
- Base
- BitbucketServer::Representation::Comment
show all
- Defined in:
- lib/bitbucket_server/representation/comment.rb
Overview
A general comment with the structure:
"comment": {
"author": {
"active": true,
"displayName": "root",
"emailAddress": "[email protected]",
"id": 1,
"links": {
"self": [
{
"href": "http://localhost:7990/users/root"
}
]
},
"name": "root",
"slug": "root",
"type": "NORMAL"
}
}
}
Defined Under Namespace
Classes: CommentNode
Instance Attribute Summary collapse
Attributes inherited from Base
#raw
Instance Method Summary
collapse
Methods inherited from Base
convert_timestamp, decorate
Constructor Details
#initialize(raw, parent_comment: nil) ⇒ Comment
Returns a new instance of Comment.
30
31
32
33
34
|
# File 'lib/bitbucket_server/representation/comment.rb', line 30
def initialize(raw, parent_comment: nil)
super(raw)
@parent_comment =
end
|
Instance Attribute Details
Returns the value of attribute parent_comment.
26
27
28
|
# File 'lib/bitbucket_server/representation/comment.rb', line 26
def
@parent_comment
end
|
Instance Method Details
#author_email ⇒ Object
50
51
52
|
# File 'lib/bitbucket_server/representation/comment.rb', line 50
def author_email
author['emailAddress']
end
|
#author_name ⇒ Object
40
41
42
|
# File 'lib/bitbucket_server/representation/comment.rb', line 40
def author_name
author['displayName']
end
|
#author_username ⇒ Object
44
45
46
47
48
|
# File 'lib/bitbucket_server/representation/comment.rb', line 44
def author_username
author['username'] ||
author['slug'] ||
author['displayName']
end
|
Bitbucket Server supports the ability to reply to any comment
and created multiple threads. It represents these as a linked list
of comments within comments. For example:
"comments": [
{
"author" : ...
"comments": [
{
"author": ...
Since GitLab only supports a single thread, we flatten all these
comments into a single discussion.
79
80
81
|
# File 'lib/bitbucket_server/representation/comment.rb', line 79
def
@comments ||=
end
|
#created_at ⇒ Object
58
59
60
|
# File 'lib/bitbucket_server/representation/comment.rb', line 58
def created_at
self.class.convert_timestamp(created_date)
end
|
#id ⇒ Object
36
37
38
|
# File 'lib/bitbucket_server/representation/comment.rb', line 36
def id
['id']
end
|
#note ⇒ Object
54
55
56
|
# File 'lib/bitbucket_server/representation/comment.rb', line 54
def note
['text']
end
|
#to_hash ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/bitbucket_server/representation/comment.rb', line 83
def to_hash
= .note if
{
id: id,
author_name: author_name,
author_email: author_email,
author_username: author_username,
note: note,
created_at: created_at,
updated_at: updated_at,
comments: .map(&:to_hash),
parent_comment_note:
}
end
|
#updated_at ⇒ Object
62
63
64
|
# File 'lib/bitbucket_server/representation/comment.rb', line 62
def updated_at
self.class.convert_timestamp(created_date)
end
|