Class: RTryHook

Inherits:
Mumukit::Templates::TryHook
  • Object
show all
Defined in:
lib/try_hook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ RTryHook

Returns a new instance of RTryHook.



5
6
7
8
# File 'lib/try_hook.rb', line 5

def initialize(config = nil)
  super config
  @query_hook = RQueryHook.new
end

Instance Attribute Details

#query_hookObject (readonly)

Returns the value of attribute query_hook.



3
4
5
# File 'lib/try_hook.rb', line 3

def query_hook
  @query_hook
end

Instance Method Details

#compile_file_content(r) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/try_hook.rb', line 10

def compile_file_content(r)
  <<R
#{@query_hook.compile_file_header(r)}
cat("#{query_separator}", fill = TRUE);
#{@query_hook.compile_query(r.query)}
cat("#{goal_separator}", fill = TRUE);
#{@query_hook.compile_query(r.goal.with_indifferent_access[:query] || 'NULL')}
R
end

#goal_separatorObject



27
28
29
# File 'lib/try_hook.rb', line 27

def goal_separator
  '!!!MUMUKI-GOAL-START!!!'
end

#query_separatorObject



23
24
25
# File 'lib/try_hook.rb', line 23

def query_separator
  '!!!MUMUKI-QUERY-START!!!'
end

#to_query_result(result, status) ⇒ Object



44
45
46
# File 'lib/try_hook.rb', line 44

def to_query_result(result, status)
  { result: result, status: status }
end

#to_structured_results(_file, result, status) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/try_hook.rb', line 31

def to_structured_results(_file, result, status)
  /#{query_separator}
?(.*)
#{goal_separator}
?(.*)
/m =~ result
  {
      query: to_query_result($1, status),
      goal: $2,
      status: status
  }
end