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_message_header(type, command) ⇒ String
- .build_message_info(response) ⇒ String
- .build_verdict(command, config, response) ⇒ Object
- .build_warn_message(command, response) ⇒ String
-
.call(command, config, definition) ⇒ Object
Build verdict.
Class Method Details
.build_allow_message(command, response) ⇒ String
84 85 86 87 88 89 90 |
# File 'lib/diffend/voting.rb', line 84 def (command, response) <<~MSG #{('an allow', command)} #{(response)}\n #{response['review_url']}\n MSG end |
.build_deny_message(command, response) ⇒ String
108 109 110 111 112 113 114 |
# File 'lib/diffend/voting.rb', line 108 def (command, response) <<~MSG #{('a deny', command)} #{(response)} 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)) raise Diffend::Errors::HandledException end |
.build_error_message(response) ⇒ String
73 74 75 76 77 78 |
# File 'lib/diffend/voting.rb', line 73 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_message_header(type, command) ⇒ String
120 121 122 |
# File 'lib/diffend/voting.rb', line 120 def (type, command) "\nDiffend reported #{type} verdict for #{command} command for this project." end |
.build_message_info(response) ⇒ String
127 128 129 |
# File 'lib/diffend/voting.rb', line 127 def (response) "\nQuality score: #{response['quality_score']}, allows: #{response['allows_count']}, warnings: #{response['warns_count']}, denies: #{response['denies_count']}." 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 66 67 68 |
# 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 'warn' (command, response) .tap(&Bundler.ui.method(:warn)) 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 |
.build_warn_message(command, response) ⇒ String
96 97 98 99 100 101 102 |
# File 'lib/diffend/voting.rb', line 96 def (command, response) <<~MSG #{('a warn', command)} #{(response)} Please go to the url below and review the issues.\n #{response['review_url']}\n MSG end |