Class: OpenPull::PullRequestDecorator

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/openpull/pull_request_decorator.rb

Instance Method Summary collapse

Instance Method Details

#as_row(username) ⇒ Object



3
4
5
6
# File 'lib/openpull/pull_request_decorator.rb', line 3

def as_row(username)
  [title, user(username), labels, status, commits, comments, mergeable,
   html_url.underline, updated_at]
end

#commentsObject



45
46
47
48
# File 'lib/openpull/pull_request_decorator.rb', line 45

def comments
  num = rels[:review_comments].get.data.size
  num == 0 ? '' : num
end

#commitsObject



40
41
42
43
# File 'lib/openpull/pull_request_decorator.rb', line 40

def commits
  num = rels[:commits].get.data.size
  num == 0 ? '' : num
end

#labelsObject



20
21
22
23
24
25
# File 'lib/openpull/pull_request_decorator.rb', line 20

def labels
  issue  = rels[:issue].get.data
  labels = issue.rels[:labels].get.data

  labels.map { |l| l.name.yellow }.join(', ')
end

#mergeableObject



50
51
52
# File 'lib/openpull/pull_request_decorator.rb', line 50

def mergeable
  super ? 'Yes'.green : 'No'.red
end

#statusObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/openpull/pull_request_decorator.rb', line 27

def status
  state = rels[:statuses].get.data.map(&:state).first

  case state
  when 'success'
    state.green
  when 'pending'
    state.yellow
  else
    (state || '--').red
  end
end

#titleObject



8
9
10
11
12
13
# File 'lib/openpull/pull_request_decorator.rb', line 8

def title
  title = super
  return title if title.size <= 80

  title[0, 80] + '...'
end

#user(other) ⇒ Object



15
16
17
18
# File 'lib/openpull/pull_request_decorator.rb', line 15

def user(other)
  user = super().
  user == other ? user.blue : user
end