Class: Mumukit::Templates::MulangExpectationsHook
- Inherits:
-
FileHook
- Object
- Hook
- FileHook
- Mumukit::Templates::MulangExpectationsHook
show all
- Defined in:
- lib/mumukit/templates/mulang_expectations_hook.rb
Instance Attribute Summary
Attributes inherited from Hook
#config
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from FileHook
#compile, isolated, mashup, #run!, structured
#create_tempfile, #with_tempfile, #write_tempfile!
Methods inherited from Hook
#env, #initialize, #logger, #method_missing, #should_forward_to_config?, stateful_through, #t
#content_type
Constructor Details
This class inherits a constructor from Mumukit::Hook
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Mumukit::Hook
Class Method Details
.include_smells(value = true) ⇒ Object
51
52
53
54
55
|
# File 'lib/mumukit/templates/mulang_expectations_hook.rb', line 51
def self.include_smells(value=true)
if value
include Mumukit::Templates::WithCodeSmells
end
end
|
Instance Method Details
#command_line(filename) ⇒ Object
11
12
13
|
# File 'lib/mumukit/templates/mulang_expectations_hook.rb', line 11
def command_line(filename)
"cat #{filename} | #{mulang_path} -s"
end
|
#compile_content(content) ⇒ Object
32
33
34
|
# File 'lib/mumukit/templates/mulang_expectations_hook.rb', line 32
def compile_content(content)
content
end
|
#compile_expectation(expectation) ⇒ Object
36
37
38
|
# File 'lib/mumukit/templates/mulang_expectations_hook.rb', line 36
def compile_expectation(expectation)
(expectation[:verb].present? ? {tag: :Advanced} : {tag: :Basic}).merge(expectation)
end
|
#compile_file_content(request) ⇒ Object
19
20
21
|
# File 'lib/mumukit/templates/mulang_expectations_hook.rb', line 19
def compile_file_content(request)
compile_json_file_content(request).to_json
end
|
#compile_json_file_content(request) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/mumukit/templates/mulang_expectations_hook.rb', line 23
def compile_json_file_content(request)
{
expectations: request[:expectations].map { |it| compile_expectation(it.deep_symbolize_keys) },
code: {
content: compile_content(request[:content]),
language: language}
}
end
|
#parse_expectation(expectation) ⇒ Object
47
48
49
|
# File 'lib/mumukit/templates/mulang_expectations_hook.rb', line 47
def parse_expectation(expectation)
expectation.deep_symbolize_keys.except(:tag)
end
|
#parse_response(response) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/mumukit/templates/mulang_expectations_hook.rb', line 40
def parse_response(response)
response['results'].map do |it|
{result: it['result'],
expectation: parse_expectation(it['expectation'])}
end
end
|
#post_process_file(file, result, status) ⇒ Object
15
16
17
|
# File 'lib/mumukit/templates/mulang_expectations_hook.rb', line 15
def post_process_file(file, result, status)
parse_response JSON.pretty_parse(result)
end
|
#tempfile_extension ⇒ Object
7
8
9
|
# File 'lib/mumukit/templates/mulang_expectations_hook.rb', line 7
def tempfile_extension
'.json'
end
|