Module: Gauge::Processors Private
- Includes:
- ExecutionHandler
- Included in:
- LSPServer, MessageProcessor
- Defined in:
- lib/processors/cache_file_processor.rb,
lib/processors/execution_handler.rb,
lib/processors/kill_request_processor.rb,
lib/processors/datastore_init_processor.rb,
lib/processors/execution_hook_processors.rb,
lib/processors/step_name_request_processor.rb,
lib/processors/step_names_request_processor.rb,
lib/processors/stub_implementation_processor.rb,
lib/processors/execute_step_request_processor.rb,
lib/processors/refactor_step_request_processor.rb,
lib/processors/step_positions_request_processor.rb,
lib/processors/step_validation_request_processor.rb,
lib/processors/implementation_file_list_processor.rb,
lib/processors/implementation_glob_pattern_processor.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: ExecutionHandler
Instance Method Summary collapse
- #cache_file_response(request) ⇒ Object private
- #create_step_position_messages(positions) ⇒ Object private
- #create_suggestion(step_value) ⇒ Object private
- #get_step(step_text) ⇒ Object private
- #implement_stub_response(request) ⇒ Object private
- #implementation_files ⇒ Object private
- #implementation_glob_pattern_response ⇒ Object private
- #process_cache_file_request(message) ⇒ Object private
- #process_datastore_init(message) ⇒ Object private
- #process_execute_step_request(message) ⇒ Object private
- #process_execution_end_request(message) ⇒ Object private
- #process_execution_start_request(message) ⇒ Object private
- #process_implementation_file_list_request(message) ⇒ Object private
- #process_implementation_glob_pattern_request(message) ⇒ Object private
- #process_kill_processor_request(message) ⇒ Object private
- #process_scenario_execution_end_request(message) ⇒ Object private
- #process_scenario_execution_start_request(message) ⇒ Object private
- #process_spec_execution_end_request(message) ⇒ Object private
- #process_spec_execution_start_request(message) ⇒ Object private
- #process_step_execution_end_request(message) ⇒ Object private
- #process_step_execution_start_request(message) ⇒ Object private
- #process_step_name_request(message) ⇒ Object private
- #process_step_names_request(message) ⇒ Object private
- #process_step_positions_request(message) ⇒ Object private
- #process_step_validation_request(message) ⇒ Object private
- #process_stub_implementation_code_request(message) ⇒ Object private
- #refactor_response(request) ⇒ Object private
- #refactor_step(message) ⇒ Object private
- #step_name_response(request) ⇒ Object private
- #step_names_response ⇒ Object private
- #step_positions(request) ⇒ Object private
- #step_validate_response(request) ⇒ Object private
Methods included from ExecutionHandler
#create_param_values, #get_code_snippet, #handle_failure, #handle_hooks_execution, #handle_pass, #screenshot_bytes, #time_elapsed_since
Instance Method Details
#cache_file_response(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/processors/cache_file_processor.rb', line 30 def cache_file_response(request) f = request.filePath status = Messages::CacheFileRequest::FileStatus.resolve(request.status) if (status == Messages::CacheFileRequest::FileStatus::CHANGED) || (status == Messages::CacheFileRequest::FileStatus::OPENED) ast = CodeParser.code_to_ast(request.content) StaticLoader.reload_steps(f, ast) elsif status == Messages::CacheFileRequest::FileStatus::CREATED ast = CodeParser.code_to_ast File.read(f) StaticLoader.reload_steps(f, ast) elsif (status == Messages::CacheFileRequest::FileStatus::CLOSED) && File.file?(f) ast = CodeParser.code_to_ast File.read(f) StaticLoader.reload_steps(f, ast) else StaticLoader.remove_steps(f) end Messages::Empty.new end |
#create_step_position_messages(positions) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 |
# File 'lib/processors/step_positions_request_processor.rb', line 32 def (positions) positions.map do |p| span = Gauge::Messages::Span.new(:start => p[:span].begin.line, :end => p[:span].end.line, :startChar => p[:span].begin.column, :endChar => p[:span].end.column) Messages::StepPositionsResponse::StepPosition.new(:stepValue => p[:stepValue], :span => span) end end |
#create_suggestion(step_value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 52 |
# File 'lib/processors/step_validation_request_processor.rb', line 47 def create_suggestion(step_value) count = -1 step_text = step_value.stepValue.gsub(/{}/) { "<arg#{count += 1}>" } params = step_value.parameters.map.with_index { |_v, i| "arg#{i}" }.join ', ' "step '#{step_text}' do |#{params}|\n\traise 'Unimplemented Step'\nend" end |
#get_step(step_text) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 |
# File 'lib/processors/refactor_step_request_processor.rb', line 45 def get_step(step_text) md = MethodCache.multiple_implementation? step_text raise "Multiple step implementations found for => '#{step_text}'" if md MethodCache.get_step_info(step_text) end |
#implement_stub_response(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/processors/stub_implementation_processor.rb', line 27 def implement_stub_response(request) codes = request.codes file_path = request.implementationFilePath content = '' if File.file? file_path content = File.read(file_path) else file_path = Util.get_file_name end text_diffs = [Messages::TextDiff.new(span: create_span(content, codes), content: codes.join("\n"))] Messages::FileDiff.new(filePath: file_path, textDiffs: text_diffs) end |
#implementation_files ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 |
# File 'lib/processors/implementation_file_list_processor.rb', line 27 def implementation_files() implPath = Util.get_step_implementation_dir fileList = Dir["#{implPath}/**/*.rb"] Messages::ImplementationFileListResponse.new(:implementationFilePaths => fileList) end |
#implementation_glob_pattern_response ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 |
# File 'lib/processors/implementation_glob_pattern_processor.rb', line 31 def implementation_glob_pattern_response implPath = Util.get_step_implementation_dir Messages::ImplementationFileGlobPatternResponse.new(globPatterns: ["#{implPath}/**/*.rb"]) end |
#process_cache_file_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 |
# File 'lib/processors/cache_file_processor.rb', line 25 def process_cache_file_request() cache_file_response(.cacheFileRequest) nil end |
#process_datastore_init(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/processors/datastore_init_processor.rb', line 23 def process_datastore_init() case . when :SuiteDataStoreInit DataStoreFactory.suite_datastore.clear when :SpecDataStoreInit DataStoreFactory.spec_datastore.clear when :ScenarioDataStoreInit DataStoreFactory.scenario_datastore.clear end execution_status_response = Messages::ExecutionStatusResponse.new(:executionResult => Messages::ProtoExecutionResult.new(:failed => false, :executionTime => 0)) Messages::Message.new(:messageType => :ExecutionStatusResponse, :messageId => ., :executionStatusResponse => execution_status_response) end |
#process_execute_step_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/processors/execute_step_request_processor.rb', line 24 def process_execute_step_request() step_text = .executeStepRequest.parsedStepText parameters = .executeStepRequest.parameters args = create_param_values parameters start_time= Time.now begin Executor.execute_step step_text, args rescue Exception => e return handle_failure , e, time_elapsed_since(start_time), MethodCache.recoverable?(step_text) end handle_pass , time_elapsed_since(start_time) end |
#process_execution_end_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 39 |
# File 'lib/processors/execution_hook_processors.rb', line 35 def process_execution_end_request() response = handle_hooks_execution(MethodCache.get_after_suite_hooks, ,.executionEndingRequest.currentExecutionInfo, false) response.executionStatusResponse.executionResult. += Gauge::GaugeMessages.instance. return response end |
#process_execution_start_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 |
# File 'lib/processors/execution_hook_processors.rb', line 27 def process_execution_start_request() Gauge::MethodCache.clear Executor.load_steps(Util.get_step_implementation_dir) response = handle_hooks_execution(MethodCache.get_before_suite_hooks, ,.executionStartingRequest.currentExecutionInfo,false) response.executionStatusResponse.executionResult. += Gauge::GaugeMessages.instance. return response end |
#process_implementation_file_list_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 |
# File 'lib/processors/implementation_file_list_processor.rb', line 22 def process_implementation_file_list_request() r = implementation_files() Messages::Message.new(:messageType => :ImplementationFileListResponse, :messageId => ., :implementationFileListResponse => r) end |
#process_implementation_glob_pattern_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 27 28 29 |
# File 'lib/processors/implementation_glob_pattern_processor.rb', line 22 def process_implementation_glob_pattern_request() r = implementation_glob_pattern_response Messages::Message.new( messageType: Messages::Message::MessageType::ImplementationFileGlobPatternResponse, messageId: ., implementationFileGlobPatternResponse: r ) end |
#process_kill_processor_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/processors/kill_request_processor.rb', line 21 def process_kill_processor_request() return end |
#process_scenario_execution_end_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 64 |
# File 'lib/processors/execution_hook_processors.rb', line 60 def process_scenario_execution_end_request() response = handle_hooks_execution(MethodCache.get_after_scenario_hooks, ,.scenarioExecutionEndingRequest.currentExecutionInfo) response.executionStatusResponse.executionResult. += Gauge::GaugeMessages.instance. return response end |
#process_scenario_execution_start_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 56 57 |
# File 'lib/processors/execution_hook_processors.rb', line 53 def process_scenario_execution_start_request() response = handle_hooks_execution(MethodCache.get_before_scenario_hooks, ,.scenarioExecutionStartingRequest.currentExecutionInfo) response.executionStatusResponse.executionResult. += Gauge::GaugeMessages.instance. return response end |
#process_spec_execution_end_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 |
# File 'lib/processors/execution_hook_processors.rb', line 47 def process_spec_execution_end_request() response = handle_hooks_execution(MethodCache.get_after_spec_hooks, ,.specExecutionEndingRequest.currentExecutionInfo) response.executionStatusResponse.executionResult. += Gauge::GaugeMessages.instance. return response end |
#process_spec_execution_start_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 44 45 |
# File 'lib/processors/execution_hook_processors.rb', line 41 def process_spec_execution_start_request() response = handle_hooks_execution(MethodCache.get_before_spec_hooks, ,.specExecutionStartingRequest.currentExecutionInfo) response.executionStatusResponse.executionResult. += Gauge::GaugeMessages.instance. return response end |
#process_step_execution_end_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
72 73 74 75 76 |
# File 'lib/processors/execution_hook_processors.rb', line 72 def process_step_execution_end_request() response = handle_hooks_execution(MethodCache.get_after_step_hooks, ,.stepExecutionEndingRequest.currentExecutionInfo) response.executionStatusResponse.executionResult. += Gauge::GaugeMessages.instance. return response end |
#process_step_execution_start_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 69 70 |
# File 'lib/processors/execution_hook_processors.rb', line 66 def process_step_execution_start_request() response = handle_hooks_execution(MethodCache.get_before_step_hooks, ,.stepExecutionStartingRequest.currentExecutionInfo) response.executionStatusResponse.executionResult. += Gauge::GaugeMessages.instance. return response end |
#process_step_name_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 |
# File 'lib/processors/step_name_request_processor.rb', line 20 def process_step_name_request() r = step_name_response(.stepNameRequest) Messages::Message.new(messageType: :StepNameResponse, messageId: ., stepNameResponse: r) end |
#process_step_names_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 |
# File 'lib/processors/step_names_request_processor.rb', line 20 def process_step_names_request() r = step_names_response Messages::Message.new(messageType: :StepNamesResponse, messageId: ., stepNamesResponse: r) end |
#process_step_positions_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 |
# File 'lib/processors/step_positions_request_processor.rb', line 20 def process_step_positions_request() r = step_positions(.stepPositionsRequest) Messages::Message.new(:messageType => :StepPositionsResponse, :messageId => ., :stepPositionsResponse => r) end |
#process_step_validation_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 |
# File 'lib/processors/step_validation_request_processor.rb', line 20 def process_step_validation_request() request = .stepValidateRequest Messages::Message.new(messageType: :StepValidateResponse, messageId: ., stepValidateResponse: step_validate_response(request)) end |
#process_stub_implementation_code_request(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 |
# File 'lib/processors/stub_implementation_processor.rb', line 22 def process_stub_implementation_code_request() file_diff = implement_stub_response(.stubImplementationCodeRequest) Messages::Message.new(messageType: :FileDiff, messageId: ., fileDiff: file_diff) end |
#refactor_response(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/processors/refactor_step_request_processor.rb', line 28 def refactor_response(request) response = Messages::RefactorResponse.new(success: true) begin step_info = get_step request.oldStepValue.stepValue refactored_info = CodeParser.refactor step_info, request.paramPositions, request.newStepValue file = step_info[:locations][0][:file] File.write file, refactored_info[:content] if request.saveChanges response.filesChanged.push(file) changes = Messages::FileChanges.new(fileName: file, fileContent: refactored_info[:content], diffs: refactored_info[:diffs]) response.fileChanges.push(changes) rescue Exception => e response.success = false response.error = e. end response end |
#refactor_step(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 |
# File 'lib/processors/refactor_step_request_processor.rb', line 22 def refactor_step() request = .refactorRequest response = refactor_response(request) Messages::Message.new(messageType: :RefactorResponse, messageId: ., refactorResponse: response) end |
#step_name_response(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/processors/step_name_request_processor.rb', line 25 def step_name_response(request) step_value = request.stepValue unless MethodCache.valid_step?(step_value) return Messages::StepNameResponse.new(isStepPresent: false, stepName: [''], hasAlias: false, fileName: '', span: nil) end step_text = MethodCache.get_step_text(step_value) has_alias = MethodCache.has_alias?(step_text) loc = MethodCache.get_step_info(step_value)[:locations][0] span = Gauge::Messages::Span.new(start: loc[:span].begin.line, end: loc[:span].end.line, startChar: loc[:span].begin.column, endChar: loc[:span].end.column) Messages::StepNameResponse.new(isStepPresent: true, stepName: [step_text], hasAlias: has_alias, fileName: loc[:file], span: span) end |
#step_names_response ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/processors/step_names_request_processor.rb', line 26 def step_names_response Messages::StepNamesResponse.new(steps: MethodCache.all_steps) end |
#step_positions(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 |
# File 'lib/processors/step_positions_request_processor.rb', line 25 def step_positions(request) file = request.filePath positions = MethodCache.step_positions(file) p = (positions) Messages::StepPositionsResponse.new(:stepPositions => p) end |
#step_validate_response(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/processors/step_validation_request_processor.rb', line 27 def step_validate_response(request) response = Messages::StepValidateResponse.new(isValid: true) if !MethodCache.valid_step? request.stepText suggestion = request.stepValue.stepValue.empty? ? '' : create_suggestion(request.stepValue) response = Messages::StepValidateResponse.new( isValid: false, errorMessage: 'Step implementation not found', errorType: Messages::StepValidateResponse::ErrorType::STEP_IMPLEMENTATION_NOT_FOUND, suggestion: suggestion ) elsif MethodCache.multiple_implementation?(request.stepText) response = Messages::StepValidateResponse.new( isValid: false, errorMessage: "Multiple step implementations found for => '#{request.stepText}'", errorType: Messages::StepValidateResponse::ErrorType::DUPLICATE_STEP_IMPLEMENTATION ) end response end |