Skip to content

Commit 48498ae

Browse files
authored
Merge pull request #298 from elixirkoans/iamvery/maintenance
Tweaks and adjustments to modernize this repo
2 parents 35d1b4d + 4bb4206 commit 48498ae

File tree

16 files changed

+77
-66
lines changed

16 files changed

+77
-66
lines changed

.github/workflows/elixir.yml

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,44 @@ on:
99

1010
jobs:
1111
build:
12+
runs-on: ubuntu-latest
1213

13-
name: Build and test
14-
runs-on: ubuntu-20.04
14+
env:
15+
MIX_ENV: test
16+
17+
strategy:
18+
matrix:
19+
elixir: [1.18.4]
20+
otp: [28.0.2]
1521

1622
steps:
17-
- uses: actions/checkout@v2
18-
- name: System dependencies
19-
run: |
20-
sudo apt update
21-
sudo apt install -y inotify-tools
22-
- name: Set up Elixir
23-
uses: erlef/setup-beam@988e02bfe678367a02564f65ca2e37726dc0268f
24-
with:
25-
elixir-version: '1.12.3' # Define the elixir version [required]
26-
otp-version: '24.1' # Define the OTP version [required]
27-
- name: Restore dependencies cache
28-
uses: actions/cache@v2
29-
with:
30-
path: deps
31-
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
32-
restore-keys: ${{ runner.os }}-mix-
33-
- name: Install dependencies
34-
run: mix deps.get
35-
- name: Run tests
36-
run: mix test
37-
- name: Run static analytics
38-
run: mix credo suggest --all --strict
23+
- uses: actions/checkout@v4
24+
- name: System Dependencies
25+
run: |
26+
sudo apt update
27+
sudo apt install -y inotify-tools
28+
- name: Setup Elixir
29+
uses: erlef/setup-beam@v1
30+
with:
31+
otp-version: ${{ matrix.otp }}
32+
elixir-version: ${{ matrix.elixir }}
33+
- name: Restore dependencies cache
34+
uses: actions/cache@v4
35+
with:
36+
path: |
37+
deps
38+
_build
39+
key: mix-${{ runner.os }}-${{matrix.elixir}}-${{matrix.otp}}-${{ hashFiles('**/mix.lock') }}
40+
restore-keys: |
41+
mix-${{ runner.os }}-${{matrix.elixir}}-${{matrix.otp}}-
42+
43+
- name: Install dependencies
44+
run: mix deps.get
45+
- name: Check code format
46+
run: mix format --check-formatted
47+
- name: Run static analysis
48+
run: mix credo --strict
49+
- name: Check for unneeded dependencies
50+
run: mix deps.unlock --check-unused
51+
- name: Run tests
52+
run: mix test

CNAME

Lines changed: 0 additions & 1 deletion
This file was deleted.

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2015 http://elixirkoans.io
3+
Copyright (c) 2015 Elixir Koans
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

lib/display.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ defmodule Display do
2222
end
2323

2424
def handle_call(:clear_screen, _from, %{clear_screen: true} = state) do
25-
ANSI.clear <> ANSI.home |> IO.puts()
25+
(ANSI.clear() <> ANSI.home()) |> IO.puts()
2626

2727
{:reply, :ok, state}
2828
end
@@ -58,6 +58,7 @@ defmodule Display do
5858
defp format(failure, module, name) do
5959
progress_bar = ProgressBar.progress_bar(Tracker.summarize())
6060
progress_bar_underline = String.duplicate("-", String.length(progress_bar))
61+
6162
"""
6263
#{Intro.intro(module, Tracker.visited())}
6364
Now meditate upon #{format_module(module)}

lib/display/failure.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ defmodule Display.Failure do
5050
end
5151

5252
defp format_error(error) do
53-
trace = System.stacktrace() |> Enum.take(2)
53+
trace = Process.info(self(), :current_stacktrace) |> Enum.take(2)
5454
Paint.red(Exception.format(:error, error, trace))
5555
end
5656

lib/display/intro.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ defmodule Display.Intro do
66
if module in modules do
77
""
88
else
9-
show_intro(module.intro)
9+
module.intro() |> show_intro()
1010
end
1111
end
1212

lib/display/progress_bar.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ defmodule Display.ProgressBar do
66
arrow = calculate_progress(current, total) |> build_arrow
77
progress_percentage = calculate_percentage(current, total)
88

9-
"|" <> String.pad_trailing(arrow, @progress_bar_length) <> "| #{current} of #{total} -> #{progress_percentage}% complete"
9+
"|" <>
10+
String.pad_trailing(arrow, @progress_bar_length) <>
11+
"| #{current} of #{total} -> #{progress_percentage}% complete"
1012
end
1113

1214
defp calculate_progress(current, total) do

lib/elixir_koans.ex

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ defmodule ElixirKoans do
33
use Application
44

55
def start(_type, _args) do
6-
import Supervisor.Spec
7-
86
children = [
9-
worker(Display, []),
10-
worker(Tracker, []),
11-
worker(Runner, []),
12-
worker(Watcher, [])
7+
%{id: Display, start: {Display, :start_link, []}},
8+
%{id: Tracker, start: {Tracker, :start_link, []}},
9+
%{id: Runner, start: {Runner, :start_link, []}},
10+
%{id: Watcher, start: {Watcher, :start_link, []}}
1311
]
1412

1513
opts = [strategy: :one_for_one, name: ElixirKoans.Supervisor]

lib/execute.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
defmodule Execute do
22
@moduledoc false
33
def run_module(module, callback \\ fn _result, _module, _koan -> nil end) do
4-
Enum.reduce_while(module.all_koans, :passed, fn koan, _ ->
4+
module.all_koans()
5+
|> Enum.reduce_while(:passed, fn koan, _ ->
56
module
67
|> run_koan(koan)
78
|> hook(module, koan, callback)

lib/koans/03_numbers.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ defmodule Numbers do
110110
end
111111

112112
koan "I want the first and last in the range" do
113-
first..last = Range.new(1, 10)
113+
first..last//_step = Range.new(1, 10)
114114

115115
assert first == ___
116116
assert last == ___
@@ -124,11 +124,11 @@ defmodule Numbers do
124124
assert 0 in range == ___
125125
end
126126

127-
def is_range?(%Range{}), do: true
128-
def is_range?(_), do: false
127+
def range?(%Range{}), do: true
128+
def range?(_), do: false
129129

130130
koan "Is this a range?" do
131-
assert is_range?(1..10) == ___
132-
assert is_range?(0) == ___
131+
assert range?(1..10) == ___
132+
assert range?(0) == ___
133133
end
134134
end

0 commit comments

Comments
 (0)