Skip to content

Commit

Permalink
Merge pull request bitwalker#5 from cliffrowley/master
Browse files Browse the repository at this point in the history
Updated to Elixir 0.14.1
  • Loading branch information
bitwalker committed Jun 25, 2014
2 parents 12d8229 + de040c2 commit 55acbcd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
4 changes: 2 additions & 2 deletions lib/app.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ defmodule ExIrc.App do
@moduledoc """
Entry point for the ExIrc application.
"""
use Application.Behaviour
use Application

def start(_type, _args) do
ExIrc.start!
end
end
end
2 changes: 1 addition & 1 deletion lib/exirc/channels.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ defmodule ExIrc.Channels do
Update the type of a tracked channel when it changes
"""
def set_type(channel_tree, channel_name, channel_type) when is_binary(channel_type) do
set_type(channel_tree, channel_name, List.from_char_data!(channel_type))
set_type(channel_tree, channel_name, String.to_char_list(channel_type))
end
def set_type(channel_tree, channel_name, channel_type) do
name = downcase(channel_name)
Expand Down
4 changes: 2 additions & 2 deletions lib/exirc/exirc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ defmodule ExIrc do
# Quit (message is optional)
ExIrc.Client.quit client, "message"
# Stop and close the client connection
ExIrc.Client.stop! client
"""
use Supervisor.Behaviour
use Supervisor

##############
# Public API
Expand Down
30 changes: 14 additions & 16 deletions lib/exirc/utils.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
defmodule ExIrc.Utils do

import String, only: [from_char_data!: 1]

######################
# IRC Message Parsing
######################
Expand All @@ -28,14 +26,14 @@ defmodule ExIrc.Utils do
end

defp parse_from(from, msg) do
case Regex.split(~r/(!|@|\.)/, iodata_to_binary(from)) do
case Regex.split(~r/(!|@|\.)/, IO.iodata_to_binary(from)) do
[nick, "!", user, "@", host | host_rest] ->
%{msg | :nick => nick, :user => user, :host => host <> host_rest}
[nick, "@", host | host_rest] ->
%{msg | :nick => nick, :host => host <> host_rest}
[_, "." | _] ->
# from is probably a server name
%{msg | :server => from_char_data!(from)}
%{msg | :server => to_string(from)}
[nick] ->
%{msg | :nick => nick}
end
Expand All @@ -53,23 +51,23 @@ defmodule ExIrc.Utils do
case args do
[1 | ctcp_rev] ->
[ctcp_cmd | args] = ctcp_rev |> Enum.reverse |> :string.tokens(' ')
%{msg | :cmd => from_char_data!(ctcp_cmd), :args => args, :ctcp => true}
%{msg | :cmd => to_string(ctcp_cmd), :args => args, :ctcp => true}
_ ->
%{msg | :cmd => from_char_data!(cmd), :ctcp => :invalid}
%{msg | :cmd => to_string(cmd), :ctcp => :invalid}
end
end

defp get_cmd([cmd | rest], msg) do
get_args(rest, %{msg | :cmd => from_char_data!(cmd)})
get_args(rest, %{msg | :cmd => to_string(cmd)})
end


# Parse command args from message
defp get_args([], msg) do
args = msg.args
|> Enum.reverse
|> Enum.reverse
|> Enum.filter(fn(arg) -> arg != [] end)
|> Enum.map(&String.from_char_data!/1)
|> Enum.map(&List.to_string/1)
%{msg | :args => args}
end

Expand Down Expand Up @@ -120,7 +118,7 @@ defmodule ExIrc.Utils do
end
defp isup_param("PREFIX=" <> user_prefixes, state) do
prefixes = Regex.run(~r/\((.*)\)(.*)/, user_prefixes, capture: :all_but_first)
|> Enum.map(&List.from_char_data!/1)
|> Enum.map(&String.to_char_list/1)
|> List.zip
%{state | :user_prefixes => prefixes}
end
Expand Down Expand Up @@ -150,15 +148,15 @@ defmodule ExIrc.Utils do
' ',
:lists.nth(m, @months_of_year),
' ',
:io_lib.format("~2..0s", [integer_to_list(d)]),
:io_lib.format("~2..0s", [Integer.to_char_list(d)]),
' ',
:io_lib.format("~2..0s", [integer_to_list(h)]),
:io_lib.format("~2..0s", [Integer.to_char_list(h)]),
':',
:io_lib.format("~2..0s", [integer_to_list(n)]),
:io_lib.format("~2..0s", [Integer.to_char_list(n)]),
':',
:io_lib.format("~2..0s", [integer_to_list(s)]),
:io_lib.format("~2..0s", [Integer.to_char_list(s)]),
' ',
integer_to_list(y)] |> List.flatten |> String.from_char_data!
Integer.to_char_list(y)] |> List.flatten |> List.to_string
end

defp trim_crlf(charlist) do
Expand All @@ -168,4 +166,4 @@ defmodule ExIrc.Utils do
end
end

end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule ExIrc.Mixfile do
def project do
[ app: :exirc,
version: "0.5.0",
elixir: "~> 0.13.3",
elixir: "~> 0.14.1",
description: "An IRC client library for Elixir.",
package: package,
deps: [] ]
Expand Down

0 comments on commit 55acbcd

Please sign in to comment.