Module: Gauge::Processors Private
- Includes:
- ExecutionHandler
- Included in:
- 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
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
- #create_span(content, codes) ⇒ Object private
- #create_step_position_messages(positions) ⇒ Object private
- #create_suggestion(step_value) ⇒ Object private
- #get_step(step_text) ⇒ Object private
- #load_from_disk(f) ⇒ 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_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_step(message) ⇒ 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
#create_span(content, codes) ⇒ 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.
36 37 38 39 40 41 42 43 44 |
# File 'lib/processors/stub_implementation_processor.rb', line 36 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 |
#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.
28 29 30 31 32 33 |
# File 'lib/processors/step_positions_request_processor.rb', line 28 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.
42 43 44 45 46 47 |
# File 'lib/processors/step_validation_request_processor.rb', line 42 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.
39 40 41 42 43 |
# File 'lib/processors/refactor_step_request_processor.rb', line 39 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 |
#load_from_disk(f) ⇒ 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.
33 34 35 36 37 38 39 40 |
# File 'lib/processors/cache_file_processor.rb', line 33 def load_from_disk(f) if File.file? f ast = CodeParser.code_to_ast File.read(f) StaticLoader.reload_steps(f, ast) else StaticLoader.remove_steps(f) end 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.
23 24 25 26 27 28 29 30 31 |
# File 'lib/processors/cache_file_processor.rb', line 23 def process_cache_file_request() if !.cacheFileRequest.isClosed ast = CodeParser.code_to_ast(.cacheFileRequest.content) StaticLoader.reload_steps(.cacheFileRequest.filePath, ast) else load_from_disk .cacheFileRequest.filePath end 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 Messages::Message::MessageType::SuiteDataStoreInit DataStoreFactory.suite_datastore.clear when Messages::Message::MessageType::SpecDataStoreInit DataStoreFactory.spec_datastore.clear when Messages::Message::MessageType::ScenarioDataStoreInit DataStoreFactory.scenario_datastore.clear end execution_status_response = Messages::ExecutionStatusResponse.new(:executionResult => Messages::ProtoExecutionResult.new(:failed => false, :executionTime => 0)) Messages::Message.new(:messageType => Messages::Message::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.
33 34 35 |
# File 'lib/processors/execution_hook_processors.rb', line 33 def process_execution_end_request() handle_hooks_execution(MethodCache.get_after_suite_hooks, , .executionEndingRequest.currentExecutionInfo, false) 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 |
# 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) handle_hooks_execution(MethodCache.get_before_suite_hooks, , .executionStartingRequest.currentExecutionInfo,false) 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 26 27 |
# File 'lib/processors/implementation_file_list_processor.rb', line 22 def process_implementation_file_list_request() implPath = Util.get_step_implementation_dir fileList = Dir["#{implPath}/**/*.rb"] r = Messages::ImplementationFileListResponse.new(:implementationFilePaths => fileList) Messages::Message.new(:messageType => Messages::Message::MessageType::ImplementationFileListResponse, :messageId => ., :implementationFileListResponse => 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.
49 50 51 |
# File 'lib/processors/execution_hook_processors.rb', line 49 def process_scenario_execution_end_request() handle_hooks_execution(MethodCache.get_after_scenario_hooks, , .scenarioExecutionEndingRequest.currentExecutionInfo) 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.
45 46 47 |
# File 'lib/processors/execution_hook_processors.rb', line 45 def process_scenario_execution_start_request() handle_hooks_execution(MethodCache.get_before_scenario_hooks, , .scenarioExecutionStartingRequest.currentExecutionInfo) 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.
41 42 43 |
# File 'lib/processors/execution_hook_processors.rb', line 41 def process_spec_execution_end_request() handle_hooks_execution(MethodCache.get_after_spec_hooks, , .specExecutionEndingRequest.currentExecutionInfo) 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.
37 38 39 |
# File 'lib/processors/execution_hook_processors.rb', line 37 def process_spec_execution_start_request() handle_hooks_execution(MethodCache.get_before_spec_hooks, , .specExecutionStartingRequest.currentExecutionInfo) 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.
58 59 60 61 62 |
# File 'lib/processors/execution_hook_processors.rb', line 58 def process_step_execution_end_request() response = handle_hooks_execution(MethodCache.get_after_step_hooks, , .stepExecutionEndingRequest.currentExecutionInfo) response.executionStatusResponse.executionResult. = Gauge::GaugeMessages.instance.get 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.
53 54 55 56 |
# File 'lib/processors/execution_hook_processors.rb', line 53 def process_step_execution_start_request() Gauge::GaugeMessages.instance.clear handle_hooks_execution(MethodCache.get_before_step_hooks, , .stepExecutionStartingRequest.currentExecutionInfo) 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 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/processors/step_name_request_processor.rb', line 20 def process_step_name_request() step_value = .stepNameRequest.stepValue if MethodCache.valid_step?(step_value) 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) r = Messages::StepNameResponse.new(isStepPresent: true, stepName: [step_text], hasAlias: has_alias, fileName: loc[:file], span: span) Messages::Message.new(:messageType => Messages::Message::MessageType::StepNameResponse, :messageId => ., :stepNameResponse => r) else r = Messages::StepNameResponse.new(isStepPresent: false, stepName: [''], hasAlias: false, fileName: '', span: nil) Messages::Message.new(:messageType => Messages::Message::MessageType::StepNameResponse, :messageId => ., :stepNameResponse => r) end 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() step_names_response = Messages::StepNamesResponse.new(:steps => MethodCache.all_steps) Messages::Message.new(:messageType => Messages::Message::MessageType::StepNamesResponse, :messageId => ., :stepNamesResponse => step_names_response) 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 24 25 26 |
# File 'lib/processors/step_positions_request_processor.rb', line 20 def process_step_positions_request() file = .stepPositionsRequest.filePath positions = MethodCache.step_positions(file) p = (positions) r = Messages::StepPositionsResponse.new(:stepPositions => p) Messages::Message.new(:messageType => Messages::Message::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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/processors/step_validation_request_processor.rb', line 20 def process_step_validation_request() request = .stepValidateRequest is_valid = true msg,suggestion = '' err_type = nil if !MethodCache.valid_step? request.stepText is_valid = false msg = 'Step implementation not found' err_type = Messages::StepValidateResponse::ErrorType::STEP_IMPLEMENTATION_NOT_FOUND suggestion = create_suggestion(request.stepValue) unless request.stepValue.stepValue.empty? elsif MethodCache.multiple_implementation?(request.stepText) is_valid = false msg = "Multiple step implementations found for => '#{request.stepText}'" err_type = Messages::StepValidateResponse::ErrorType::DUPLICATE_STEP_IMPLEMENTATION suggestion = '' end step_validate_response = Messages::StepValidateResponse.new(:isValid => is_valid, :errorMessage => msg, :errorType => err_type, :suggestion => suggestion) Messages::Message.new(:messageType => Messages::Message::MessageType::StepValidateResponse, :messageId => ., :stepValidateResponse => step_validate_response) 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 26 27 28 29 30 31 32 33 34 |
# File 'lib/processors/stub_implementation_processor.rb', line 22 def process_stub_implementation_code_request() codes = .stubImplementationCodeRequest.codes file_path = .stubImplementationCodeRequest.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"))] file_diff = Messages::FileDiff.new(filePath: file_path, textDiffs: text_diffs) Messages::Message.new(messageType: Messages::Message::MessageType::FileDiff, messageId: ., fileDiff: file_diff) 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 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/processors/refactor_step_request_processor.rb', line 22 def refactor_step() request = .refactorRequest refactor_response = Messages::RefactorResponse.new(success: true) begin step_info = get_step request.oldStepValue.stepValue refactored_code = CodeParser.refactor step_info, request.paramPositions, request.newStepValue file = step_info[:locations][0][:file] File.write file, refactored_code if request.saveChanges refactor_response.filesChanged = [file] refactor_response.fileChanges = [Messages::FileChanges.new(:fileName => file, :fileContent => refactored_code)] rescue Exception => e refactor_response.success = false refactor_response.error = e. end Messages::Message.new(:messageType => Messages::Message::MessageType::RefactorResponse, :messageId => ., refactorResponse: refactor_response) end |