Show subject separately in RDF.Description inspect string
This commit is contained in:
parent
f76493403b
commit
458e5b4540
3 changed files with 13 additions and 2 deletions
|
@ -11,6 +11,11 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
|
|||
|
||||
- `RDF.Graph.new/2` and `RDF.Graph.add/2` support the addition of `RDF.Dataset`s
|
||||
|
||||
### Changed
|
||||
|
||||
- The inspect string of `RDF.Description` now includes the subject separately, so
|
||||
it can be seen also when the description is empty.
|
||||
|
||||
|
||||
[Compare v0.11.0...HEAD](https://github.com/rdf-elixir/rdf-ex/compare/v0.11.0...HEAD)
|
||||
|
||||
|
|
|
@ -30,12 +30,14 @@ defimpl Inspect, for: RDF.Description do
|
|||
description
|
||||
end
|
||||
|
||||
header = "#RDF.Description<subject: #{inspect(description.subject)}"
|
||||
|
||||
body =
|
||||
description
|
||||
|> RDF.Turtle.write_string!(only: :triples, indent: 2)
|
||||
|> String.trim_trailing()
|
||||
|
||||
"#RDF.Description<\n#{body}#{if limit, do: "..\n..."}\n>"
|
||||
"#{header}\n#{body}#{if limit, do: "..\n..."}\n>"
|
||||
rescue
|
||||
caught_exception ->
|
||||
message =
|
||||
|
|
|
@ -22,7 +22,7 @@ defmodule RDF.InspectTest do
|
|||
describe "RDF.Description" do
|
||||
test "it includes a header" do
|
||||
{header, _} = inspect_parts(@test_description)
|
||||
assert header == "#RDF.Description<"
|
||||
assert header == "#RDF.Description<subject: #{inspect(@test_description.subject)}"
|
||||
end
|
||||
|
||||
test "it encodes the description in Turtle" do
|
||||
|
@ -34,6 +34,10 @@ defmodule RDF.InspectTest do
|
|||
|> String.trim()) <> "\n>"
|
||||
end
|
||||
|
||||
test "it includes the subject when empty" do
|
||||
assert inspect(Description.new(EX.Foo)) =~ IRI.to_string(EX.Foo)
|
||||
end
|
||||
|
||||
test "it encodes the RDF-star graphs and descriptions in Turtle-star" do
|
||||
{_, triples} = inspect_parts(annotation_description(), limit: 2)
|
||||
assert triples =~ "<< <http://example.com/S> <http://example.com/P> \"Foo\" >>"
|
||||
|
|
Loading…
Reference in a new issue