Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows custom format width #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/snapshy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ defmodule Snapshy do
value
|> Inspect.Algebra.to_doc(inspect_options())
|> Inspect.Algebra.group()
|> Inspect.Algebra.format(80)
|> Enum.join()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also remove Enum.join since File.write can accept iodata. :)

|> Inspect.Algebra.format(format_width_option())
end

defp deserialize(value) do
Expand All @@ -194,6 +193,10 @@ defmodule Snapshy do
term
end

defp format_width_option() do
Application.get_env(:snapshy, :format_width, 80)
end

defp inspect_options do
opts =
default_inspect_options()
Expand Down