Skip to content

Commit

Permalink
feat: added NoBorder style
Browse files Browse the repository at this point in the history
  • Loading branch information
hpopp committed May 4, 2019
1 parent 68c7430 commit 4305127
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

.iex.exs
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
45 changes: 25 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions lib/inspect_overrides.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
11 changes: 11 additions & 0 deletions lib/style/no_border.ex
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
19 changes: 19 additions & 0 deletions test/style_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4305127

Please sign in to comment.