Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/fix obsolete #132

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/addict/controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Addict.AddictController do
Renders registration layout
"""
def register(%{method: "GET"} = conn, _) do
csrf_token = generate_csrf_token
csrf_token = generate_csrf_token()
conn
|> put_addict_layout
|> render("register.html", csrf_token: csrf_token)
Expand All @@ -54,7 +54,7 @@ defmodule Addict.AddictController do
Renders login layout
"""
def login(%{method: "GET"} = conn, _) do
csrf_token = generate_csrf_token
csrf_token = generate_csrf_token()
conn
|> put_addict_layout
|> render("login.html", csrf_token: csrf_token)
Expand Down Expand Up @@ -90,7 +90,7 @@ defmodule Addict.AddictController do
Renders Password Recovery layout
"""
def recover_password(%{method: "GET"} = conn, _) do
csrf_token = generate_csrf_token
csrf_token = generate_csrf_token()
conn
|> put_addict_layout
|> render("recover_password.html", csrf_token: csrf_token)
Expand All @@ -113,7 +113,7 @@ defmodule Addict.AddictController do
Renders Password Reset layout
"""
def reset_password(%{method: "GET"} = conn, params) do
csrf_token = generate_csrf_token
csrf_token = generate_csrf_token()
token = params["token"]
signature = params["signature"]
conn
Expand Down Expand Up @@ -162,8 +162,8 @@ defmodule Addict.AddictController do
end

defp parse(user_params) do
if user_params[schema_name_string] != nil do
user_params[schema_name_string]
if user_params[schema_name_string()] != nil do
user_params[schema_name_string()]
else
user_params
end
Expand Down
4 changes: 2 additions & 2 deletions lib/addict/mix/generate_boilerplate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Mix.Tasks.Addict.Generate.Boilerplate do
Mix.shell.error "[x] Please make sure your Addict configuration exists first. Generate it via mix:"
Mix.shell.error "[x] mix addict.generate.configs"
else
base_module = guess_application_name
base_module = guess_application_name()
Mix.shell.info "[o] Generating Addict boilerplate"

create_addict_templates
Expand Down Expand Up @@ -53,7 +53,7 @@ defmodule Mix.Tasks.Addict.Generate.Boilerplate do
defp create_addict_view do
view_file = Path.join(["web", "views", "addict_view.ex"])
|> Path.relative_to(Mix.Project.app_path)
create_file view_file, view_template(base_route_helper: (guess_application_name <> ".Router.Helpers"))
create_file view_file, view_template(base_route_helper: (guess_application_name() <> ".Router.Helpers"))
end

defp guess_application_name do
Expand Down
24 changes: 12 additions & 12 deletions lib/addict/mix/generate_configs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@ defmodule Mix.Tasks.Addict.Generate.Configs do
if addict_config_already_exists?(configs_path) do
Mix.shell.error "[x] Please remove the existing Addict configuration before generating a new one"
else
base_module = guess_application_name
base_module = guess_application_name()
user_schema = "#{base_module}.User"
repo = "#{base_module}.Repo"

Mix.shell.info "[o] Generating Addict configuration"

guessed = Mix.shell.yes? "Is your application root module #{base_module}?"
base_module =
base_module =
case guessed do
true -> base_module
false -> Mix.shell.prompt("Please insert your application root module:") |> String.rstrip
false -> Mix.shell.prompt("Please insert your application root module:") |> String.trim_trailing
end

guessed = Mix.shell.yes? "Is your Ecto Repository module #{repo}?"
repo =
repo =
case guessed do
true -> repo
false -> Mix.shell.prompt("Please insert your Ecto Repository module:") |> String.rstrip
false -> Mix.shell.prompt("Please insert your Ecto Repository module:") |> String.trim_trailing
end

guessed = Mix.shell.yes? "Is your User Schema module #{user_schema}?"
user_schema =
user_schema =
case guessed do
true -> user_schema
false -> Mix.shell.prompt("Please insert your User Schema module:") |> String.rstrip
false -> Mix.shell.prompt("Please insert your User Schema module:") |> String.trim_trailing
end

use_mailgun = Mix.shell.yes? "Will you be using Mailgun?"
mailgun_domain =
mailgun_domain =
case use_mailgun do
true -> Mix.shell.prompt("Please insert your Mailgun domain: (e.g.: https://api.mailgun.net/v3/sandbox123456.mailgun.org)") |> String.rstrip
true -> Mix.shell.prompt("Please insert your Mailgun domain: (e.g.: https://api.mailgun.net/v3/sandbox123456.mailgun.org)") |> String.trim_trailing
false -> ""
end

mailgun_api_key =
case use_mailgun do
true -> Mix.shell.prompt("Please insert your Mailgun API key:") |> String.rstrip
mailgun_api_key =
case use_mailgun do
true -> Mix.shell.prompt("Please insert your Mailgun API key:") |> String.trim_trailing
false -> ""
end

Expand Down
6 changes: 3 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ defmodule Addict.Mixfile do
[app: :addict,
version: "0.3.0",
elixir: "~> 1.2",
description: description,
package: package,
description: description(),
package: package(),
docs: &docs/0,
deps: deps]
deps: deps()]
end

def application do
Expand Down