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
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 |
#comments ⇒ Object
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 |
#commits ⇒ Object
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 |
#labels ⇒ Object
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 |
#mergeable ⇒ Object
50 51 52 |
# File 'lib/openpull/pull_request_decorator.rb', line 50 def mergeable super ? 'Yes'.green : 'No'.red end |
#status ⇒ Object
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 |
#title ⇒ Object
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().login user == other ? user.blue : user end |