Class: ElixirQueryHook

Inherits:
Mumukit::Templates::FileHook
  • Object
show all
Defined in:
lib/query_hook.rb

Instance Method Summary collapse

Instance Method Details

#command_line(filename) ⇒ Object



38
39
40
# File 'lib/query_hook.rb', line 38

def command_line(filename)
  "elixir #{filename}"
end


33
34
35
36
# File 'lib/query_hook.rb', line 33

def compile_cookie(cookie)
  return if cookie.blank?
  cookie.join("\n")
end

#compile_file_content(r) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/query_hook.rb', line 9

def compile_file_content(r)
 <<elixir
defmodule ElixirServer do

try do
  #{r.extra}
  #{r.content}
  #{compile_cookie(r.cookie)}
  #{compile_query(r.query)}
catch
  _ -> IO.puts ""
end
end
elixir
end

#compile_query(query) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/query_hook.rb', line 25

def compile_query(query)
  if query.start_with? 'def '
    "#{query}\nIO.puts \"<function>\""
  else
    "IO.inspect #{query}"
  end
end

#tempfile_extensionObject



4
5
6
# File 'lib/query_hook.rb', line 4

def tempfile_extension
  '.exs'
end