Sha256: 0d8dcc7a57ae61dc2c4351a633b25fef7c8aed171abfd9dfd227f1f78cdbf549
Contents?: true
Size: 1.55 KB
Versions: 3
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true require_relative '../../rails_command_executor' module RailsSpotlight module Middlewares module Handlers class ConsoleActionHandler < BaseActionHandler def execute validate_project! RailsSpotlight.config.logger && RailsSpotlight.config.logger.info("Executing command: #{command}") # rubocop:disable Style/SafeNavigation executor.execute(command) end private def validate_project! return if for_project.blank? return if for_project.include?(::RailsSpotlight.config.project_name) raise UnprocessableEntity, "Check your connection settings the current command is not allowed to be executed on the #{::RailsSpotlight.config.project_name} project" end def executor @executor ||= ::RailsSpotlight::RailsCommandExecutor.new end def inspect_types @inspect_types ||= json_request_body.fetch('inspect_types') end def command @command ||= json_request_body.fetch('command') end def for_project @for_project ||= json_request_body['project'] end def json_response_body if executor.execution_successful? { result: executor.result_as_json(inspect_types: inspect_types), project: ::RailsSpotlight.config.project_name } else executor.result_as_json.merge(project: ::RailsSpotlight.config.project_name) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems