diff --git a/lib/rdf/description.ex b/lib/rdf/description.ex index e966113..e80b7b7 100644 --- a/lib/rdf/description.ex +++ b/lib/rdf/description.ex @@ -811,8 +811,8 @@ defmodule RDF.Description do @doc """ Removes all objects from a description which are quoted triples. """ - @spec without_quoted_triples(t) :: t - def without_quoted_triples(%__MODULE__{} = description) do + @spec without_quoted_triple_objects(t) :: t + def without_quoted_triple_objects(%__MODULE__{} = description) do %__MODULE__{ description | predications: diff --git a/lib/rdf/graph.ex b/lib/rdf/graph.ex index 8bdb6a2..c880d98 100644 --- a/lib/rdf/graph.ex +++ b/lib/rdf/graph.ex @@ -652,7 +652,7 @@ defmodule RDF.Graph do Note: This function excludes only triples where the subject is a quoted triple. If you want to exclude also triples where the object is a quoted triple, - you'll have to use `RDF.Graph.without_quoted_triples/1`. + you'll have to use `RDF.Graph.without_star_statements/1`. """ @spec without_annotations(t) :: t defdelegate without_annotations(graph), to: RDF.Star.Graph @@ -662,10 +662,10 @@ defmodule RDF.Graph do This function is relatively costly, since it requires a full walk-through of all triples. In many cases quoted triples are only used on subject position, where you can use - `RDF.Graph.without_annotations/1`. + the significantly faster `RDF.Graph.without_annotations/1`. """ - @spec without_quoted_triples(t) :: t - defdelegate without_quoted_triples(graph), to: RDF.Star.Graph + @spec without_star_statements(t) :: t + defdelegate without_star_statements(graph), to: RDF.Star.Graph @doc """ Gets and updates the description of the given subject, in a single pass. diff --git a/lib/rdf/star/graph.ex b/lib/rdf/star/graph.ex index 5d0eb04..99f7967 100644 --- a/lib/rdf/star/graph.ex +++ b/lib/rdf/star/graph.ex @@ -63,14 +63,15 @@ defmodule RDF.Star.Graph do } end - @spec without_quoted_triples(Graph.t()) :: Graph.t() - def without_quoted_triples(%Graph{} = graph) do + @spec without_star_statements(Graph.t()) :: Graph.t() + def without_star_statements(%Graph{} = graph) do %Graph{ graph | descriptions: Enum.reduce(graph.descriptions, graph.descriptions, fn {subject, description}, descriptions when not is_tuple(subject) -> - description_without_quoted_triples = Description.without_quoted_triples(description) + description_without_quoted_triples = + Description.without_quoted_triple_objects(description) if Enum.empty?(description_without_quoted_triples) do Map.delete(descriptions, subject) diff --git a/test/unit/star/description_test.exs b/test/unit/star/description_test.exs index 56ca22d..ec42b18 100644 --- a/test/unit/star/description_test.exs +++ b/test/unit/star/description_test.exs @@ -205,9 +205,10 @@ defmodule RDF.Star.Description.Test do assert Description.describes?(annotation_description(), coercible_statement()) end - describe "without_quoted_triples/1" do + describe "without_quoted_triple_objects/1" do test "empty description" do - assert Description.without_quoted_triples(description()) == Description.new(description()) + assert Description.without_quoted_triple_objects(description()) == + Description.new(description()) end test "when the description has no quoted triples on object position" do @@ -219,7 +220,7 @@ defmodule RDF.Star.Description.Test do ] ) - assert Description.without_quoted_triples(description) == description + assert Description.without_quoted_triple_objects(description) == description end test "when the description has quoted triples" do @@ -230,7 +231,7 @@ defmodule RDF.Star.Description.Test do {EX.ap2(), statement()} ] ) - |> Description.without_quoted_triples() == + |> Description.without_quoted_triple_objects() == Description.new(statement(), init: {EX.ap1(), EX.ao()}) end end diff --git a/test/unit/star/graph_test.exs b/test/unit/star/graph_test.exs index 0b52e0c..141999c 100644 --- a/test/unit/star/graph_test.exs +++ b/test/unit/star/graph_test.exs @@ -1798,26 +1798,26 @@ defmodule RDF.Star.GraphTest do end end - describe "without_quoted_triples/1" do + describe "without_star_statements/1" do test "when no annotations exist" do - assert Graph.without_quoted_triples(RDF.graph()) == RDF.graph() - assert Graph.without_quoted_triples(RDF.graph(statement())) == RDF.graph(statement()) + assert Graph.without_star_statements(RDF.graph()) == RDF.graph() + assert Graph.without_star_statements(RDF.graph(statement())) == RDF.graph(statement()) end test "when annotations exist" do - assert Graph.without_quoted_triples(graph_with_annotation()) == RDF.graph() + assert Graph.without_star_statements(graph_with_annotation()) == RDF.graph() assert graph_with_annotation() |> Graph.add(statement()) - |> Graph.without_quoted_triples() == RDF.graph(statement()) + |> Graph.without_star_statements() == RDF.graph(statement()) end test "quoted triples on object position" do - assert Graph.without_quoted_triples(graph_with_quoted_triples()) == RDF.graph() + assert Graph.without_star_statements(graph_with_quoted_triples()) == RDF.graph() assert graph_with_quoted_triples() |> Graph.add(statement()) - |> Graph.without_quoted_triples() == RDF.graph(statement()) + |> Graph.without_star_statements() == RDF.graph(statement()) end end