Skip to content
Permalink
Browse files

Add read_file! function

  • Loading branch information
ericdouglas committed Sep 3, 2017
1 parent 4d1d21b commit b03097e05af392eb2e067b27251092c6b256597b
Showing with 31 additions and 0 deletions.
  1. +1 −0 lib/test_helper.exs
  2. +20 −0 lib/todo_list.ex
  3. +8 −0 lib/todo_list_test.exs
  4. +1 −0 lib/todos.csv
  5. +1 −0 lib/todos_test.csv
@@ -0,0 +1 @@
ExUnit.start()
@@ -0,0 +1,20 @@
defmodule TodoList do
@moduledoc """
Todo list application to work with .csv files through IEx.
"""

@path_env %{dev: ["lib", "todos.csv"], test: ["lib", "todos_test.csv"]}
@path Path.join(@path_env[Mix.env])

def init do
@path
|> read_file!
end

defp read_file!(path) do
path
|> File.stream!
|> Enum.map(&String.replace(&1, "\n", ""))
|> to_string
end
end
@@ -0,0 +1,8 @@
defmodule TodoListTest do
use ExUnit.Case
doctest TodoList

test "if the app will load the data from the csv file correctly" do
assert TodoList.init == "1,Study Erlang,2018-01-01,todo"
end
end
@@ -0,0 +1 @@
1,Study Elixir,2017-10-01,done
@@ -0,0 +1 @@
1,Study Erlang,2018-01-01,todo

0 comments on commit b03097e

Please sign in to comment.
You can’t perform that action at this time.