Class: BitbucketServer::Representation::Activity

Inherits:
Base
  • Object
show all
Defined in:
lib/bitbucket_server/representation/activity.rb

Instance Attribute Summary

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods inherited from Base

convert_timestamp, decorate, #initialize

Constructor Details

This class inherits a constructor from BitbucketServer::Representation::Base

Instance Method Details

#approved_event?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/bitbucket_server/representation/activity.rb', line 60

def approved_event?
  action == 'APPROVED'
end

#approver_emailObject



72
73
74
# File 'lib/bitbucket_server/representation/activity.rb', line 72

def approver_email
  raw.dig('user', 'emailAddress')
end

#approver_nameObject



64
65
66
# File 'lib/bitbucket_server/representation/activity.rb', line 64

def approver_name
  raw.dig('user', 'displayName')
end

#approver_usernameObject



68
69
70
# File 'lib/bitbucket_server/representation/activity.rb', line 68

def approver_username
  raw.dig('user', 'slug')
end

#commentObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/bitbucket_server/representation/activity.rb', line 18

def comment
  return unless comment?

  @comment ||=
    if inline_comment?
      PullRequestComment.new(raw)
    else
      Comment.new(raw)
    end
end

#comment?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/bitbucket_server/representation/activity.rb', line 10

def comment?
  action == 'COMMENTED'
end

#committer_emailObject



46
47
48
# File 'lib/bitbucket_server/representation/activity.rb', line 46

def committer_email
  commit.dig('committer', 'emailAddress')
end

#committer_nameObject



38
39
40
# File 'lib/bitbucket_server/representation/activity.rb', line 38

def committer_name
  commit.dig('committer', 'displayName')
end

#committer_userObject



34
35
36
# File 'lib/bitbucket_server/representation/activity.rb', line 34

def committer_user
  commit.dig('committer', 'displayName')
end

#committer_usernameObject



42
43
44
# File 'lib/bitbucket_server/representation/activity.rb', line 42

def committer_username
  commit.dig('committer', 'slug')
end

#created_atObject



92
93
94
# File 'lib/bitbucket_server/representation/activity.rb', line 92

def created_at
  self.class.convert_timestamp(created_date)
end

#declined_event?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/bitbucket_server/representation/activity.rb', line 76

def declined_event?
  action == 'DECLINED'
end

#decliner_emailObject



88
89
90
# File 'lib/bitbucket_server/representation/activity.rb', line 88

def decliner_email
  raw.dig('user', 'emailAddress')
end

#decliner_nameObject



80
81
82
# File 'lib/bitbucket_server/representation/activity.rb', line 80

def decliner_name
  raw.dig('user', 'displayName')
end

#decliner_usernameObject



84
85
86
# File 'lib/bitbucket_server/representation/activity.rb', line 84

def decliner_username
  raw.dig('user', 'slug')
end

#idObject



6
7
8
# File 'lib/bitbucket_server/representation/activity.rb', line 6

def id
  raw['id']
end

#inline_comment?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/bitbucket_server/representation/activity.rb', line 14

def inline_comment?
  !!(comment? && comment_anchor)
end

#merge_commitObject



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

def merge_commit
  commit['id']
end

#merge_event?Boolean

TODO Move this into MergeEvent

Returns:

  • (Boolean)


30
31
32
# File 'lib/bitbucket_server/representation/activity.rb', line 30

def merge_event?
  action == 'MERGED'
end

#merge_timestampObject



50
51
52
53
54
# File 'lib/bitbucket_server/representation/activity.rb', line 50

def merge_timestamp
  timestamp = commit['committerTimestamp']

  self.class.convert_timestamp(timestamp)
end

#to_hashObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/bitbucket_server/representation/activity.rb', line 96

def to_hash
  {
    id: id,
    committer_name: committer_user,
    committer_user: committer_user,
    committer_username: committer_username,
    committer_email: committer_email,
    merge_timestamp: merge_timestamp,
    merge_commit: merge_commit,
    approver_name: approver_name,
    approver_username: approver_username,
    approver_email: approver_email,
    decliner_name: decliner_name,
    decliner_username: decliner_username,
    decliner_email: decliner_email,
    created_at: created_at
  }
end