Class: OpenPull::PullRequestDecorator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- OpenPull::PullRequestDecorator
- Defined in:
- lib/openpull/pull_request_decorator.rb
Instance Method Summary collapse
- #as_row(username) ⇒ Object
- #comments ⇒ Object
- #commits ⇒ Object
- #labels ⇒ Object
- #mergeable ⇒ Object
- #status ⇒ Object
- #title ⇒ Object
- #user(other) ⇒ Object
Instance Method Details
#as_row(username) ⇒ Object
5 6 7 8 |
# File 'lib/openpull/pull_request_decorator.rb', line 5 def as_row(username) [title, user(username), labels, status, commits, comments, mergeable, html_url.underline, updated_at] end |
#comments ⇒ Object
47 48 49 50 51 |
# File 'lib/openpull/pull_request_decorator.rb', line 47 def comments num = rels[:comments].get.data.size num += rels[:review_comments].get.data.size num.zero? ? '' : num end |
#commits ⇒ Object
42 43 44 45 |
# File 'lib/openpull/pull_request_decorator.rb', line 42 def commits num = rels[:commits].get.data.size num.zero? ? '' : num end |
#labels ⇒ Object
22 23 24 25 26 27 |
# File 'lib/openpull/pull_request_decorator.rb', line 22 def labels issue = rels[:issue].get.data labels = issue.rels[:labels].get.data labels.map { |l| l.name.yellow }.join(', ') end |
#mergeable ⇒ Object
53 54 55 |
# File 'lib/openpull/pull_request_decorator.rb', line 53 def mergeable super ? 'Yes'.green : 'No'.red end |
#status ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/openpull/pull_request_decorator.rb', line 29 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 |
#title ⇒ Object
10 11 12 13 14 15 |
# File 'lib/openpull/pull_request_decorator.rb', line 10 def title title = super return title if title.size <= 80 title[0, 80] + '...' end |
#user(other) ⇒ Object
17 18 19 20 |
# File 'lib/openpull/pull_request_decorator.rb', line 17 def user(other) user = super().login user == other ? user.blue : user end |