Remove newlines from inspect string of empty descriptions
This commit is contained in:
parent
458e5b4540
commit
8dcd949d24
2 changed files with 11 additions and 6 deletions
|
@ -32,12 +32,16 @@ defimpl Inspect, for: RDF.Description do
|
||||||
|
|
||||||
header = "#RDF.Description<subject: #{inspect(description.subject)}"
|
header = "#RDF.Description<subject: #{inspect(description.subject)}"
|
||||||
|
|
||||||
body =
|
if Enum.empty?(description) do
|
||||||
description
|
header <> ">"
|
||||||
|> RDF.Turtle.write_string!(only: :triples, indent: 2)
|
else
|
||||||
|> String.trim_trailing()
|
body =
|
||||||
|
description
|
||||||
|
|> RDF.Turtle.write_string!(only: :triples, indent: 2)
|
||||||
|
|> String.trim_trailing()
|
||||||
|
|
||||||
"#{header}\n#{body}#{if limit, do: "..\n..."}\n>"
|
"#{header}\n#{body}#{if limit, do: "..\n..."}\n>"
|
||||||
|
end
|
||||||
rescue
|
rescue
|
||||||
caught_exception ->
|
caught_exception ->
|
||||||
message =
|
message =
|
||||||
|
|
|
@ -35,7 +35,8 @@ defmodule RDF.InspectTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it includes the subject when empty" do
|
test "it includes the subject when empty" do
|
||||||
assert inspect(Description.new(EX.Foo)) =~ IRI.to_string(EX.Foo)
|
assert inspect(Description.new(EX.Foo)) =~
|
||||||
|
"#RDF.Description<subject: #{inspect(RDF.iri(EX.Foo))}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it encodes the RDF-star graphs and descriptions in Turtle-star" do
|
test "it encodes the RDF-star graphs and descriptions in Turtle-star" do
|
||||||
|
|
Loading…
Reference in a new issue