Class: CodeExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/code_executor.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.execute(code_content, lang, temp_dir, input_file_path = nil, explain = false, flamegraph = false) ⇒ Object



7
8
9
# File 'lib/code_executor.rb', line 7

def self.execute(code_content, lang, temp_dir, input_file_path = nil, explain = false, flamegraph = false)
  new.execute(code_content, lang, temp_dir, input_file_path, explain, flamegraph)
end

Instance Method Details

#execute(code_content, lang, temp_dir, input_file_path = nil, explain = false, flamegraph = false) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/code_executor.rb', line 11

def execute(code_content, lang, temp_dir, input_file_path = nil, explain = false, flamegraph = false)
  lang_key = lang.downcase
  lang_config = SUPPORTED_LANGUAGES[lang_key]

  return handle_unsupported_language(lang) unless lang_config

  TestSilencer.warn_unless_testing("Executing #{lang_key} code block...")

  result = execute_with_config(code_content, lang_config, temp_dir, lang_key, input_file_path, explain, flamegraph)
  process_execution_result(result, lang_config, lang_key, explain, flamegraph)
end