Skip to content

Commit

Permalink
Fixes #450 and release 1.4.27
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertDober committed Aug 11, 2022
1 parent e718190 commit beaa4be
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 28 deletions.
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [Earmark](https://hex.pm/packages/earmark) 1.4.27 2022-08-11

- Fix [Leaky Configuration](https://github.com/pragdave/earmark/issues/450)

## [Earmark](https://hex.pm/packages/earmark) 1.4.26 2033-06-15

Accompanying release of [EarmarkParser](https://hex.pm/packages/earmark_parser) 1.4.26
Expand Down
6 changes: 1 addition & 5 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# This file is responsible for configuring your application
# and its dependencies. The Mix.Config module provides functions
# to aid in doing so.
import Config
case Mix.env do
:test -> config :earmark, sys_interface: Support.Earmark.SysInterface.Mock
_ -> config :earmark, sys_interface: Earmark.SysInterface.Implementation
end
# import Config

# Note this file is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
Expand Down
4 changes: 2 additions & 2 deletions lib/earmark/cli/implementation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ defmodule Earmark.Cli.Implementation do
{:stderr, "Cannot open #{options.file}, reason: #{reason}"}
end
defp _process_input({:ok, io_device}, %Options{eex: true}=options) do
input = SysInterface.sys_interface.readlines(io_device) |> Enum.to_list |> IO.chardata_to_string
input = SysInterface.readlines(io_device) |> Enum.to_list |> IO.chardata_to_string
output = EEx.eval_string(input, include: &Earmark.Internal.include(&1, options))
output_ = _maybe_to_html!(output, options)
{:stdio, output_}
end
defp _process_input({:ok, io_device}, options) do
content =
io_device
|> SysInterface.sys_interface.readlines
|> SysInterface.readlines
|> Enum.to_list

{:stdio, Earmark.as_html!(content, options)}
Expand Down
2 changes: 1 addition & 1 deletion lib/earmark/internal.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ defmodule Earmark.Internal do
|> Options.relative_filename(filename)
case Path.extname(filename) do
".eex" -> EEx.eval_file(options_.file, include: &include(&1, options_))
_ -> SysInterface.sys_interface.readlines(options_.file) |> Enum.to_list
_ -> SysInterface.readlines(options_.file) |> Enum.to_list
end
end

Expand Down
6 changes: 0 additions & 6 deletions lib/earmark/sys_interface.ex

This file was deleted.

3 changes: 0 additions & 3 deletions lib/earmark/sys_interface/behaviour.ex

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
defmodule Earmark.SysInterface.Implementation do

@behaviour Earmark.SysInterface.Behavior
defmodule Earmark.SysInterface do

@doc """
A proxy to IO.stream(..., :line) or usage with a filename
"""
@impl true
def readlines(device_or_filename)
def readlines(filename) when is_binary(filename) do
IO.inspect(filename, label: :inside)
Expand Down
5 changes: 3 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
end

defp elixirc_paths(:test), do: ["lib", "test/support", "dev"]
defp elixirc_paths(:dev), do: ["lib", "bench", "dev"]
defp elixirc_paths(_), do: ["lib"]
defp elixirc_paths(:dev), do: ["lib", "lib1", "bench", "dev"]
defp elixirc_paths(_), do: ["lib", "lib1"]

defp escript_config do
[main_module: Earmark.Cli]
Expand All @@ -70,6 +70,7 @@
[
files: [
"lib",
"lib1",
"mix.exs",
"README.md"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defmodule Test.Acceptance.Earmark.Postprocessor.ChangeMapperTest do
html
end

defp main_mapper({_, atts, _, _} = node) do
defp main_mapper({_, _atts, _, _} = node) do
classes = Earmark.AstTools.find_att_in_node(node, "class") || ""

cond do
Expand Down
2 changes: 1 addition & 1 deletion test/lib/cli/implementation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Test.Cli.ImplementationTest do
use ExUnit.Case

import Earmark.Cli.Implementation
import Support.Earmark.SysInterface.Mock, only: [mock_stdio: 1]
import Earmark.SysInterface, only: [mock_stdio: 1]

doctest Earmark.Cli.Implementation, import: true

Expand Down
3 changes: 1 addition & 2 deletions test/support/sys_interface/mock.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
defmodule Support.Earmark.SysInterface.Mock do
@behaviour Earmark.SysInterface.Behavior
defmodule Earmark.SysInterface do

def readlines(device)
def readlines(:stdio), do: Agent.get_and_update(__MODULE__, &{Map.get(&1, :stdio), %{stdio: []}})
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

ExUnit.configure(exclude: [:wip, :later, :dev, :performance], timeout: 10_000_000)
ExUnit.start(timeout: 10_000 * 60)
Support.Earmark.SysInterface.Mock.start_link
Earmark.SysInterface.start_link

# SPDX-License-Identifier: Apache-2.0

0 comments on commit beaa4be

Please sign in to comment.