Exception: Escobar::GitHub::DeploymentError
- Inherits:
-
StandardError
- Object
- StandardError
- Escobar::GitHub::DeploymentError
- Defined in:
- lib/escobar/github/deployment_error.rb
Overview
Consolidate GitHub deployment api failures for easier messaging
Instance Attribute Summary collapse
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#required_commit_contexts ⇒ Object
Returns the value of attribute required_commit_contexts.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #default_message ⇒ Object
-
#initialize(repo, response, required_commit_contexts) ⇒ DeploymentError
constructor
A new instance of DeploymentError.
- #missing_contexts ⇒ Object
- #missing_contexts? ⇒ Boolean
- #response_message ⇒ Object
- #succeeded_required_contexts ⇒ Object
Constructor Details
#initialize(repo, response, required_commit_contexts) ⇒ DeploymentError
Returns a new instance of DeploymentError.
7 8 9 10 11 |
# File 'lib/escobar/github/deployment_error.rb', line 7 def initialize(repo, response, required_commit_contexts) @repo = repo @response = response @required_commit_contexts = required_commit_contexts end |
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo.
5 6 7 |
# File 'lib/escobar/github/deployment_error.rb', line 5 def repo @repo end |
#required_commit_contexts ⇒ Object
Returns the value of attribute required_commit_contexts.
5 6 7 |
# File 'lib/escobar/github/deployment_error.rb', line 5 def required_commit_contexts @required_commit_contexts end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/escobar/github/deployment_error.rb', line 5 def response @response end |
Instance Method Details
#default_message ⇒ Object
36 37 38 |
# File 'lib/escobar/github/deployment_error.rb', line 36 def "Unable to create GitHub deployments for #{repo}: #{}" end |
#missing_contexts ⇒ Object
28 29 30 |
# File 'lib/escobar/github/deployment_error.rb', line 28 def missing_contexts required_commit_contexts - succeeded_required_contexts end |
#missing_contexts? ⇒ Boolean
13 14 15 |
# File 'lib/escobar/github/deployment_error.rb', line 13 def missing_contexts? missing_contexts.any? end |
#response_message ⇒ Object
32 33 34 |
# File 'lib/escobar/github/deployment_error.rb', line 32 def response["message"] end |
#succeeded_required_contexts ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/escobar/github/deployment_error.rb', line 17 def succeeded_required_contexts error = response.fetch("errors", [])[0] return [] unless error && error["field"] == "required_contexts" contexts = error["contexts"] contexts.each_with_object([]) do |context, succeeded| success = (context["state"] == "success") required = required_commit_contexts.include?(context["context"]) succeeded << context["context"] if required && success end end |