Skip to content

Commit

Permalink
📎 version bump (cosmetics)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Matiushkin committed Jan 22, 2022
1 parent f3f09de commit 945828a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
1 change: 0 additions & 1 deletion lib/estructura.ex
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ defmodule Estructura do
quote do
@__estructura__ struct!(Estructura.Config, unquote(opts))

# @after_compile Estructura.Hooks
@before_compile {Estructura.Hooks, :inject_estructura}
end
end
Expand Down
19 changes: 6 additions & 13 deletions lib/estructura/hooks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ defmodule Estructura.Hooks do

if match?({:module, StreamData}, Code.ensure_compiled(StreamData)) do
defp generator_ast([{_, _} | _] = types) do
quote generated: true, location: :keep, bind_quoted: [types: types] do
module = __MODULE__
fields = Keyword.keys(types)

@__generator__ %{types: types, fields: Keyword.keys(types)}
quote generated: true, location: :keep do
module = __MODULE__

defp fix_gen(many) when is_list(many), do: Enum.map(many, &fix_gen/1)

Expand Down Expand Up @@ -354,7 +354,7 @@ defmodule Estructura.Hooks do

defp generation_bound do
args =
Enum.map(@__generator__.types, fn {arg, gen} ->
Enum.map(unquote(types), fn {arg, gen} ->
{Macro.var(arg, nil), fix_gen(gen)}
end)

Expand All @@ -365,10 +365,7 @@ defmodule Estructura.Hooks do

defmacrop do_generation, do: generation_bound()

@doc """
Returns the generator to be used in `StreamData`-powered property testing, based
on the specification given to `use #{inspect(__MODULE__)}`.
"""
@doc "See `#{inspect(__MODULE__)}.__generator__/1`"
@spec __generator__() :: StreamData.t(%__MODULE__{})
def __generator__, do: __generator__(%__MODULE__{})

Expand All @@ -386,7 +383,7 @@ defmodule Estructura.Hooks do
def __generator__(%__MODULE__{} = this) do
do_generation()
|> StreamData.map(&Tuple.to_list/1)
|> StreamData.map(&Enum.zip(@__generator__.fields, &1))
|> StreamData.map(&Enum.zip(unquote(fields), &1))
|> StreamData.map(&struct(this, &1))
end

Expand All @@ -405,10 +402,6 @@ defmodule Estructura.Hooks do
|> Map.keys()
end

def __after_compile__(_env, _bytecode) do
# IO.inspect(env.module.__struct__, label: "AFTER")
end

defmacro inject_estructura(env) do
module = env.module

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

@app :estructura
@version "0.3.0"
@version "0.3.1"

def project do
[
Expand Down

0 comments on commit 945828a

Please sign in to comment.