diff --git a/larus/config/config.exs b/larus/config/config.exs --- a/larus/config/config.exs +++ b/larus/config/config.exs @@ -9,7 +9,7 @@ config :larus, Larus.Endpoint, url: [host: "localhost"], root: Path.dirname(__DIR__), - secret_key_base: "P4ngDTuHdlm7r4xqCkz1XwmyQoVJ8tJBDixcKVMEE6aVAwUsy59vZw/b/U7UgYpz", + secret_key_base: "P4ngDTuHdlm7r4xqCkz1XwmyQoVJ8tJBDixcKVMEE6aVAwUsy59vZw/b/", render_errors: [accepts: ~w(html json)], pubsub: [name: Larus.PubSub, adapter: Phoenix.PubSub.PG2] diff --git a/larus/lib/larus.ex b/larus/lib/larus.ex --- a/larus/lib/larus.ex +++ b/larus/lib/larus.ex @@ -1,4 +1,7 @@ defmodule Larus do + @moduledoc """ + Application + """ use Application # See http://elixir-lang.org/docs/stable/elixir/Application.html diff --git a/larus/lib/larus/endpoint.ex b/larus/lib/larus/endpoint.ex --- a/larus/lib/larus/endpoint.ex +++ b/larus/lib/larus/endpoint.ex @@ -1,4 +1,8 @@ defmodule Larus.Endpoint do + @moduledoc """ + Larus.Endpoint + """ + use Phoenix.Endpoint, otp_app: :larus socket "/socket", Larus.UserSocket diff --git a/larus/lib/larus/repo.ex b/larus/lib/larus/repo.ex --- a/larus/lib/larus/repo.ex +++ b/larus/lib/larus/repo.ex @@ -1,3 +1,6 @@ defmodule Larus.Repo do + @moduledoc """ + Larus.Repo + """ use Ecto.Repo, otp_app: :larus end diff --git a/larus/mix.exs b/larus/mix.exs --- a/larus/mix.exs +++ b/larus/mix.exs @@ -36,6 +36,7 @@ {:phoenix_html, "~> 2.4"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:gettext, "~> 0.9"}, + {:dogma, "~> 0.1", only: :dev}, {:cowboy, "~> 1.0"}] end diff --git a/larus/test/support/model_case.ex b/larus/test/support/model_case.ex --- a/larus/test/support/model_case.ex +++ b/larus/test/support/model_case.ex @@ -41,12 +41,12 @@ Given a User model that lists `:name` as a required field and validates `:password` to be safe, it would return: - iex> errors_on(%User{}, %{password: "password"}) + iex> errors_on(%User{}, %{password: "pass"}) [password: "is unsafe", name: "is blank"] You could then write your assertion like: - assert {:password, "is unsafe"} in errors_on(%User{}, %{password: "password"}) + assert {:password, "is unsafe"} in errors_on(%User{}, %{password: "pass"}) You can also create the changeset manually and retrieve the errors field directly: diff --git a/larus/test/test_helper.exs b/larus/test/test_helper.exs --- a/larus/test/test_helper.exs +++ b/larus/test/test_helper.exs @@ -3,4 +3,3 @@ Mix.Task.run "ecto.create", ~w(-r Larus.Repo --quiet) Mix.Task.run "ecto.migrate", ~w(-r Larus.Repo --quiet) Ecto.Adapters.SQL.begin_test_transaction(Larus.Repo) - diff --git a/larus/test/views/layout_view_test.exs b/larus/test/views/layout_view_test.exs --- a/larus/test/views/layout_view_test.exs +++ b/larus/test/views/layout_view_test.exs @@ -1,3 +1,3 @@ defmodule Larus.LayoutViewTest do - use Larus.ConnCase, async: true -end \ No newline at end of file + use Larus.ConnCase, async: true +end diff --git a/larus/web/channels/user_socket.ex b/larus/web/channels/user_socket.ex --- a/larus/web/channels/user_socket.ex +++ b/larus/web/channels/user_socket.ex @@ -1,10 +1,13 @@ defmodule Larus.UserSocket do + @moduledoc """ + Larus.UserSocket + """ use Phoenix.Socket - ## Channels + # ## Channels # channel "rooms:*", Larus.RoomChannel - ## Transports + # ## Transports transport :websocket, Phoenix.Transports.WebSocket # transport :longpoll, Phoenix.Transports.LongPoll @@ -23,14 +26,15 @@ {:ok, socket} end - # Socket id's are topics that allow you to identify all sockets for a given user: + # Socket id's are topics that allow you to identify all sockets for a given + # user: # - # def id(socket), do: "users_socket:#{socket.assigns.user_id}" + # def id(socket), do: "users_socket:#{socket.assigns.user_id}" # # Would allow you to broadcast a "disconnect" event and terminate # all active sockets and channels for a given user: # - # Larus.Endpoint.broadcast("users_socket:#{user.id}", "disconnect", %{}) + # Larus.Endpoint.broadcast("users_socket:#{user.id}", "disconnect", %{}) # # Returning `nil` makes this socket anonymous. def id(_socket), do: nil diff --git a/larus/web/controllers/page_controller.ex b/larus/web/controllers/page_controller.ex --- a/larus/web/controllers/page_controller.ex +++ b/larus/web/controllers/page_controller.ex @@ -1,4 +1,8 @@ defmodule Larus.PageController do + @moduledoc """ + Larus.PageController + """ + use Larus.Web, :controller def index(conn, _params) do diff --git a/larus/web/gettext.ex b/larus/web/gettext.ex --- a/larus/web/gettext.ex +++ b/larus/web/gettext.ex @@ -5,18 +5,18 @@ By using [Gettext](http://hexdocs.pm/gettext), your module gains a set of macros for translations, for example: - import Larus.Gettext + import Larus.Gettext - # Simple translation - gettext "Here is the string to translate" + # Simple translation + gettext "Here is the string to translate" - # Plural translation - ngettext "Here is the string to translate", - "Here are the strings to translate", - 3 + # Plural translation + ngettext "Here is the string to translate", + "Here are the strings to translate", + 3 - # Domain-based translation - dgettext "errors", "Here is the error message to translate" + # Domain-based translation + dgettext "errors", "Here is the error message to translate" See the [Gettext Docs](http://hexdocs.pm/gettext) for detailed usage. """ diff --git a/larus/web/router.ex b/larus/web/router.ex --- a/larus/web/router.ex +++ b/larus/web/router.ex @@ -1,4 +1,8 @@ defmodule Larus.Router do + @moduledoc """ + Larus.Router + """ + use Larus.Web, :router pipeline :browser do diff --git a/larus/web/views/error_helpers.ex b/larus/web/views/error_helpers.ex --- a/larus/web/views/error_helpers.ex +++ b/larus/web/views/error_helpers.ex @@ -9,8 +9,9 @@ Generates tag for inlined form input errors. """ def error_tag(form, field) do - if error = form.errors[field] do - content_tag :span, translate_error(error), class: "help-block" + error = form.errors[field] + if error do + content_tag :span, translate_error(error), class: "help-block" end end @@ -26,6 +27,7 @@ # # dngettext "errors", "1 file", "%{count} files", count # + Gettext.dngettext(Larus.Gettext, "errors", msg, msg, opts[:count], opts) end diff --git a/larus/web/views/error_view.ex b/larus/web/views/error_view.ex --- a/larus/web/views/error_view.ex +++ b/larus/web/views/error_view.ex @@ -1,4 +1,8 @@ defmodule Larus.ErrorView do + @moduledoc """ + Views on errors + """ + use Larus.Web, :view def render("404.html", _assigns) do diff --git a/larus/web/views/layout_view.ex b/larus/web/views/layout_view.ex --- a/larus/web/views/layout_view.ex +++ b/larus/web/views/layout_view.ex @@ -1,3 +1,7 @@ defmodule Larus.LayoutView do + @moduledoc """ + A layout view. + """ + use Larus.Web, :view end diff --git a/larus/web/views/page_view.ex b/larus/web/views/page_view.ex --- a/larus/web/views/page_view.ex +++ b/larus/web/views/page_view.ex @@ -1,3 +1,7 @@ defmodule Larus.PageView do + @moduledoc """ + The Larus page view + """ + use Larus.Web, :view end diff --git a/larus/web/web.ex b/larus/web/web.ex --- a/larus/web/web.ex +++ b/larus/web/web.ex @@ -44,7 +44,8 @@ use Phoenix.View, root: "web/templates" # Import convenience functions from controllers - import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1] + import Phoenix.Controller, only: + [get_csrf_token: 0, get_flash: 2, view_module: 1] # Use all HTML functionality (forms, tags, etc) use Phoenix.HTML