Class: Mumukit::Templates::FileHook
Instance Attribute Summary collapse
Attributes inherited from Hook
#config
Class Method Summary
collapse
Instance Method Summary
collapse
#create_tempfile, #mask_tempfile_references, #tempfile_extension, #with_tempfile, #write_tempdir!, #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
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
5
6
7
|
# File 'lib/mumukit/templates/file_hook.rb', line 5
def request
@request
end
|
Class Method Details
.isolated(value = true) ⇒ Object
.line_number_offset(offset, options = {}) ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/mumukit/templates/file_hook.rb', line 36
def self.line_number_offset(offset, options={})
include Mumukit::Templates::WithLineNumberOffset
define_method(:line_number_offset) do
= options[:include_extra] && request. ? request..lines.length : 0
offset +
end
end
|
.mashup(*args, &map_block) ⇒ Object
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/mumukit/templates/file_hook.rb', line 67
def self.mashup(*args, &map_block)
include Mumukit::Templates::WithMashupFileContent
define_method(:map_mashup_fields, &map_block) if block_given?
args = args.present? ? args : [:extra, :content, :test]
if args
define_method(:mashup_fields) { args }
end
end
|
.structured(value = true, separator: nil) ⇒ Object
52
53
54
55
56
57
|
# File 'lib/mumukit/templates/file_hook.rb', line 52
def self.structured(value=true, separator: nil)
if value
@separator = separator
include Mumukit::Templates::WithStructuredResults
end
end
|
.with_error_patterns ⇒ Object
Instance Method Details
#cleanup_raw_result(result) ⇒ Object
19
20
21
|
# File 'lib/mumukit/templates/file_hook.rb', line 19
def cleanup_raw_result(result)
mask_tempfile_references(result.force_encoding('UTF-8'), masked_tempfile_path)
end
|
#compile(request) ⇒ Object
7
8
9
10
|
# File 'lib/mumukit/templates/file_hook.rb', line 7
def compile(request)
self.request = request
write_tempfile! compile_file_content(request)
end
|
#masked_tempfile_path ⇒ Object
32
33
34
|
# File 'lib/mumukit/templates/file_hook.rb', line 32
def masked_tempfile_path
@masked_tempfile_path ||= "#{t 'mumukit.masked_tempfile_basename'}#{tempfile_extension}"
end
|
#post_process_file(file, result, status) ⇒ Object
23
24
25
|
# File 'lib/mumukit/templates/file_hook.rb', line 23
def post_process_file(file, result, status)
[result, status]
end
|
#run!(file) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/mumukit/templates/file_hook.rb', line 12
def run!(file)
result, status = run_file!(file)
post_process_file(file, cleanup_raw_result(result), status)
ensure
file.unlink
end
|