From 430512720576d09344a4b8e26845a0095774505c Mon Sep 17 00:00:00 2001 From: Henry Popp Date: Sat, 4 May 2019 13:26:49 -0500 Subject: [PATCH] feat: added `NoBorder` style --- .gitignore | 2 ++ .travis.yml | 2 +- CHANGELOG.md | 45 ++++++++++++++++++++++------------------ README.md | 15 +++++++++++++- lib/inspect_overrides.ex | 12 +++-------- lib/style/no_border.ex | 11 ++++++++++ mix.exs | 4 +++- test/style_test.exs | 19 +++++++++++++++++ 8 files changed, 78 insertions(+), 32 deletions(-) create mode 100644 lib/style/no_border.ex diff --git a/.gitignore b/.gitignore index 6e1db0f..a8ed8ed 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ erl_crash.dump # Also ignore archive artifacts (built via "mix archive.build"). *.ez + +.iex.exs diff --git a/.travis.yml b/.travis.yml index ab0cc9e..d76e2f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ matrix: otp_release: 20.3.1 - elixir: 1.7.3 otp_release: 21.0.9 - - elixir: 1.8.0 + - elixir: 1.8.1 otp_release: 21.0.9 script: - "MIX_ENV=test mix do deps.get, compile, coveralls.travis" diff --git a/CHANGELOG.md b/CHANGELOG.md index d18b4e9..edf20a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,21 @@ -# v0.8.2 +# Changelog + +## v0.9.0 +* `NoBorder` style added. + +## v0.8.2 * Support for Elixir `v1.8` -# v0.8.1 +## v0.8.1 * Support for Elixir `v1.7` -# v0.8.0 +## v0.8.0 * `:compile_auto_inspect` and `:auto_inspect` config options, both default - to false -* Added `Scribe.auto_inspect/1` for toggling auto inspect -* Added `Scribe.auto_inspect?/0` -* Removed `Scribe.enable/0` and `Scribe.disable/0`, replaced with above -* Removed `Scribe.enabled?/0`, replaced with above + to `false`. +* Added `Scribe.auto_inspect/1` for toggling auto inspect. +* Added `Scribe.auto_inspect?/0`. +* Removed `Scribe.enable/0` and `Scribe.disable/0`, replaced with above. +* Removed `Scribe.enabled?/0`, replaced with above. To work with production releases, auto-inspect functionality can now be optionally compiled (not compiled by default). To enable auto-inspect for @@ -27,21 +32,21 @@ true again. If auto-inspect is not compiled (or disabled), `Scribe.print/2` and similar functions will continue to work as normal. -# v0.7.0 -* Pseudographics style added +## v0.7.0 +* Pseudographics style added. -# v0.6.0 +## v0.6.0 * Overrides Inspect protocol for `List` and `Map`. These types will now - automatically return in Scribe's table format. Disable by default + automatically return in Scribe's table format. Disabled by default. with `config :scribe, enable: false` in your Mix config. -* `Scribe.enable`, `Scribe.disable`, and `Scribe.enabled?` added -* Minimum Elixir version bumped to `1.5` +* `Scribe.enable`, `Scribe.disable`, and `Scribe.enabled?` added. +* Minimum Elixir version bumped to `1.5`. -# v0.5.1 -* Bump pane dependency to v0.2.0 +## v0.5.1 +* Bump pane dependency to v0.2.0. -# v0.5.0 +## v0.5.0 * `@behaviour Scribe.Style` implemented (See `/style` for example adapters) -* Colorized output -* Default styling no longer separates data rows -* Tables no longer width-limited unless specified +* Colorized output. +* Default styling no longer separates data rows. +* Tables no longer width-limited unless specified. diff --git a/README.md b/README.md index 5e625ca..5e6fc7d 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Pretty-print tables of Elixir structs and maps. Inspired by [hirb](https://githu ```elixir def deps do [ - {:scribe, "~> 0.8"} + {:scribe, "~> 0.9"} ] end ``` @@ -234,6 +234,19 @@ Scribe supports four styling formats natively, with support for custom adapters. └───────┴───────────────────────────────────┴────────────────────────┘ ``` +*NoBorder* + + ```elixir + iex> Scribe.print(data, style: Scribe.Style.NoBorder) + + :id :inserted_at :key + 457 "2017-03-27 14:42:34.095202Z" "CEB0E055ECDF6028" + 326 "2017-03-27 14:42:34.097519Z" "CF67027F7235B88D" + 756 "2017-03-27 14:42:34.097553Z" "DE016DFF477BEDDB" + 484 "2017-03-27 14:42:34.097572Z" "9194A82EF4BB0123" + 780 "2017-03-27 14:42:34.097591Z" "BF92748B4AAAF14A" + ``` + Set a default one in your Mix config if you like: ```elixir diff --git a/lib/inspect_overrides.ex b/lib/inspect_overrides.ex index b837f7a..81e96ae 100644 --- a/lib/inspect_overrides.ex +++ b/lib/inspect_overrides.ex @@ -4,17 +4,11 @@ ignore? = Code.compiler_options()[:ignore_module_conflict] Code.compiler_options(ignore_module_conflict: true) case version do - %{major: 1, minor: 8} -> - Code.load_file("inspect_overrides/1_6.ex") - - %{major: 1, minor: 7} -> - Code.load_file("inspect_overrides/1_6.ex") - - %{major: 1, minor: 6} -> - Code.load_file("inspect_overrides/1_6.ex") - %{major: 1, minor: 5} -> Code.load_file("inspect_overrides/1_5.ex") + + _ -> + Code.load_file("inspect_overrides/1_6.ex") end Code.compiler_options(ignore_module_conflict: ignore?) diff --git a/lib/style/no_border.ex b/lib/style/no_border.ex new file mode 100644 index 0000000..2dee535 --- /dev/null +++ b/lib/style/no_border.ex @@ -0,0 +1,11 @@ +defmodule Scribe.Style.NoBorder do + @moduledoc false + + alias Scribe.Border + + @behaviour Scribe.Style + + def border_at(_row, _col, _max_rows, _max_cols), do: %Border{} + + use Scribe.DefaultColors +end diff --git a/mix.exs b/mix.exs index d63caf9..9d16e94 100644 --- a/mix.exs +++ b/mix.exs @@ -1,10 +1,12 @@ defmodule Scribe.Mixfile do use Mix.Project + @version "0.9.0" + def project do [ app: :scribe, - version: "0.8.2", + version: @version, elixir: "~> 1.5", source_url: "https://github.com/codedge-llc/scribe", description: description(), diff --git a/test/style_test.exs b/test/style_test.exs index f83f692..0dce986 100644 --- a/test/style_test.exs +++ b/test/style_test.exs @@ -87,4 +87,23 @@ defmodule Scribe.StyleTest do assert actual == expected end end + + describe "no_border" do + test "outputs correct format" do + t = %Scribe.StyleTest{} + refute t.id + assert t.value == 1234 + + # Whitespace stripping breaks docstrings + expected = + " :__struct__ :id :value \n" <> + " Scribe.StyleTest nil 1234 \n" <> + " Scribe.StyleTest nil 1234 \n" <> + " Scribe.StyleTest nil 1234 \n" + + opts = [colorize: false, style: Scribe.Style.NoBorder] + actual = Scribe.format([t, t, t], opts) + assert actual == expected + end + end end