diff --git a/morse/.formatter.exs b/morse/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/morse/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/morse/.gitignore b/morse/.gitignore new file mode 100644 index 0000000..2f07eac --- /dev/null +++ b/morse/.gitignore @@ -0,0 +1,24 @@ +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. +/.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. +erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). +*.ez + +# Ignore package tarball (built via "mix hex.build"). +morse-*.tar + diff --git a/morse/README.md b/morse/README.md new file mode 100644 index 0000000..521bdda --- /dev/null +++ b/morse/README.md @@ -0,0 +1,21 @@ +# Morse + +**TODO: Add description** + +## Installation + +If [available in Hex](https://hex.pm/docs/publish), the package can be installed +by adding `morse` to your list of dependencies in `mix.exs`: + +```elixir +def deps do + [ + {:morse, "~> 0.1.0"} + ] +end +``` + +Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) +and published on [HexDocs](https://hexdocs.pm). Once published, the docs can +be found at [https://hexdocs.pm/morse](https://hexdocs.pm/morse). + diff --git a/morse/lib/morse.ex b/morse/lib/morse.ex new file mode 100644 index 0000000..402a6c7 --- /dev/null +++ b/morse/lib/morse.ex @@ -0,0 +1,13 @@ +defmodule Morse do + @moduledoc """ + Functions to control the signal lamp connected with GPIO. + """ + + @doc """ + Takes a string composed of dots and dashes, and signals them with the + signal lamp. + """ + def signal(msg) do + IO.puts(msg) + end +end diff --git a/morse/mix.exs b/morse/mix.exs new file mode 100644 index 0000000..05d2095 --- /dev/null +++ b/morse/mix.exs @@ -0,0 +1,28 @@ +defmodule Morse.MixProject do + use Mix.Project + + def project do + [ + app: :morse, + version: "0.1.0", + elixir: "~> 1.9", + start_permanent: Mix.env() == :prod, + deps: deps() + ] + end + + # Run "mix help compile.app" to learn about applications. + def application do + [ + extra_applications: [:logger] + ] + end + + # Run "mix help deps" to learn about dependencies. + defp deps do + [ + # {:dep_from_hexpm, "~> 0.3.0"}, + # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} + ] + end +end diff --git a/morse/test/morse_test.exs b/morse/test/morse_test.exs new file mode 100644 index 0000000..07b8b62 --- /dev/null +++ b/morse/test/morse_test.exs @@ -0,0 +1,4 @@ +defmodule MorseTest do + use ExUnit.Case + doctest Morse +end diff --git a/morse/test/test_helper.exs b/morse/test/test_helper.exs new file mode 100644 index 0000000..869559e --- /dev/null +++ b/morse/test/test_helper.exs @@ -0,0 +1 @@ +ExUnit.start() diff --git a/ui/lib/signal_morse.ex b/ui/lib/signal_morse.ex deleted file mode 100644 index 409e038..0000000 --- a/ui/lib/signal_morse.ex +++ /dev/null @@ -1,5 +0,0 @@ -defmodule Ui.SignalMorse do - def signal do - IO.puts("bleep bloop") - end -end diff --git a/ui/lib/ui_web/controllers/page_controller.ex b/ui/lib/ui_web/controllers/page_controller.ex index 05ff15f..1e56767 100644 --- a/ui/lib/ui_web/controllers/page_controller.ex +++ b/ui/lib/ui_web/controllers/page_controller.ex @@ -22,7 +22,7 @@ defmodule UiWeb.PageController do case get_start_time() do start_time when start_time + 35 <= now -> System.put_env("MORSE_START_TIME", Integer.to_string(now)) - Ui.SignalMorse.signal() + Morse.signal("...---...") text(conn, "Done.") _ -> text(conn, "It is still in progress...") diff --git a/ui/mix.exs b/ui/mix.exs index 61c999c..40d6763 100644 --- a/ui/mix.exs +++ b/ui/mix.exs @@ -38,7 +38,8 @@ defmodule Ui.MixProject do {:phoenix_live_reload, "~> 1.2", only: :dev}, {:gettext, "~> 0.11"}, {:jason, "~> 1.0"}, - {:plug_cowboy, "~> 2.0"} + {:plug_cowboy, "~> 2.0"}, + {:morse, path: "../morse"} ] end end diff --git a/ui/test/ui_web/controllers/page_controller_test.exs b/ui/test/ui_web/controllers/page_controller_test.exs index 3de8b82..5bcffb4 100644 --- a/ui/test/ui_web/controllers/page_controller_test.exs +++ b/ui/test/ui_web/controllers/page_controller_test.exs @@ -1,8 +1,3 @@ defmodule UiWeb.PageControllerTest do use UiWeb.ConnCase - - test "GET /", %{conn: conn} do - conn = get(conn, "/") - assert html_response(conn, 200) =~ "Welcome to Phoenix!" - end end