Class: Python3TryHook
- Inherits:
-
Mumukit::Templates::TryHook
- Object
- Mumukit::Templates::TryHook
- Python3TryHook
- Defined in:
- lib/python3/try_hook.rb
Instance Method Summary collapse
- #checker_options ⇒ Object
- #compile_file_content(r) ⇒ Object
- #goal_separator ⇒ Object
-
#initialize(config = nil) ⇒ Python3TryHook
constructor
A new instance of Python3TryHook.
- #post_process_file(file, result, status) ⇒ Object
- #query_separator ⇒ Object
- #to_query_result(result, status) ⇒ Object
- #to_structured_results(_file, result, status) ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ Python3TryHook
Returns a new instance of Python3TryHook.
4 5 6 7 |
# File 'lib/python3/try_hook.rb', line 4 def initialize(config = nil) super config @query_hook = Python3QueryHook.new end |
Instance Method Details
#checker_options ⇒ Object
51 52 53 |
# File 'lib/python3/try_hook.rb', line 51 def { strip_mode: :right_only } end |
#compile_file_content(r) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/python3/try_hook.rb', line 9 def compile_file_content(r) <<python #{@query_hook.compile_file_header(r)} print("#{query_separator}"); #{@query_hook.compile_query(r.query, '')} print("#{goal_separator}"); #{@query_hook.compile_query(r.goal.indifferent_get(:query) || 'None', '')} python end |
#goal_separator ⇒ Object
30 31 32 |
# File 'lib/python3/try_hook.rb', line 30 def goal_separator '!!!MUMUKI-GOAL-START!!!' end |
#post_process_file(file, result, status) ⇒ Object
22 23 24 |
# File 'lib/python3/try_hook.rb', line 22 def post_process_file(file, result, status) super file, *@query_hook.post_process_file(file, result, status) end |
#query_separator ⇒ Object
26 27 28 |
# File 'lib/python3/try_hook.rb', line 26 def query_separator '!!!MUMUKI-QUERY-START!!!' end |
#to_query_result(result, status) ⇒ Object
47 48 49 |
# File 'lib/python3/try_hook.rb', line 47 def to_query_result(result, status) { result: result, status: status } end |
#to_structured_results(_file, result, status) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/python3/try_hook.rb', line 34 def to_structured_results(_file, result, status) result_match = result[/#{query_separator} \K.*?(?=(#{goal_separator})|\z)/m]&.rstrip goal_match = result[/#{goal_separator} \K.*\z/m]&.rstrip { query: to_query_result(result_match, status), goal: goal_match, status: status } end |