Module: Diffend::RequestVerdict
- Defined in:
- lib/diffend/request_verdict.rb
Overview
Module responsible for fetching diffend verdict on local context
Class Method Summary collapse
- .build_request_object(command, config, payload) ⇒ Diffend::RequestObject
- .call(command, config, definition) ⇒ Object
-
.commands_url(command, project_id) ⇒ String
Provides diffend command endpoint url.
Class Method Details
.build_request_object(command, config, payload) ⇒ Diffend::RequestObject
37 38 39 40 41 42 43 44 |
# File 'lib/diffend/request_verdict.rb', line 37 def build_request_object(command, config, payload) Diffend::RequestObject.new( config: config, url: commands_url(command, config.project_id), payload: payload, request_method: :post ) end |
.call(command, config, definition) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/diffend/request_verdict.rb', line 12 def call(command, config, definition) payload = Diffend::LocalContext.call(command, config.project_id, definition) response = Diffend::Request.call( build_request_object(command, config, payload) ) JSON.parse(response.body) rescue Bundler::GemNotFound raise ::Diffend::Errors::DependenciesResolveException rescue StandardError => e Diffend::HandleErrors::Report.call( exception: e, payload: payload || {}, config: config, message: :unhandled_exception, report: true ) end |
.commands_url(command, project_id) ⇒ String
Provides diffend command endpoint url
52 53 54 55 56 |
# File 'lib/diffend/request_verdict.rb', line 52 def commands_url(command, project_id) return ENV['DIFFEND_COMMAND_URL'] if ENV.key?('DIFFEND_COMMAND_URL') "https://my.diffend.io/api/projects/#{project_id}/bundle/#{command}" end |