From a7f5bfde071c681b183a0b46c51ea3ea2dcea165 Mon Sep 17 00:00:00 2001 From: Garth Kidd Date: Sun, 16 Aug 2020 17:17:03 +1000 Subject: [PATCH] Adjust to Amplified house style * Rebuild `Makefile` * Adjust `README.md` development section * Copy `.credo.exs` style configuration * Copy `.github/workflows/elixir.yml` build configuration * Copy `.tool-versions` Elixir and Erlang upgrades * Copy `.editorconfig` * Copy `.vscode` settings and extension recommendations * Remove `elixir-lang/ex_doc#1169` workaround * Use `@external_resource` to keep `mix docs` in sync * Reorganise `mix.exs`, filling it out more comprehensively * _Downgrade_ `ExDoc` * Include `test/support` in the archive for `TestDevice` * Remove lint * Add a shorter example for fixing the device only --- .credo.exs | 46 ++++++++++++++++++++++++++------- .editorconfig | 4 --- .github/workflows/elixir.yml | 30 ++++++++++++---------- .tool-versions | 4 +-- .vscode/extensions.json | 5 ++-- .vscode/settings.json | 17 +++++++------ Makefile | 29 ++++++++++++++------- README.md | 13 +++++++--- lib/pretty.ex | 3 ++- mix.exs | 49 +++++++++++++----------------------- mix.lock | 23 +++++++++-------- test/pretty_test.exs | 4 +-- test/support/test_device.ex | 4 +-- 13 files changed, 133 insertions(+), 98 deletions(-) diff --git a/.credo.exs b/.credo.exs index f4ceea8..32d4e2e 100644 --- a/.credo.exs +++ b/.credo.exs @@ -10,7 +10,7 @@ configs: [ %{ # - # Run any exec using `mix credo -C `. If no exec name is given + # Run any config using `mix credo -C `. If no config name is given # "default" is used. # name: "default", @@ -21,10 +21,23 @@ # You can give explicit globs or simply directories. # In the latter case `**/*.{ex,exs}` will be used. # - included: ["lib/", "src/", "test/", "web/", "apps/"], + included: [ + "lib/", + "src/", + "test/", + "web/", + "apps/*/lib/", + "apps/*/src/", + "apps/*/test/", + "apps/*/web/" + ], excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"] }, # + # Load and configure plugins here: + # + plugins: [], + # # If you create your own checks, you must specify the source files for # them here, so they can be loaded by Credo before running the analysis. # @@ -35,6 +48,10 @@ # strict: false, # + # To modify the timeout for parsing files, change this value: + # + parse_timeout: 5000, + # # If you want to use uncolored output by default, you can change `color` # to `false` below: # @@ -51,7 +68,7 @@ # ## Consistency Checks # - {Credo.Check.Consistency.ExceptionNames, []}, + {Credo.Check.Consistency.ExceptionNames, false}, {Credo.Check.Consistency.LineEndings, []}, {Credo.Check.Consistency.ParameterPatternMatching, []}, {Credo.Check.Consistency.SpaceAroundOperators, []}, @@ -70,7 +87,7 @@ # If you don't want TODO comments to cause `mix credo` to fail, just # set this value to 0 (zero). # - {Credo.Check.Design.TagTODO, [exit_status: 2]}, + {Credo.Check.Design.TagTODO, false}, {Credo.Check.Design.TagFIXME, []}, # @@ -93,6 +110,7 @@ {Credo.Check.Readability.StringSigils, []}, {Credo.Check.Readability.TrailingBlankLine, []}, {Credo.Check.Readability.TrailingWhiteSpace, []}, + {Credo.Check.Readability.UnnecessaryAliasExpansion, []}, {Credo.Check.Readability.VariableNames, []}, # @@ -107,12 +125,8 @@ {Credo.Check.Refactor.NegatedConditionsInUnless, []}, {Credo.Check.Refactor.NegatedConditionsWithElse, []}, {Credo.Check.Refactor.Nesting, []}, - {Credo.Check.Refactor.PipeChainStart, - [ - excluded_argument_types: [:atom, :binary, :fn, :keyword, :number], - excluded_functions: [] - ]}, {Credo.Check.Refactor.UnlessWithElse, []}, + {Credo.Check.Refactor.WithClauses, []}, # ## Warnings @@ -122,6 +136,7 @@ {Credo.Check.Warning.IExPry, []}, {Credo.Check.Warning.IoInspect, []}, {Credo.Check.Warning.LazyLogging, false}, + {Credo.Check.Warning.MixEnv, false}, {Credo.Check.Warning.OperationOnSameValues, []}, {Credo.Check.Warning.OperationWithConstantResult, []}, {Credo.Check.Warning.RaiseInsideRescue, []}, @@ -133,18 +148,31 @@ {Credo.Check.Warning.UnusedRegexOperation, []}, {Credo.Check.Warning.UnusedStringOperation, []}, {Credo.Check.Warning.UnusedTupleOperation, []}, + {Credo.Check.Warning.UnsafeExec, []}, + + # + # Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`) # # Controversial and experimental checks (opt-in, just replace `false` with `[]`) # + {Credo.Check.Readability.StrictModuleLayout, ignore: [:module_attribute]}, {Credo.Check.Consistency.MultiAliasImportRequireUse, false}, + {Credo.Check.Consistency.UnusedVariableNames, false}, {Credo.Check.Design.DuplicatedCode, false}, + {Credo.Check.Readability.AliasAs, false}, + {Credo.Check.Readability.MultiAlias, false}, {Credo.Check.Readability.Specs, false}, + {Credo.Check.Readability.SinglePipe, []}, + {Credo.Check.Readability.WithCustomTaggedTuple, false}, {Credo.Check.Refactor.ABCSize, false}, {Credo.Check.Refactor.AppendSingleItem, false}, {Credo.Check.Refactor.DoubleBooleanNegation, false}, {Credo.Check.Refactor.ModuleDependencies, false}, + {Credo.Check.Refactor.NegatedIsNil, false}, + {Credo.Check.Refactor.PipeChainStart, []}, {Credo.Check.Refactor.VariableRebinding, false}, + {Credo.Check.Warning.LeakyEnvironment, false}, {Credo.Check.Warning.MapGetUnsafePass, false}, {Credo.Check.Warning.UnsafeToAtom, false} diff --git a/.editorconfig b/.editorconfig index 8326f52..2f45085 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,10 +6,6 @@ insert_final_newline = true trim_trailing_whitespace = true charset = utf-8 -[*.{md,py}] -indent_style = space -indent_size = 4 - [*.{ex,exs,json}] indent_style = space indent_size = 2 diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index bf40e5b..3c52c34 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -1,30 +1,34 @@ +# Modifying the actions? Don't like pushing to GitHub to find out whether your changes worked? +# Consider act: https://github.com/nektos/act +# +# WARNING: you'll need the 18.2GB GitHub-compatible Docker image: +# act -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04 + name: Elixir CI on: push: - branches: [trunk] + branches: [ main ] pull_request: - branches: [trunk] + branches: [ main ] jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 name: Elixir ${{matrix.elixir}} on OTP ${{matrix.otp}} strategy: matrix: - otp: ["21.3", "22.3"] + otp: ["21.3", "22.3", "23.0"] elixir: ["1.8", "1.9", "1.10"] steps: - - uses: actions/checkout@v1.0.0 - - uses: gleam-lang/setup-erlang@v1.0.0 - with: - otp-version: ${{matrix.otp}} - - uses: actions/setup-elixir@v1.2.0 + - uses: actions/checkout@v2 + - name: Set up Elixir + uses: actions/setup-elixir@v1 with: - otp-version: ${{matrix.otp}} elixir-version: ${{matrix.elixir}} - - name: Cache deps - uses: actions/cache@v1.1.2 + otp-version: ${{matrix.otp}} + - name: Restore dependencies cache + uses: actions/cache@v2 env: cache-name: deps with: @@ -58,7 +62,7 @@ jobs: env: MIX_ENV: test - name: mix test - run: mix coveralls --trace + run: mix test --trace - name: mix format run: | mix format --check-formatted --dry-run --check-equivalent diff --git a/.tool-versions b/.tool-versions index e7c8e63..c3de5d1 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -elixir 1.10.3-otp-22 -erlang 22.1.8.1 +elixir 1.10.4-otp-23 +erlang 23.0.3 diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 5283624..19ac909 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,6 @@ { "recommendations": [ - "EditorConfig.EditorConfig", - "davidanson.vscode-markdownlint", - "jakebecker.elixir-ls" + "editorconfig.editorconfig", + "elixir-lsp.elixir-ls" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 863eb66..8f9d048 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,21 +2,24 @@ "editor.rulers": [ 98 ], - "editor.formatOnSave": true, + "[elixir]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "JakeBecker.elixir-ls" + }, "workbench.colorCustomizations": { - "activityBar.activeBorder": "#f9bd85", "activityBar.background": "#ad68f8", + "activityBar.activeBorder": "#f9bd85", "activityBar.foreground": "#15202b", "activityBar.inactiveForeground": "#15202b99", "activityBarBadge.background": "#f9bd85", "activityBarBadge.foreground": "#15202b", - "statusBar.background": "#9337f6", - "statusBar.foreground": "#e7e7e7", - "statusBarItem.hoverBackground": "#ad68f8", "titleBar.activeBackground": "#9337f6", - "titleBar.activeForeground": "#e7e7e7", "titleBar.inactiveBackground": "#9337f699", - "titleBar.inactiveForeground": "#e7e7e799" + "titleBar.activeForeground": "#e7e7e7", + "titleBar.inactiveForeground": "#e7e7e799", + "statusBar.background": "#9337f6", + "statusBarItem.hoverBackground": "#ad68f8", + "statusBar.foreground": "#e7e7e7" }, "peacock.affectActivityBar": true, "peacock.color": "#9337f6", diff --git a/Makefile b/Makefile index 94fab1f..ff67b48 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,36 @@ +# https://tech.davis-hansson.com/p/make/ +SHELL := bash +.ONESHELL: +.SHELLFLAGS := -eu -o pipefail -c +.DELETE_ON_ERROR: +MAKEFLAGS += --warn-undefined-variables +MAKEFLAGS += --no-builtin-rules + +SOURCE := $(shell find lib -name \*.ex) +TEST := $(shell find test -name \*.ex) + .PHONY: check clean -check: deps lib/pretty.ex - mix format --check-formatted --dry-run --check-equivalent - mix compile --warnings-as-errors - mix coveralls.html - mix credo --strict +check: _build/dev _build/test + mix test + mix credo mix dialyzer mix docs + mix format @echo "OK" -mix.lock: mix.exs +mix.lock deps: mix.exs mix deps.get mix deps.unlock --unused mix deps.clean --unused touch $@ -deps: mix.lock - mix deps.get +_build/dev: deps $(SOURCE) + MIX_ENV=dev mix compile --warnings-as-errors touch $@ -lib/pretty.ex: README.md +_build/test: deps $(SOURCE) $(TEST) + MIX_ENV=test mix compile --warnings-as-errors touch $@ clean: diff --git a/README.md b/README.md index 2745d32..d5ded6f 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ end * `mix do deps.get, deps.unlock --unused, deps.clean --unused` if you change dependencies * `mix compile --warnings-as-errors` for a stricter compile * `mix coveralls.html` to check for test coverage -* `mix credo --strict` to suggest more idiomatic style for your code +* `mix credo` to suggest more idiomatic style for your code * `mix dialyzer` to find problems typing might reveal… albeit *slowly* -* `touch lib/pretty.ex && mix docs` to generate documentation +* `mix docs` to generate documentation @@ -210,11 +210,18 @@ handler and write to it explicitly from inside the handler: ```elixir device = Process.group_leader() handler = fn name, m10s, m6a, nil -> -IO.inspect(device, {name, m10s, m6a}, label: "Ecto") + IO.inspect(device, {name, m10s, m6a}, label: "Ecto") end :telemetry.attach(self(), [:my_app, :repo, :query], handler, nil) ``` +You can _almost_ get it down to a one-liner if you lose the label: + +```elixir +dev = Process.group_leader() +:telemetry.attach(self(), [:my_app, :repo, :query], &IO.inspect(&4, {&1, &2, &3}, []), dev) +``` + ### The Case of the Missing Colors Trying to read pages of data structures without syntax coloring is hard. Where'd the colors go? diff --git a/lib/pretty.ex b/lib/pretty.ex index 3d0f19c..0e3b7d2 100644 --- a/lib/pretty.ex +++ b/lib/pretty.ex @@ -1,10 +1,11 @@ defmodule Pretty do + @external_resource "README.md" + @moduledoc "README.md" |> File.read!() |> String.split("") |> Enum.filter(&(&1 =~ ~R{})) |> Enum.join("\n") - # strip comments https://github.com/elixir-lang/ex_doc/issues/1169 |> (&Regex.replace(~R{}, &1, "")).() # compensate for anchor id differences between ExDoc and GitHub |> (&Regex.replace(~R{\(\#\K(?=[a-z][a-z0-9-]+\))}, &1, "module-")).() diff --git a/mix.exs b/mix.exs index 27162af..db8dd5a 100644 --- a/mix.exs +++ b/mix.exs @@ -1,23 +1,24 @@ defmodule Pretty.MixProject do use Mix.Project + @version "1.0.6" + def project do [ app: :pretty, deps: deps(), description: "Inspect values with syntax colors despite your remote console.", - dialyzer: dialyzer(), docs: docs(), elixir: "~> 1.8", elixirc_paths: elixirc_paths(Mix.env()), homepage_url: "https://github.com/amplifiedai/pretty", name: "Pretty", package: package(), - preferred_cli_env: preferred_cli_env(), + preferred_cli_env: [coveralls: :test, "coveralls.html": :test, "coveralls.json": :test], source_url: "https://github.com/amplifiedai/pretty", start_permanent: Mix.env() == :prod, test_coverage: [tool: ExCoveralls], - version: "1.0.6" + version: @version ] end @@ -30,51 +31,35 @@ defmodule Pretty.MixProject do defp deps do [ {:credo, "~> 1.4.0", only: [:dev, :test], runtime: false}, - {:dialyxir, "~> 1.0.0", only: [:dev], runtime: false}, - {:ex_doc, "~> 0.22.0", only: :dev, runtime: false}, - {:excoveralls, "~> 0.12.3", only: [:dev, :test]}, - {:mix_test_watch, "~> 1.0.2", only: :test, runtime: false} - ] - end - - defp dialyzer do - [ - ignore_warnings: "dialyzer.ignore-warnings", - list_unused_filters: true, - plt_add_apps: [:mix], - plt_add_deps: [:app_tree] + {:dialyxir, "~> 1.0.0", only: :dev, runtime: false}, + {:ex_doc, "~> 0.21.0", only: :dev, runtime: false}, + {:excoveralls, "~> 0.13.0", only: :test, runtime: false}, + {:mix_test_watch, "~> 1.0.2", only: :dev, runtime: false} ] end defp docs do [ - main: "Pretty" + api_reference: false, + authors: ["Garth Kidd"], + canonical: "http://hexdocs.pm/pretty", + main: "Pretty", + source_ref: "v#{@version}" ] end defp elixirc_paths(:test), do: ["test/support", "lib"] defp elixirc_paths(_), do: ["lib"] - defp package() do + defp package do [ + files: ~w(mix.exs README.md lib test/support), licenses: ["Apache 2.0"], links: %{ "Amplified" => "https://www.amplified.ai", "GitHub" => "https://github.com/amplifiedai/pretty" - } - ] - end - - defp preferred_cli_env do - [ - "coveralls.detail": :test, - "coveralls.html": :test, - "coveralls.json": :test, - "coveralls.post": :test, - "test.watch": :test, - coveralls: :test, - credo: :test, - docs: :dev + }, + maintainers: ["Garth Kidd"] ] end end diff --git a/mix.lock b/mix.lock index e8e4345..f3ef3d1 100644 --- a/mix.lock +++ b/mix.lock @@ -1,23 +1,24 @@ %{ "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"}, + "certifi": {:hex, :certifi, "2.5.2", "b7cfeae9d2ed395695dd8201c57a2d019c0c43ecaf8b8bcb9320b40d6662f340", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "3b3b5f36493004ac3455966991eaf6e768ce9884693d9968055aeeeb1e575040"}, "credo": {:hex, :credo, "1.4.0", "92339d4cbadd1e88b5ee43d427b639b68a11071b6f73854e33638e30a0ea11f5", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1fd3b70dce216574ce3c18bdf510b57e7c4c85c2ec9cad4bff854abaf7e58658"}, "dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"}, - "earmark": {:hex, :earmark, "1.4.4", "4821b8d05cda507189d51f2caeef370cf1e18ca5d7dfb7d31e9cafe6688106a4", [:mix], [], "hexpm", "1f93aba7340574847c0f609da787f0d79efcab51b044bb6e242cae5aca9d264d"}, + "earmark": {:hex, :earmark, "1.4.10", "bddce5e8ea37712a5bfb01541be8ba57d3b171d3fa4f80a0be9bcf1db417bcaf", [:mix], [{:earmark_parser, ">= 1.4.10", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "12dbfa80810478e521d3ffb941ad9fbfcbbd7debe94e1341b4c4a1b2411c1c27"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.22.0", "fb0495cd70849bc4d7bc716d4e740aebfaddb77bb1074addf357912468c831d6", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f9b36237b220c8262d561489967b6a604832593f0dc1fb1608662909457e91aa"}, - "excoveralls": {:hex, :excoveralls, "0.12.3", "2142be7cb978a3ae78385487edda6d1aff0e482ffc6123877bb7270a8ffbcfe0", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "568a3e616c264283f5dea5b020783ae40eef3f7ee2163f7a67cbd7b35bcadada"}, + "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"}, + "excoveralls": {:hex, :excoveralls, "0.13.1", "b9f1697f7c9e0cfe15d1a1d737fb169c398803ffcbc57e672aa007e9fd42864c", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "b4bb550e045def1b4d531a37fb766cbbe1307f7628bf8f0414168b3f52021cce"}, "file_system": {:hex, :file_system, "0.2.8", "f632bd287927a1eed2b718f22af727c5aeaccc9a98d8c2bd7bff709e851dc986", [:mix], [], "hexpm", "97a3b6f8d63ef53bd0113070102db2ce05352ecf0d25390eb8d747c2bde98bca"}, - "hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "e0100f8ef7d1124222c11ad362c857d3df7cb5f4204054f9f0f4a728666591fc"}, - "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"}, + "hackney": {:hex, :hackney, "1.16.0", "5096ac8e823e3a441477b2d187e30dd3fff1a82991a806b2003845ce72ce2d84", [:rebar3], [{:certifi, "2.5.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.1", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.0", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.6", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "3bf0bebbd5d3092a3543b783bf065165fa5d3ad4b899b836810e513064134e18"}, + "idna": {:hex, :idna, "6.0.1", "1d038fb2e7668ce41fbf681d2c45902e52b3cb9e9c77b55334353b222c2ee50c", [:rebar3], [{:unicode_util_compat, "0.5.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a02c8a1c4fd601215bb0b0324c8a6986749f807ce35f25449ec9e69758708122"}, "jason": {:hex, :jason, "1.2.1", "12b22825e22f468c02eb3e4b9985f3d0cb8dc40b9bd704730efa11abd2708c44", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b659b8571deedf60f79c5a608e15414085fa141344e2716fbd6988a084b5f993"}, - "makeup": {:hex, :makeup, "1.0.1", "82f332e461dc6c79dbd82fbe2a9c10d48ed07146f0a478286e590c83c52010b5", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49736fe5b66a08d8575bf5321d716bac5da20c8e6b97714fec2bcd6febcfa1f8"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"}, + "makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "mix_test_watch": {:hex, :mix_test_watch, "1.0.2", "34900184cbbbc6b6ed616ed3a8ea9b791f9fd2088419352a6d3200525637f785", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "47ac558d8b06f684773972c6d04fcc15590abdb97aeb7666da19fcbfdc441a07"}, - "nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm", "589b5af56f4afca65217a1f3eb3fee7e79b09c40c742fddc1c312b3ac0b3399f"}, + "nimble_parsec": {:hex, :nimble_parsec, "0.6.0", "32111b3bf39137144abd7ba1cce0914533b2d16ef35e8abc5ec8be6122944263", [:mix], [], "hexpm", "27eac315a94909d4dc68bc07a4a83e06c8379237c5ea528a9acff4ca1c873c52"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm", "13104d7897e38ed7f044c4de953a6c28597d1c952075eb2e328bc6d6f2bfc496"}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.5.0", "8516502659002cec19e244ebd90d312183064be95025a319a6c7e89f4bccd65b", [:rebar3], [], "hexpm", "d48d002e15f5cc105a696cf2f1bbb3fc72b4b770a184d8420c8db20da2674b38"}, } diff --git a/test/pretty_test.exs b/test/pretty_test.exs index a875188..48c8270 100644 --- a/test/pretty_test.exs +++ b/test/pretty_test.exs @@ -184,14 +184,14 @@ defmodule PrettyTest do describe "width/1 (internal)" do test "device without columns" do - device = open_test_device() |> expect({:get_geometry, :columns}, {:error, :enotsup}) + device = expect(open_test_device(), {:get_geometry, :columns}, {:error, :enotsup}) default_width = %Inspect.Opts{}.width assert ^default_width = Pretty.width(device) check!(device) end test "device with columns" do - device = open_test_device() |> expect({:get_geometry, :columns}, 98) + device = expect(open_test_device(), {:get_geometry, :columns}, 98) assert 98 = Pretty.width(device) check!(device) end diff --git a/test/support/test_device.ex b/test/support/test_device.ex index 7e2b072..9fd589f 100644 --- a/test/support/test_device.ex +++ b/test/support/test_device.ex @@ -83,12 +83,12 @@ defmodule TestDevice do {:mock_request, pid, ref, {:expect, request, reply}} -> Process.send(pid, {:mock_reply, ref, :ok}, []) - loop(state |> State.expect({request, reply})) + state |> State.expect({request, reply}) |> loop() {:mock_request, pid, ref, :flush} -> unsatisfied = State.list_remaining_expectations(state) Process.send(pid, {:mock_reply, ref, {:ok, unsatisfied}}, []) - loop(state |> State.flush()) + state |> State.flush() |> loop() {:io_request, pid, ref, request} -> {{expected, reply}, state} = State.pop_next_expectation(state)