defmodule GraphPlot do def plot(connections) do connections |> Enum.map(fn x -> create_line(x) end) |> Enum.join(", ") |> insert_into_template |> create_doc IO.puts "Done! All requirements have been mapped" IO.puts "Please check index.html in the current directory" end def create_doc(html) do cwd = System.cwd!() {:ok, file} = File.open cwd <> "/index.html", [:write] IO.binwrite file, html end def insert_into_template(data) do template |> String.replace("//insert connections_json here", data, global: false) end def create_line({parent, children}) do imports = children |> Enum.map(fn child -> "\"#{child}\"" end) |> Enum.join(", ") "{\"name\": \"#{parent}\", \"imports\": [#{imports}]}" end def template do """ """ end end