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)}"
|
||||
|
||||
body =
|
||||
description
|
||||
|> RDF.Turtle.write_string!(only: :triples, indent: 2)
|
||||
|> String.trim_trailing()
|
||||
if Enum.empty?(description) do
|
||||
header <> ">"
|
||||
else
|
||||
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
|
||||
caught_exception ->
|
||||
message =
|
||||
|
|
|
@ -35,7 +35,8 @@ defmodule RDF.InspectTest do
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
test "it encodes the RDF-star graphs and descriptions in Turtle-star" do
|
||||
|
|
Loading…
Reference in a new issue