Skip to content

Commit

Permalink
Fix Kernel.binary_to_atom deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
rcdilorenzo committed Jun 25, 2014
1 parent 9ff4307 commit 7cc8389
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions lib/weber/handler/weber_req_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ defmodule Handler.WeberReqHandler do
l -> String.replace(l, "-", "_")
end
# check 'lang' process
locale_process = Process.whereis(binary_to_atom(lang <> ".json"))
locale_process = Process.whereis(String.to_atom(lang <> ".json"))
case locale_process do
nil ->
case File.read(Weber.Path.__root__ <> "/deps/weber/lib/weber/i18n/localization/locale/" <> lang <> ".json") do
{:ok, locale_data} -> Weber.Localization.Locale.start_link(binary_to_atom(lang <> ".json"), locale_data)
{:ok, locale_data} -> Weber.Localization.Locale.start_link(String.to_atom(lang <> ".json"), locale_data)
_ -> :ok
end
_ -> :ok
Expand Down Expand Up @@ -116,13 +116,13 @@ defmodule Handler.WeberReqHandler do
end
end

result = state.handler.handle_result(result, conn, controller, Weber.Utils.capitalize(atom_to_binary(action)))
result = state.handler.handle_result(result, conn, controller, Weber.Utils.capitalize(Atom.to_string(action)))
# check for action/controller redirect
case result do
{:render_other_controller, _, _} ->
[controller, action] = result |> elem(1) |> String.split("#")
{controller, _} = Code.eval_string(controller)
get_response(controller, binary_to_atom(action), result |> elem(2), conn, req, state)
get_response(controller, String.to_atom(action), result |> elem(2), conn, req, state)
_ ->
handle_request(result, req, state, {controller, action, conn})
end
Expand Down
2 changes: 1 addition & 1 deletion lib/weber/http/url.ex
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ defmodule Weber.Http.Url do
end)

Enum.map(filterBindings, fn({{_key1, val1}, {_key2, val2}}) ->
{:erlang.binary_to_atom(val2, :utf8), val1}
{String.to_atom(val2, :utf8), val1}
end)
end

Expand Down
6 changes: 3 additions & 3 deletions lib/weber/i18n/i18n.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ defmodule Weber.I18n do
[] -> "en_US.json"
l -> l <> ".json"
end
date_time_format = :gen_server.call(binary_to_atom(pid), :get_date_time_format)
{date_time_format, binary_to_atom(pid)}
date_time_format = :gen_server.call(String.to_atom(pid), :get_date_time_format)
{date_time_format, String.to_atom(pid)}
end

@doc """
Expand All @@ -37,4 +37,4 @@ defmodule Weber.I18n do
end
end

end
end
4 changes: 2 additions & 2 deletions lib/weber/i18n/localization_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ defmodule Weber.Localization.LocalizationManager do
on_files_in_path(
Path.join([project_path, "/deps/weber/lib/weber/i18n/localization/locale"]),
&( :lists.member(&1, use_locales) ),
&( Weber.Localization.Locale.start_link(binary_to_atom(&1), &2) )
&( Weber.Localization.Locale.start_link(String.to_atom(&1), &2) )
)

on_files_in_path(
Path.join([project_path, "/lang"]),
fn (_) -> true end,
&( Weber.Translation.Translate.start_link(binary_to_atom(&1), &2) )
&( Weber.Translation.Translate.start_link(String.to_atom(&1), &2) )
)

{:noreply, %LocalizationConfig{config: state.config, default_locale: default_locale}}
Expand Down
10 changes: 5 additions & 5 deletions lib/weber/route.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule Weber.Route do
fn({type, value}, acc) ->
case type do
:segment -> acc <> "/" <> value
:binding -> acc <> "/" <> to_bin(Keyword.get(bindings, binary_to_atom(value)))
:binding -> acc <> "/" <> to_bin(Keyword.get(bindings, String.to_atom(value)))
end
end)
end
Expand All @@ -51,12 +51,12 @@ defmodule Weber.Route do
"""
def on(method, path, controllerAndAction) when is_binary(controllerAndAction) do
[controller, action] = split(controllerAndAction, "#")
[[method: method, path: path, controller: binary_to_atom(controller), action: binary_to_atom(action)]]
[[method: method, path: path, controller: String.to_atom(controller), action: String.to_atom(action)]]
end

def on(routesList, method, path, controllerAndAction) when is_binary(controllerAndAction) do
[controller, action] = split(controllerAndAction, "#")
:lists.append(routesList, [[method: method, path: path, controller: binary_to_atom(controller), action: binary_to_atom(action)]])
:lists.append(routesList, [[method: method, path: path, controller: String.to_atom(controller), action: String.to_atom(action)]])
end

@doc """
Expand Down Expand Up @@ -160,7 +160,7 @@ defmodule Weber.Route do
end

defp resources_routes(controller) do
url = List.foldl(String.split(atom_to_binary(controller),"."), "",
url = List.foldl(String.split(Atom.to_string(controller),"."), "",
fn (x, acc) ->
case x do
"Elixir" -> acc <> ""
Expand All @@ -185,4 +185,4 @@ defmodule Weber.Route do
list
end

end
end

0 comments on commit 7cc8389

Please sign in to comment.