Class: BitbucketServer::Representation::PullRequest

Inherits:
Base
  • Object
show all
Defined in:
lib/bitbucket_server/representation/pull_request.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

#authorObject


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

def author
  raw.dig('author', 'user', 'name')
end

#author_emailObject


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

def author_email
  raw.dig('author', 'user', 'emailAddress')
end

#author_usernameObject


14
15
16
17
18
# File 'lib/bitbucket_server/representation/pull_request.rb', line 14

def author_username
  raw.dig('author', 'user', 'username') ||
    raw.dig('author', 'user', 'slug') ||
    raw.dig('author', 'user', 'displayName')
end

#created_atObject


43
44
45
# File 'lib/bitbucket_server/representation/pull_request.rb', line 43

def created_at
  self.class.convert_timestamp(created_date)
end

#descriptionObject


20
21
22
# File 'lib/bitbucket_server/representation/pull_request.rb', line 20

def description
  raw['description']
end

#iidObject


24
25
26
# File 'lib/bitbucket_server/representation/pull_request.rb', line 24

def iid
  raw['id']
end

#merged?Boolean

Returns:

  • (Boolean)

39
40
41
# File 'lib/bitbucket_server/representation/pull_request.rb', line 39

def merged?
  state == 'merged'
end

#source_branch_nameObject


55
56
57
# File 'lib/bitbucket_server/representation/pull_request.rb', line 55

def source_branch_name
  raw.dig('fromRef', 'id')
end

#source_branch_shaObject


59
60
61
# File 'lib/bitbucket_server/representation/pull_request.rb', line 59

def source_branch_sha
  raw.dig('fromRef', 'latestCommit')
end

#stateObject


28
29
30
31
32
33
34
35
36
37
# File 'lib/bitbucket_server/representation/pull_request.rb', line 28

def state
  case raw['state']
  when 'MERGED'
    'merged'
  when 'DECLINED'
    'closed'
  else
    'opened'
  end
end

#target_branch_nameObject


63
64
65
# File 'lib/bitbucket_server/representation/pull_request.rb', line 63

def target_branch_name
  raw.dig('toRef', 'id')
end

#target_branch_shaObject


67
68
69
# File 'lib/bitbucket_server/representation/pull_request.rb', line 67

def target_branch_sha
  raw.dig('toRef', 'latestCommit')
end

#titleObject


51
52
53
# File 'lib/bitbucket_server/representation/pull_request.rb', line 51

def title
  raw['title']
end

#updated_atObject


47
48
49
# File 'lib/bitbucket_server/representation/pull_request.rb', line 47

def updated_at
  self.class.convert_timestamp(updated_date)
end