Module: Diffend::Voting
- Defined in:
- lib/diffend/voting.rb,
lib/diffend/voting/versions/local.rb,
lib/diffend/voting/versions/remote.rb
Overview
Verifies voting verdicts for gems
Defined Under Namespace
Modules: Versions
Class Method Summary collapse
- .build_allow_message(command, response) ⇒ String
- .build_deny_message(command, response) ⇒ String
- .build_error(response) ⇒ Object
- .build_error_message(response) ⇒ String
- .build_message(command, config, response) ⇒ Object
- .build_verdict(command, config, response) ⇒ Object
-
.call(command, config, definition) ⇒ Object
Build verdict.
Class Method Details
.build_allow_message(command, response) ⇒ String
81 82 83 84 85 86 87 |
# File 'lib/diffend/voting.rb', line 81 def (command, response) <<~MSG \nDiffend reported an allow verdict for #{command} command for this project.\n All of our #{response['allows_count'] + response['denies_count']} checks succeeded.\n #{response['review_url']}\n MSG end |
.build_deny_message(command, response) ⇒ String
93 94 95 96 97 98 99 |
# File 'lib/diffend/voting.rb', line 93 def (command, response) <<~MSG \nDiffend reported a deny verdict for #{command} command for this project.\n #{response['denies_count']} out of our #{response['allows_count'] + response['denies_count']} checks failed. Please go to the url below and review the issues.\n #{response['review_url']}\n MSG end |
.build_error(response) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/diffend/voting.rb', line 37 def build_error(response) (response) .tap(&Bundler.ui.method(:error)) exit 1 end |
.build_error_message(response) ⇒ String
70 71 72 73 74 75 |
# File 'lib/diffend/voting.rb', line 70 def (response) <<~MSG \nDiffend returned an error for your request.\n #{response['error']}\n MSG end |
.build_message(command, config, response) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/diffend/voting.rb', line 21 def (command, config, response) if response.key?('error') build_error(response) elsif response.key?('action') build_verdict(command, config, response) else Diffend::HandleErrors::Report.call( config: config, message: :unsupported_response, payload: response, report: true ) end end |
.build_verdict(command, config, response) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/diffend/voting.rb', line 47 def build_verdict(command, config, response) case response['action'] when 'allow' (command, response) .tap(&Bundler.ui.method(:confirm)) when 'deny' (command, response) .tap(&Bundler.ui.method(:error)) exit 1 else Diffend::HandleErrors::Report.call( config: config, message: :unsupported_verdict, payload: response, report: true ) end end |