Class: BitbucketServer::Representation::Comment

Inherits:
Base
  • Object
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"
            }
}

}

Direct Known Subclasses

PullRequestComment

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 = parent_comment
end

Instance Attribute Details

#parent_commentObject (readonly)

Returns the value of attribute parent_comment


26
27
28
# File 'lib/bitbucket_server/representation/comment.rb', line 26

def parent_comment
  @parent_comment
end

Instance Method Details

#author_emailObject


44
45
46
# File 'lib/bitbucket_server/representation/comment.rb', line 44

def author_email
  author['emailAddress']
end

#author_usernameObject


40
41
42
# File 'lib/bitbucket_server/representation/comment.rb', line 40

def author_username
  author['displayName']
end

#commentsObject

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.


73
74
75
# File 'lib/bitbucket_server/representation/comment.rb', line 73

def comments
  @comments ||= flatten_comments
end

#created_atObject


52
53
54
# File 'lib/bitbucket_server/representation/comment.rb', line 52

def created_at
  self.class.convert_timestamp(created_date)
end

#idObject


36
37
38
# File 'lib/bitbucket_server/representation/comment.rb', line 36

def id
  raw_comment['id']
end

#noteObject


48
49
50
# File 'lib/bitbucket_server/representation/comment.rb', line 48

def note
  raw_comment['text']
end

#updated_atObject


56
57
58
# File 'lib/bitbucket_server/representation/comment.rb', line 56

def updated_at
  self.class.convert_timestamp(created_date)
end