Skip to content

Commit

Permalink
Merge pull request #25 from jclem/3.3.3
Browse files Browse the repository at this point in the history
v3.3.3
  • Loading branch information
jclem authored Jan 10, 2022
2 parents 2c977a4 + 076faf9 commit e16da42
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
40 changes: 34 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
name: CI

on:
push: {branches: master}
pull_request: {branches: master}
push: {branches: main}
pull_request: {branches: main}

jobs:
test:
name: Run tests
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- otp: 21.x
elixir: 1.8.x
- otp: 21.x
elixir: 1.9.x
- otp: 21.x
elixir: 1.10.x
- otp: 21.x
elixir: 1.11.x
- otp: 22.x
elixir: 1.12.x
- otp: 22.x
elixir: 1.13.x
steps:
- uses: actions/checkout@1.0.0
- uses: erlef/[email protected]
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
- uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2.3.1
with:
otp-version: 21.x
elixir-version: 1.8.x
name: crash-logs
path: erl_crash.dump
if-no-files-found: ignore
- uses: erlef/setup-elixir@988e02bfe678367a02564f65ca2e37726dc0268f # v1.9.0
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- uses: actions/cache@67b6d52d50609f6166e3ea1d8872aca3a4763bd2 # v2.1.7
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}-
- run: mix deps.get
- run: mix test --trace
- run: mix format --check-formatted
15 changes: 1 addition & 14 deletions lib/logfmt/decoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ defmodule Logfmt.Decoder do
parse_char(next_grapheme(rest), :key, char, map)
end

@spec parse_char({String.t(), String.t()}, :garbage, map) :: map
defp parse_char({_char, rest}, :garbage, map) do
parse_char(next_grapheme(rest), :garbage, map)
end
Expand All @@ -43,12 +42,10 @@ defmodule Logfmt.Decoder do
parse_char(next_grapheme(rest), :key, key <> char, map)
end

@spec parse_char({String.t(), String.t()}, :key, String.t(), map) :: map
defp parse_char({"=", rest}, :key, key, map) do
parse_char(next_grapheme(rest), :equals, key, map)
end

@spec parse_char({String.t(), String.t()}, :key, String.t(), map) :: map
defp parse_char({_char, rest}, :key, key, map) do
parse_char(next_grapheme(rest), :garbage, map |> put_value(key, true))
end
Expand All @@ -64,12 +61,10 @@ defmodule Logfmt.Decoder do
parse_char(next_grapheme(rest), :ivalue, key, char, map)
end

@spec parse_char({String.t(), String.t()}, :equals, String.t(), map) :: map
defp parse_char({"\"", rest}, :equals, key, map) do
parse_char(next_grapheme(rest), :qvalue, false, key, "", map)
end

@spec parse_char({String.t(), String.t()}, :equals, String.t(), map) :: map
defp parse_char({_char, rest}, :equals, key, map) do
parse_char(next_grapheme(rest), :garbage, map |> put_value(key, true))
end
Expand All @@ -85,7 +80,6 @@ defmodule Logfmt.Decoder do
parse_char(next_grapheme(rest), :garbage, map |> put_value(key, value))
end

@spec parse_char({String.t(), String.t()}, :ivalue, String.t(), String.t(), map) :: map
defp parse_char({char, rest}, :ivalue, key, value, map) do
parse_char(next_grapheme(rest), :ivalue, key, value <> char, map)
end
Expand All @@ -105,12 +99,10 @@ defmodule Logfmt.Decoder do
parse_char(next_grapheme(rest), :qvalue, false, key, value <> char, map)
end

@spec parse_char({String.t(), String.t()}, :qvalue, false, String.t(), String.t(), map) :: map
defp parse_char({"\"", rest}, :qvalue, false, key, value, map) do
parse_char(next_grapheme(rest), :garbage, map |> put_value(key, value))
end

@spec parse_char({String.t(), String.t()}, :qvalue, false, String.t(), String.t(), map) :: map
defp parse_char({char, rest}, :qvalue, false, key, value, map) do
parse_char(next_grapheme(rest), :qvalue, false, key, value <> char, map)
end
Expand All @@ -130,16 +122,11 @@ defmodule Logfmt.Decoder do
map |> Map.put(key, value |> coerce_value)
end

@spec coerce_value(String.t()) :: true
@spec coerce_value(String.t()) :: boolean | number | String.t() | nil
defp coerce_value("true"), do: true

@spec coerce_value(String.t()) :: false
defp coerce_value("false"), do: false

@spec coerce_value(String.t()) :: nil
defp coerce_value("nil"), do: nil

@spec coerce_value(String.t()) :: number | String.t()
defp coerce_value(value) do
integer =
case Integer.parse(value) do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Logfmt.MixProject do
use Mix.Project

@source_url "https://github.com/jclem/logfmt-elixir"
@version "3.3.2"
@version "3.3.3"

def project do
[
Expand Down

0 comments on commit e16da42

Please sign in to comment.