Skip to content

Commit

Permalink
Merge pull request #25 from adamu/elixir_1.18
Browse files Browse the repository at this point in the history
Fix various warnings and deprecations on Elixir 1.18
  • Loading branch information
nthock authored Dec 17, 2024
2 parents 8ce379a + 0625b77 commit 037ec6a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
import Config

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
Expand Down
29 changes: 19 additions & 10 deletions lib/eqrcode/matrix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,16 @@ defmodule EQRCode.Matrix do
defp path(:up, {x, y}),
do:
for(
i <- x..0,
j <- y..(y - 1),
i <- x..0//-1,
j <- y..(y - 1)//-1,
do: {i, j}
)

defp path(:down, {x, y}),
do:
for(
i <- 0..x,
j <- y..(y - 1),
j <- y..(y - 1)//-1,
do: {i, j}
)

Expand Down Expand Up @@ -373,16 +373,20 @@ defmodule EQRCode.Matrix do
matrix =
Enum.reduce(0..(modules - 1), matrix, fn i, acc ->
update_in(acc, [Access.elem(i)], fn row ->
Tuple.insert_at(row, 0, 0)
row_size = tuple_size(row)

row
|> Tuple.insert_at(0, 0)
|> Tuple.insert_at(0, 0)
|> Tuple.append(0)
|> Tuple.append(0)
|> Tuple.insert_at(row_size + 2, 0)
|> Tuple.insert_at(row_size + 3, 0)
end)
end)
|> Tuple.insert_at(0, zone)
|> Tuple.insert_at(0, zone)
|> Tuple.append(zone)
|> Tuple.append(zone)

matrix = Tuple.insert_at(matrix, tuple_size(matrix), zone)
matrix = Tuple.insert_at(matrix, tuple_size(matrix), zone)

%{m | matrix: matrix}
end
Expand All @@ -401,8 +405,13 @@ defmodule EQRCode.Matrix do
"""
@spec shape(coordinate, {integer, integer}) :: [coordinate]
def shape({x, y}, {w, h}) do
for i <- x..(x + h - 1),
j <- y..(y + w - 1),
x_limit = x + h - 1
y_limit = y + w - 1
x_step = if x <= x_limit, do: 1, else: -1
y_step = if y <= y_limit, do: 1, else: -1

for i <- x..x_limit//x_step,
j <- y..y_limit//y_step,
do: {i, j}
end

Expand Down
12 changes: 6 additions & 6 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
%{
"earmark": {:hex, :earmark, "1.2.6", "b6da42b3831458d3ecc57314dff3051b080b9b2be88c2e5aa41cd642a5b044ed", [:mix], [], "hexpm"},
"earmark_parser": {:hex, :earmark_parser, "1.4.15", "b29e8e729f4aa4a00436580dcc2c9c5c51890613457c193cc8525c388ccb2f06", [:mix], [], "hexpm", "044523d6438ea19c1b8ec877ec221b008661d3c27e3b848f4c879f500421ca5c"},
"ex_doc": {:hex, :ex_doc, "0.25.2", "4f1cae793c4d132e06674b282f1d9ea3bf409bcca027ddb2fe177c4eed6a253f", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "5b0c172e87ac27f14dfd152d52a145238ec71a95efbf29849550278c58a393d6"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
"earmark_parser": {:hex, :earmark_parser, "1.4.41", "ab34711c9dc6212dda44fcd20ecb87ac3f3fce6f0ca2f28d4a00e4154f8cd599", [:mix], [], "hexpm", "a81a04c7e34b6617c2792e291b5a2e57ab316365c2644ddc553bb9ed863ebefa"},
"ex_doc": {:hex, :ex_doc, "0.35.1", "de804c590d3df2d9d5b8aec77d758b00c814b356119b3d4455e4b8a8687aecaf", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "2121c6402c8d44b05622677b761371a759143b958c6c19f6558ff64d0aed40df"},
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
"makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
}
10 changes: 6 additions & 4 deletions test/eqrcode_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ defmodule EQRCodeTest do
end

test "should return error when the input is a charlist" do
charlist = 'this_is_a_charlist'
charlist = ~c"this_is_a_charlist"

assert_raise ArgumentError, "You have passed a list instead of string. Did you pass in a charlist by mistake?", fn ->
charlist |> EQRCode.encode()
end
assert_raise ArgumentError,
"You have passed a list instead of string. Did you pass in a charlist by mistake?",
fn ->
charlist |> EQRCode.encode()
end
end
end
end

0 comments on commit 037ec6a

Please sign in to comment.