Class: Michael::Models::PullRequest
- Inherits:
-
Object
- Object
- Michael::Models::PullRequest
- Defined in:
- lib/michael/models/pull_request.rb
Instance Attribute Summary collapse
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#pull_request ⇒ Object
readonly
Returns the value of attribute pull_request.
-
#reviews ⇒ Object
Returns the value of attribute reviews.
-
#statuses ⇒ Object
Returns the value of attribute statuses.
Instance Method Summary collapse
- #actionable?(name) ⇒ Boolean
- #approved? ⇒ Boolean
- #author ⇒ Object
- #author?(name) ⇒ Boolean
- #head_sha ⇒ Object
-
#initialize(pull_request) ⇒ PullRequest
constructor
A new instance of PullRequest.
- #labels ⇒ Object
- #needs_review? ⇒ Boolean
- #number ⇒ Object
- #pretty_print ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(pull_request) ⇒ PullRequest
Returns a new instance of PullRequest.
12 13 14 |
# File 'lib/michael/models/pull_request.rb', line 12 def initialize(pull_request) @pull_request = pull_request end |
Instance Attribute Details
#comments ⇒ Object
Returns the value of attribute comments.
10 11 12 |
# File 'lib/michael/models/pull_request.rb', line 10 def comments @comments end |
#pull_request ⇒ Object (readonly)
Returns the value of attribute pull_request.
9 10 11 |
# File 'lib/michael/models/pull_request.rb', line 9 def pull_request @pull_request end |
#reviews ⇒ Object
Returns the value of attribute reviews.
10 11 12 |
# File 'lib/michael/models/pull_request.rb', line 10 def reviews @reviews end |
#statuses ⇒ Object
Returns the value of attribute statuses.
10 11 12 |
# File 'lib/michael/models/pull_request.rb', line 10 def statuses @statuses end |
Instance Method Details
#actionable?(name) ⇒ Boolean
50 51 52 53 54 55 |
# File 'lib/michael/models/pull_request.rb', line 50 def actionable?(name) return false if (name) return true if reviews.map(&:author).none?(name) last_update_head? end |
#approved? ⇒ Boolean
36 37 38 39 40 |
# File 'lib/michael/models/pull_request.rb', line 36 def approved? return false if reviews.nil? reviews.any? && reviews.all?(&:approved?) end |
#author ⇒ Object
24 25 26 |
# File 'lib/michael/models/pull_request.rb', line 24 def pull_request[:user][:login] end |
#author?(name) ⇒ Boolean
46 47 48 |
# File 'lib/michael/models/pull_request.rb', line 46 def (name) == name end |
#head_sha ⇒ Object
28 29 30 |
# File 'lib/michael/models/pull_request.rb', line 28 def head_sha pull_request[:head][:sha] end |
#labels ⇒ Object
32 33 34 |
# File 'lib/michael/models/pull_request.rb', line 32 def labels pull_request[:labels].map(&:name) end |
#needs_review? ⇒ Boolean
42 43 44 |
# File 'lib/michael/models/pull_request.rb', line 42 def needs_review? pull_request[:requested_reviewers].any? || pull_request[:requested_teams].any? end |
#number ⇒ Object
16 17 18 |
# File 'lib/michael/models/pull_request.rb', line 16 def number pull_request[:number] end |
#pretty_print ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/michael/models/pull_request.rb', line 57 def pretty_print [ pastel.bold("\##{number}"), statuses_in_dots, reviews_in_dots, title, labels.empty? ? nil : pastel.bold.yellow("[#{labels.join(', ')}]"), pastel.cyan(), pretty_last_update(Time.now, last_updated_at), requested_changes, commented ].reject(&:nil?).join(' ') end |
#title ⇒ Object
20 21 22 |
# File 'lib/michael/models/pull_request.rb', line 20 def title pull_request[:title] end |