module Gauge::Processors
@api private
@api private
Public Instance Methods
Source
# File lib/processors/step_positions_request_processor.rb, line 15 def create_step_position_messages(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
Source
# File lib/processors/step_validation_request_processor.rb, line 28 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
Source
# File lib/processors/datastore_init_processor.rb, line 25 def datastore_response Messages::ExecutionStatusResponse.new(:executionResult => Messages::ProtoExecutionResult.new(:failed => false, :executionTime => 0)) end
Source
# File lib/processors/refactor_step_request_processor.rb, line 27 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
Source
# File lib/processors/cache_file_processor.rb, line 12 def process_cache_file_request(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 if !Gauge::MethodCache.is_file_cached f ast = CodeParser.code_to_ast File.read(f) StaticLoader.reload_steps(f, ast) end 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
Source
# File lib/processors/execute_step_request_processor.rb, line 12 def process_execute_step_request(request) step_text = request.parsedStepText parameters = request.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
Source
# File lib/processors/execution_hook_processors.rb, line 22 def process_execution_end_request(request) handle_hooks_execution(MethodCache.get_after_suite_hooks, request.currentExecutionInfo, false) end
Source
# File lib/processors/execution_hook_processors.rb, line 16 def process_execution_start_request(request) Gauge::MethodCache.clear Executor.load_steps(Util.get_step_implementation_dir) handle_hooks_execution(MethodCache.get_before_suite_hooks,request.currentExecutionInfo,false) end
Source
# File lib/processors/implementation_file_list_processor.rb, line 10 def process_implementation_file_list_request(_request) implPath = Util.get_step_implementation_dir fileList = Dir["#{implPath}/**/*.rb"] Messages::ImplementationFileListResponse.new(:implementationFilePaths => fileList) end
Source
# File lib/processors/implementation_glob_pattern_processor.rb, line 10 def process_implementation_glob_pattern_request(_request) implPath = Util.get_step_implementation_dir Messages::ImplementationFileGlobPatternResponse.new(globPatterns: ["#{implPath}/**/*.rb"]) end
Source
# File lib/processors/kill_request_processor.rb, line 9 def process_kill_processor_request(message) return message end
Source
# File lib/processors/refactor_step_request_processor.rb, line 10 def process_refactor_request(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.message end response end
Source
# File lib/processors/datastore_init_processor.rb, line 20 def process_scenario_data_store_init_request(_request) DataStoreFactory.scenario_datastore.clear datastore_response end
Source
# File lib/processors/execution_hook_processors.rb, line 39 def process_scenario_execution_end_request(request) handle_hooks_execution(MethodCache.get_after_scenario_hooks,request.currentExecutionInfo) end
Source
# File lib/processors/execution_hook_processors.rb, line 34 def process_scenario_execution_start_request(request) handle_hooks_execution(MethodCache.get_before_scenario_hooks,request.currentExecutionInfo) end
Source
# File lib/processors/datastore_init_processor.rb, line 15 def process_spec_data_store_init_request(_request) DataStoreFactory.spec_datastore.clear datastore_response end
Source
# File lib/processors/execution_hook_processors.rb, line 30 def process_spec_execution_end_request(request) handle_hooks_execution(MethodCache.get_after_spec_hooks,request.currentExecutionInfo) end
Source
# File lib/processors/execution_hook_processors.rb, line 26 def process_spec_execution_start_request(request) handle_hooks_execution(MethodCache.get_before_spec_hooks,request.currentExecutionInfo) end
Source
# File lib/processors/execution_hook_processors.rb, line 47 def process_step_execution_end_request(request) handle_hooks_execution(MethodCache.get_after_step_hooks,request.currentExecutionInfo) end
Source
# File lib/processors/execution_hook_processors.rb, line 43 def process_step_execution_start_request(request) handle_hooks_execution(MethodCache.get_before_step_hooks,request.currentExecutionInfo) end
Source
# File lib/processors/step_name_request_processor.rb, line 8 def process_step_name_request(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
Source
# File lib/processors/step_names_request_processor.rb, line 8 def process_step_names_request(_request) Messages::StepNamesResponse.new(steps: MethodCache.all_steps) end
Source
# File lib/processors/step_positions_request_processor.rb, line 8 def process_step_positions_request(request) file = request.filePath positions = MethodCache.step_positions(file) p = create_step_position_messages(positions) Messages::StepPositionsResponse.new(:stepPositions => p) end
Source
# File lib/processors/step_validation_request_processor.rb, line 8 def process_step_validation_request(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
Source
# File lib/processors/stub_implementation_processor.rb, line 10 def process_stub_implementation_code_request(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
Source
# File lib/processors/datastore_init_processor.rb, line 10 def process_suite_data_store_init_request(_request) DataStoreFactory.suite_datastore.clear datastore_response end
Private Instance Methods
Source
# File lib/processors/stub_implementation_processor.rb, line 24 def create_span(content, codes) unless content.empty? eof_char = content.strip.length == content.length ? "\n" : '' codes.unshift(eof_char) line = content.split("\n").length return Messages::Span.new(start: line, startChar: 0, end: line, endChar: 0) end Messages::Span.new(start: 0, startChar: 0, end: 0, endChar: 0) end