Use new RDF.IRI.coerce_base/1
for RDF.Graph.set_base_iri/2
This commit is contained in:
parent
fe49c0e431
commit
3f1afa190f
2 changed files with 9 additions and 2 deletions
|
@ -753,6 +753,8 @@ defmodule RDF.Graph do
|
|||
|
||||
@doc """
|
||||
Sets the base IRI of the given `graph`.
|
||||
|
||||
The `base_iri` can be given as anything accepted by `RDF.IRI.coerce_base/1`.
|
||||
"""
|
||||
def set_base_iri(graph, base_iri)
|
||||
|
||||
|
@ -761,7 +763,7 @@ defmodule RDF.Graph do
|
|||
end
|
||||
|
||||
def set_base_iri(%RDF.Graph{} = graph, base_iri) do
|
||||
%RDF.Graph{graph | base_iri: RDF.IRI.new(base_iri)}
|
||||
%RDF.Graph{graph | base_iri: RDF.IRI.coerce_base(base_iri)}
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
|
@ -544,11 +544,16 @@ defmodule RDF.GraphTest do
|
|||
assert graph.base_iri == ~I<http://example.com/>
|
||||
end
|
||||
|
||||
test "when given a vocabulary namespace atom" do
|
||||
test "when given a term atom under a vocabulary namespace" do
|
||||
graph = Graph.new() |> Graph.set_base_iri(EX.Base)
|
||||
assert graph.base_iri == RDF.iri(EX.Base)
|
||||
end
|
||||
|
||||
test "when given a vocabulary namespace module" do
|
||||
graph = Graph.new() |> Graph.set_base_iri(EX)
|
||||
assert graph.base_iri == RDF.iri(EX.__base_iri__)
|
||||
end
|
||||
|
||||
test "when given nil" do
|
||||
graph = Graph.new() |> Graph.set_base_iri(nil)
|
||||
assert graph.base_iri == nil
|
||||
|
|
Loading…
Reference in a new issue