Skip to content

Commit

Permalink
Merge pull request #300 from aesmail/elixir-module-validation
Browse files Browse the repository at this point in the history
filter erlang modules out
  • Loading branch information
aesmail authored Oct 9, 2023
2 parents d159160 + 625a53b commit 0a3e00b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v0.10.1 (2023-10-09)

### Fixes
- Fix a crash when Kaffy mistakenly treats erlang modules as Elixir modules (PR #300)

## v0.10.0 (2023-10-06)

### Fixes
Expand Down
10 changes: 7 additions & 3 deletions lib/kaffy/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ defmodule Kaffy.Utils do
end

@doc """
Returns true if `thing` is a module, false otherwise.
Returns true if `thing` is an elixir module, false otherwise.
"""
@spec is_module(module()) :: boolean()
def is_module(thing), do: is_atom(thing) && function_exported?(thing, :__info__, 1)
Expand Down Expand Up @@ -432,8 +432,12 @@ defmodule Kaffy.Utils do

defp get_schemas(mods) do
Enum.filter(mods, fn m ->
functions = m.__info__(:functions)
Keyword.has_key?(functions, :__schema__) && Map.has_key?(m.__struct__, :__meta__)
if is_module(m) do
functions = m.__info__(:functions)
Keyword.has_key?(functions, :__schema__) && Map.has_key?(m.__struct__, :__meta__)
else
false
end
end)
end

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 Kaffy.MixProject do
use Mix.Project

@source_url "https://github.com/aesmail/kaffy"
@version "0.10.0"
@version "0.10.1"

def project do
[
Expand Down

0 comments on commit 0a3e00b

Please sign in to comment.