Skip to content

Commit

Permalink
Handle octal format deprecation in 0.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed Aug 12, 2014
1 parent f2bb9b1 commit 4c3ab5c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/exirc/commands.ex
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ defmodule Irc.Commands do
############
# Helpers
############
@ctcp_delimiter <<0x01>>
@ctcp_delimiter 0o001

@doc """
Send data to a TCP socket.
Expand Down
6 changes: 3 additions & 3 deletions lib/exirc/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ defmodule ExIrc.Utils do

defp get_cmd([cmd, target, [1 | ctcp_cmd] | cmd_args], msg) when cmd == 'PRIVMSG' or cmd == 'NOTICE' do
args = cmd_args
|> Enum.map(&Enum.take_while(&1, fn c -> c != ?\001 end))
|> Enum.map(&Enum.take_while(&1, fn c -> c != 0o001 end))
|> Enum.map(&List.to_string/1)
case args do
args when args != [] ->
Expand Down Expand Up @@ -143,8 +143,8 @@ defmodule ExIrc.Utils do
Example:
iex> local_time = {{2013,12,6},{14,5,00}}
{{2013,12,6},{14,5,00}}
iex> local_time = {{2013,12,6},{14,5,0}}
{{2013,12,6},{14,5,0}}
iex> ExIrc.Utils.ctcp_time local_time
"Fri Dec 06 14:05:00 2013"
"""
Expand Down
4 changes: 2 additions & 2 deletions test/commands_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ defmodule ExIrc.CommandsTest do
use Irc.Commands

test "Commands are formatted properly" do
expected = <<1, "TESTCMD", 1, ?\r, ?\n>>
expected = <<0o001, "TESTCMD", 0o001, ?\r, ?\n>>
assert expected == ctcp!("TESTCMD") |> IO.iodata_to_binary
expected = <<"PRIVMSG #testchan :", 0x01, "ACTION mind explodes!!", 0x01, ?\r, ?\n>>
expected = <<"PRIVMSG #testchan :", 0o001, "ACTION mind explodes!!", 0o001, ?\r, ?\n>>
assert expected == me!("#testchan", "mind explodes!!") |> IO.iodata_to_binary
expected = <<"PASS testpass", ?\r, ?\n>>
assert expected == pass!("testpass") |> IO.iodata_to_binary
Expand Down
4 changes: 2 additions & 2 deletions test/utils_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ defmodule ExIrc.UtilsTest do
doctest ExIrc.Utils

test "Given a local date/time as a tuple, can retrieve get the CTCP formatted time" do
local_time = {{2013,12,6},{14,5,00}} # Mimics output of :calendar.local_time()
local_time = {{2013,12,6},{14,5,0}} # Mimics output of :calendar.local_time()
assert Utils.ctcp_time(local_time) == "Fri Dec 06 14:05:00 2013"
end

test "Can parse a CTCP command" do
message = ':pschoenf NOTICE #testchan :\001ACTION mind explodes!!\001'
message = ':pschoenf NOTICE #testchan :' ++ '#{<<0o001>>}' ++ 'ACTION mind explodes!!' ++ '#{<<0o001>>}'
expected = %IrcMessage{
nick: "pschoenf",
cmd: "ACTION",
Expand Down

0 comments on commit 4c3ab5c

Please sign in to comment.