From 2fbe1c9c20a600d16fdde381b0310bd3cb2edb3d Mon Sep 17 00:00:00 2001 From: Jeff Weiss Date: Tue, 29 Mar 2016 22:04:43 -0700 Subject: prefer Elixir module variants over Erlang ones Prior to this commit exirc used `:gen_server` and `:supervisor` over the Elixir variants `GenServer` and `Supervisor`, respectively. The commit changes to modules to the Elixir variants mostly to reduce the cognitive load on contributors, particularly those who are not yet well versed in Erlang. --- lib/exirc/example_handler.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exirc/example_handler.ex') diff --git a/lib/exirc/example_handler.ex b/lib/exirc/example_handler.ex index f7b0e48..251afaf 100644 --- a/lib/exirc/example_handler.ex +++ b/lib/exirc/example_handler.ex @@ -9,7 +9,7 @@ defmodule ExampleHandler do end def start_link(_) do - :gen_server.start_link(__MODULE__, nil, []) + GenServer.start_link(__MODULE__, nil, []) end def init(_) do -- cgit v1.2.3 From 1ca809736246fc25ce07f45bcbd3eeb787e2adf6 Mon Sep 17 00:00:00 2001 From: Jeff Weiss Date: Tue, 29 Mar 2016 22:40:07 -0700 Subject: Prefer Keyword list syntax for Map key-value pairs Prior to this commit exirc had inconsistent formatting for Map key-value pairs, some cases used the Keyword list style (`key: value`), while other used the traditional Map fat arrow style (`:key => value`). This commit standardizes the codebase on the Keyword list style because 1) all the Map/struct keys are atoms enabling use of the Keyword list style, and 2) the Keyword list style is more compact. --- lib/exirc/example_handler.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/exirc/example_handler.ex') diff --git a/lib/exirc/example_handler.ex b/lib/exirc/example_handler.ex index 251afaf..48774fd 100644 --- a/lib/exirc/example_handler.ex +++ b/lib/exirc/example_handler.ex @@ -27,10 +27,10 @@ defmodule ExampleHandler do def handle_info(:logged_in, _state) do IO.puts "Logged in!" end - def handle_info(%IrcMessage{:nick => from, :cmd => "PRIVMSG", :args => ["mynick", msg]}, _state) do + def handle_info(%IrcMessage{nick: from, cmd: "PRIVMSG", args: ["mynick", msg]}, _state) do IO.puts "Received a private message from \#{from}: \#{msg}" end - def handle_info(%IrcMessage{:nick => from, :cmd => "PRIVMSG", :args => [to, msg]}, _state) do + def handle_info(%IrcMessage{nick: from, cmd: "PRIVMSG", args: [to, msg]}, _state) do IO.puts "Received a message in \#{to} from \#{from}: \#{msg}" end """ @@ -111,11 +111,11 @@ defmodule ExampleHandler do {:noreply, nil} end # This is an example of how you can manually catch commands if ExIrc.Client doesn't send a specific message for it - def handle_info(%IrcMessage{:nick => from, :cmd => "PRIVMSG", :args => ["testnick", msg]}, _state) do + def handle_info(%IrcMessage{nick: from, cmd: "PRIVMSG", args: ["testnick", msg]}, _state) do debug "Received a private message from #{from}: #{msg}" {:noreply, nil} end - def handle_info(%IrcMessage{:nick => from, :cmd => "PRIVMSG", :args => [to, msg]}, _state) do + def handle_info(%IrcMessage{nick: from, cmd: "PRIVMSG", args: [to, msg]}, _state) do debug "Received a message in #{to} from #{from}: #{msg}" {:noreply, nil} end -- cgit v1.2.3